Git fork

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.

This is a bit ugly, but it makes it explicit that some tests are
interdependent. Alternative solutions, like moving the new tests to
the end of the script, were considered, but were rejected because they
would instead hide the technical debt and could confuse developers in
the future.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Christian Couder and committed by
Junio C Hamano
132e5666 e204a167

+8 -4
+8 -4
t/t9350-fast-export.sh
··· 35 35 git commit -m sitzt file2 && 36 36 test_tick && 37 37 git tag -a -m valentin muss && 38 + ANNOTATED_TAG_COUNT=1 && 38 39 git merge -s ours main 39 40 40 41 ' ··· 229 230 230 231 test_expect_success 'set up faked signed tag' ' 231 232 232 - git fast-import <signed-tag-import 233 + git fast-import <signed-tag-import && 234 + ANNOTATED_TAG_COUNT=$((ANNOTATED_TAG_COUNT + 1)) 233 235 234 236 ' 235 237 ··· 491 493 test_expect_success 'fast-export | fast-import when main is tagged' ' 492 494 493 495 git tag -m msg last && 496 + ANNOTATED_TAG_COUNT=$((ANNOTATED_TAG_COUNT + 1)) && 494 497 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 496 499 497 500 ' 498 501 ··· 506 509 507 510 TAG=$(git hash-object --literally -t tag -w tag-content) && 508 511 git update-ref refs/tags/sonnenschein $TAG && 512 + ANNOTATED_TAG_COUNT=$((ANNOTATED_TAG_COUNT + 1)) && 509 513 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 && 511 515 ! grep "Unspecified Tagger" output && 512 516 git fast-export -C -C --signed-tags=strip --all \ 513 517 --fake-missing-tagger > output && 514 - test $(grep -c "^tag " output) = 4 && 518 + test $(grep -c "^tag " output) = $ANNOTATED_TAG_COUNT && 515 519 grep "Unspecified Tagger" output 516 520 517 521 '