Skip to content

Commit f1fc1e8

Browse files
chriscoolgitster
authored andcommitted
t9350: properly count annotated tags
In t9350-fast-export.sh, these existing tests: - 'fast-export | fast-import when main is tagged' - 'cope with tagger-less tags' are checking the number of annotated tags in the test repo by comparing it with some hardcoded values. This could be an issue if some new tests that have some prerequisites add new annotated tags to the repo before these existing tests. When the prerequisites would be satisfied, the number of annotated tags would be different from when some prerequisites would not be satisfied. As we are going to add new tests that add new annotated tags in a following commit, let's properly count the number of annotated tag in the repo by incrementing a counter each time a new annotated tag is added, and then by comparing the number of annotated tags to the value of the counter when checking the number of annotated tags. Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d2cd755 commit f1fc1e8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

t/t9350-fast-export.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ test_expect_success 'setup' '
3535
git commit -m sitzt file2 &&
3636
test_tick &&
3737
git tag -a -m valentin muss &&
38+
ANNOTATED_TAG_COUNT=1 &&
3839
git merge -s ours main
3940
4041
'
@@ -229,7 +230,8 @@ EOF
229230

230231
test_expect_success 'set up faked signed tag' '
231232
232-
git fast-import <signed-tag-import
233+
git fast-import <signed-tag-import &&
234+
ANNOTATED_TAG_COUNT=$((ANNOTATED_TAG_COUNT + 1))
233235
234236
'
235237

@@ -491,8 +493,9 @@ test_expect_success 'fast-export -C -C | fast-import' '
491493
test_expect_success 'fast-export | fast-import when main is tagged' '
492494
493495
git tag -m msg last &&
496+
ANNOTATED_TAG_COUNT=$((ANNOTATED_TAG_COUNT + 1)) &&
494497
git fast-export -C -C --signed-tags=strip --all > output &&
495-
test $(grep -c "^tag " output) = 3
498+
test $(grep -c "^tag " output) = $ANNOTATED_TAG_COUNT
496499
497500
'
498501

@@ -506,12 +509,13 @@ test_expect_success 'cope with tagger-less tags' '
506509
507510
TAG=$(git hash-object --literally -t tag -w tag-content) &&
508511
git update-ref refs/tags/sonnenschein $TAG &&
512+
ANNOTATED_TAG_COUNT=$((ANNOTATED_TAG_COUNT + 1)) &&
509513
git fast-export -C -C --signed-tags=strip --all > output &&
510-
test $(grep -c "^tag " output) = 4 &&
514+
test $(grep -c "^tag " output) = $ANNOTATED_TAG_COUNT &&
511515
! grep "Unspecified Tagger" output &&
512516
git fast-export -C -C --signed-tags=strip --all \
513517
--fake-missing-tagger > output &&
514-
test $(grep -c "^tag " output) = 4 &&
518+
test $(grep -c "^tag " output) = $ANNOTATED_TAG_COUNT &&
515519
grep "Unspecified Tagger" output
516520
517521
'

0 commit comments

Comments
 (0)