Skip to content

Commit 606e435

Browse files
pcloudsgitster
authored andcommitted
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 the 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 <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 0b854bc commit 606e435

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

builtin/clone.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,12 @@ static int add_one_reference(struct string_list_item *item, void *cb_data)
252252
die(_("reference repository '%s' is not a local repository."),
253253
item->string);
254254

255+
if (!access(mkpath("%s/shallow", ref_git), F_OK))
256+
die(_("reference repository '%s' is shallow"), item->string);
257+
258+
if (!access(mkpath("%s/info/grafts", ref_git), F_OK))
259+
die(_("reference repository '%s' is grafted"), item->string);
260+
255261
strbuf_addf(&alternate, "%s/objects", ref_git);
256262
add_to_alternates_file(alternate.buf);
257263
strbuf_release(&alternate);

0 commit comments

Comments
 (0)