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:41 +0300
committerJunio C Hamano <gitster@pobox.com>2022-02-17 22:19:44 +0300
commit583bc419235cedc6a2ba12593f058a9f812b9594 (patch)
tree8cfcc26b49a15a2a32ec7226bc901927e9351503 /t/t5510-fetch.sh
parentb3a804663c4682f6df55dd6703f8f8af9a7c6ab5 (diff)
fetch: make `--atomic` flag cover pruning of refs
When fetching with the `--prune` flag we will delete any local references matching the fetch refspec which have disappeared on the remote. This step is not currently covered by the `--atomic` flag: we delete branches even though updating of local references has failed, which means that the fetch is not an all-or-nothing operation. Fix this bug by passing in the global transaction into `prune_refs()`: if one is given, then we'll only queue up deletions and not commit them right away. This change also improves performance when pruning many branches in a repository with a big packed-refs file: every references is pruned in its own transaction, which means that we potentially have to rewrite the packed-refs files for every single reference we're about to prune. The following benchmark demonstrates this: it performs a pruning fetch from a repository with a single reference into a repository with 100k references, which causes us to prune all but one reference. This is of course a very artificial setup, but serves to demonstrate the impact of only having to write the packed-refs file once: Benchmark 1: git fetch --prune --atomic +refs/*:refs/* (HEAD~) Time (mean ± σ): 2.366 s ± 0.021 s [User: 0.858 s, System: 1.508 s] Range (min … max): 2.328 s … 2.407 s 10 runs Benchmark 2: git fetch --prune --atomic +refs/*:refs/* (HEAD) Time (mean ± σ): 1.369 s ± 0.017 s [User: 0.715 s, System: 0.641 s] Range (min … max): 1.346 s … 1.400 s 10 runs Summary 'git fetch --prune --atomic +refs/*:refs/* (HEAD)' ran 1.73 ± 0.03 times faster than 'git fetch --prune --atomic +refs/*:refs/* (HEAD~)' Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5510-fetch.sh')
-rwxr-xr-xt/t5510-fetch.sh8
1 files changed, 2 insertions, 6 deletions
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 70d51f343b..48e14e2dab 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -354,17 +354,13 @@ test_expect_success 'fetch --atomic --prune executes a single reference transact
head_oid=$(git rev-parse HEAD) &&
# Fetching with the `--atomic` flag should update all references in a
- # single transaction. It is currently missing coverage of pruned
- # references though, and as a result those may be committed to disk
- # even if updating references fails later.
+ # single transaction.
cat >expected <<-EOF &&
prepared
$ZERO_OID $ZERO_OID refs/remotes/origin/scheduled-for-deletion
- committed
- $ZERO_OID $ZERO_OID refs/remotes/origin/scheduled-for-deletion
- prepared
$ZERO_OID $head_oid refs/remotes/origin/new-branch
committed
+ $ZERO_OID $ZERO_OID refs/remotes/origin/scheduled-for-deletion
$ZERO_OID $head_oid refs/remotes/origin/new-branch
EOF