Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2022-02-17 16:04:36 +0300
committerJunio C Hamano <gitster@pobox.com>2022-02-17 22:19:44 +0300
commitb3a804663c4682f6df55dd6703f8f8af9a7c6ab5 (patch)
treef80dc75559e6db94ac157328c36f61fc8667c06e /t/t5503-tagfollow.sh
parent4f2ba2d06a7dd7e84e105a2779a7f07549d04231 (diff)
fetch: make `--atomic` flag cover backfilling of tags
When fetching references from a remote we by default also fetch all tags which point into the history we have fetched. This is a separate step performed after updating local references because it requires us to walk over the history on the client-side to determine whether the remote has announced any tags which point to one of the fetched commits. This backfilling of tags isn't covered by the `--atomic` flag: right now, it only applies to the step where we update our local references. This is an oversight at the time the flag was introduced: its purpose is to either update all references or none, but right now we happily update local references even in the case where backfilling failed. Fix this by pulling up creation of the reference transaction such that we can pass the same transaction to both the code which updates local references and to the code which backfills tags. This allows us to only commit the transaction in case both actions succeed. Note that we also have to start passing the transaction into `find_non_local_tags()`: this function is responsible for finding all tags which we need to backfill. Right now, it will happily return tags which have already been updated with our local references. But when we use a single transaction for both local references and backfilling then it may happen that we try to queue the same reference update twice to the transaction, which consequently triggers a bug. We thus have to skip over any tags which have already been queued. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5503-tagfollow.sh')
-rwxr-xr-xt/t5503-tagfollow.sh11
1 files changed, 3 insertions, 8 deletions
diff --git a/t/t5503-tagfollow.sh b/t/t5503-tagfollow.sh
index c057c49e80..e72fdc2534 100755
--- a/t/t5503-tagfollow.sh
+++ b/t/t5503-tagfollow.sh
@@ -180,11 +180,8 @@ test_expect_success 'atomic fetch with failing backfill' '
EOF
test_must_fail git -C clone3 fetch --atomic .. $B:refs/heads/something &&
-
- # Creation of the tag has failed, so ideally refs/heads/something
- # should not exist. The fact that it does demonstrates that there is
- # a bug in the `--atomic` flag.
- test $B = "$(git -C clone3 rev-parse --verify refs/heads/something)"
+ test_must_fail git -C clone3 rev-parse --verify refs/heads/something &&
+ test_must_fail git -C clone3 rev-parse --verify refs/tags/tag2
'
test_expect_success 'atomic fetch with backfill should use single transaction' '
@@ -197,12 +194,10 @@ test_expect_success 'atomic fetch with backfill should use single transaction' '
prepared
$ZERO_OID $B refs/heads/something
$ZERO_OID $S refs/tags/tag2
+ $ZERO_OID $T refs/tags/tag1
committed
$ZERO_OID $B refs/heads/something
$ZERO_OID $S refs/tags/tag2
- prepared
- $ZERO_OID $T refs/tags/tag1
- committed
$ZERO_OID $T refs/tags/tag1
EOF