Skip to content

Commit c12c9df

Browse files
navytuxgitster
authored andcommitted
fetch-pack: test explicitly that --all can fetch tag references pointing to non-commits
Fetch-pack --all became broken with respect to unusual tags in 5f0fc64 (fetch-pack: eliminate spurious error messages, 2012-09-09), and was fixed only recently in e9502c0 (fetch-pack: don't try to fetch peel values with --all, 2018-06-11). However the test added in e9502c0 does not explicitly cover all funky cases. In order to be sure fetching funky tags will never break, let's explicitly test all relevant cases with 4 tag objects pointing to 1) a blob, 2) a tree, 3) a commit, and 4) another tag objects. The referenced tag objects themselves are referenced from under regular refs/tags/* namespace. Before e9502c0 `fetch-pack --all` was failing e.g. this way: .../git/t/trash directory.t5500-fetch-pack/fetchall$ git ls-remote .. 44085874... HEAD ... bc4e9e1f... refs/tags/tag-to-blob 038f48ad... refs/tags/tag-to-blob^{} # peeled 520db1f5... refs/tags/tag-to-tree 7395c100... refs/tags/tag-to-tree^{} # peeled .../git/t/trash directory.t5500-fetch-pack/fetchall$ git fetch-pack --all .. fatal: A git upload-pack: not our ref 038f48ad... fatal: The remote end hung up unexpectedly Helped-by: Junio C Hamano <[email protected]> Signed-off-by: Kirill Smelkov <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e9502c0 commit c12c9df

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

t/t5500-fetch-pack.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,37 @@ test_expect_success 'test --all with tag to non-tip' '
528528
)
529529
'
530530

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+
531562
test_expect_success 'shallow fetch with tags does not break the repository' '
532563
mkdir repo1 &&
533564
(

0 commit comments

Comments
 (0)