Skip to content

Commit 0079732

Browse files
committed
Merge branch 'jk/fetch-all-peeled-fix'
"git fetch-pack --all" used to unnecessarily fail upon seeing an annotated tag that points at an object other than a commit. * jk/fetch-all-peeled-fix: fetch-pack: test explicitly that --all can fetch tag references pointing to non-commits fetch-pack: don't try to fetch peel values with --all
2 parents 8d3661d + c12c9df commit 0079732

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

fetch-pack.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -657,11 +657,11 @@ static void filter_refs(struct fetch_pack_args *args,
657657
}
658658
i++;
659659
}
660-
}
661660

662-
if (!keep && args->fetch_all &&
663-
(!args->deepen || !starts_with(ref->name, "refs/tags/")))
664-
keep = 1;
661+
if (!keep && args->fetch_all &&
662+
(!args->deepen || !starts_with(ref->name, "refs/tags/")))
663+
keep = 1;
664+
}
665665

666666
if (keep) {
667667
*newtail = ref;

t/t5500-fetch-pack.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,47 @@ test_expect_success 'test --all, --depth, and explicit tag' '
518518
) >out-adt 2>error-adt
519519
'
520520

521+
test_expect_success 'test --all with tag to non-tip' '
522+
git commit --allow-empty -m non-tip &&
523+
git commit --allow-empty -m tip &&
524+
git tag -m "annotated" non-tip HEAD^ &&
525+
(
526+
cd client &&
527+
git fetch-pack --all ..
528+
)
529+
'
530+
531+
test_expect_success 'test --all wrt tag to non-commits' '
532+
# create tag-to-{blob,tree,commit,tag}, making sure all tagged objects
533+
# are reachable only via created tag references.
534+
blob=$(echo "hello blob" | git hash-object -t blob -w --stdin) &&
535+
git tag -a -m "tag -> blob" tag-to-blob $blob &&
536+
\
537+
tree=$(printf "100644 blob $blob\tfile" | git mktree) &&
538+
git tag -a -m "tag -> tree" tag-to-tree $tree &&
539+
\
540+
tree2=$(printf "100644 blob $blob\tfile2" | git mktree) &&
541+
commit=$(git commit-tree -m "hello commit" $tree) &&
542+
git tag -a -m "tag -> commit" tag-to-commit $commit &&
543+
\
544+
blob2=$(echo "hello blob2" | git hash-object -t blob -w --stdin) &&
545+
tag=$(printf "object $blob2\ntype blob\ntag tag-to-blob2\n\
546+
tagger author A U Thor <[email protected]> 0 +0000\n\nhello tag" | git mktag) &&
547+
git tag -a -m "tag -> tag" tag-to-tag $tag &&
548+
\
549+
# `fetch-pack --all` should succeed fetching all those objects.
550+
mkdir fetchall &&
551+
(
552+
cd fetchall &&
553+
git init &&
554+
git fetch-pack --all .. &&
555+
git cat-file blob $blob >/dev/null &&
556+
git cat-file tree $tree >/dev/null &&
557+
git cat-file commit $commit >/dev/null &&
558+
git cat-file tag $tag >/dev/null
559+
)
560+
'
561+
521562
test_expect_success 'shallow fetch with tags does not break the repository' '
522563
mkdir repo1 &&
523564
(

0 commit comments

Comments
 (0)