Re: [PATCH v3 03/28] clone: prevent --reference to a shallow repository
On Sun, Nov 24, 2013 at 10:55 PM, Nguyễn Thái Ngọc Duy pclo...@gmail.com wrote: If we borrow objects from another repository, we should also pay attention to their $GIT_DIR/shallow (and even info/grafts). But current alternates code does not. Reject alternate repos that are shallow because we do not do it right. In future we alternate code may be updated to check s/we/the/ $GIT_DIR/shallow properly so that this restriction could be lifted. Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- builtin/clone.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/builtin/clone.c b/builtin/clone.c index 874e0fd..900f564 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -252,6 +252,12 @@ static int add_one_reference(struct string_list_item *item, void *cb_data) die(_(reference repository '%s' is not a local repository.), item-string); + if (!access(mkpath(%s/shallow, ref_git), F_OK)) + die(_(reference repository '%s' is shallow), item-string); + + if (!access(mkpath(%s/info/grafts, ref_git), F_OK)) + die(_(reference repository '%s' is grafted), item-string); + strbuf_addf(alternate, %s/objects, ref_git); add_to_alternates_file(alternate.buf); strbuf_release(alternate); -- 1.8.2.83.gc99314b -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 03/28] clone: prevent --reference to a shallow repository
If we borrow objects from another repository, we should also pay attention to their $GIT_DIR/shallow (and even info/grafts). But current alternates code does not. Reject alternate repos that are shallow because we do not do it right. In future we alternate code may be updated to check $GIT_DIR/shallow properly so that this restriction could be lifted. Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- builtin/clone.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/builtin/clone.c b/builtin/clone.c index 874e0fd..900f564 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -252,6 +252,12 @@ static int add_one_reference(struct string_list_item *item, void *cb_data) die(_(reference repository '%s' is not a local repository.), item-string); + if (!access(mkpath(%s/shallow, ref_git), F_OK)) + die(_(reference repository '%s' is shallow), item-string); + + if (!access(mkpath(%s/info/grafts, ref_git), F_OK)) + die(_(reference repository '%s' is grafted), item-string); + strbuf_addf(alternate, %s/objects, ref_git); add_to_alternates_file(alternate.buf); strbuf_release(alternate); -- 1.8.2.83.gc99314b -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html