Files
git/builtin
Patrick Steinhardt 583bc41923 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>
2022-02-17 11:19:44 -08:00
..
2022-01-27 18:00:15 -08:00
2022-02-09 14:21:00 -08:00
2020-07-30 19:18:06 -07:00
2021-12-21 15:03:17 -08:00
2022-02-16 15:14:29 -08:00
2021-10-28 09:57:09 -07:00
2021-02-25 16:43:30 -08:00
2022-02-09 14:21:00 -08:00
2021-10-23 10:45:25 -07:00
2022-02-16 15:14:29 -08:00
2021-04-14 13:47:21 -07:00
2022-02-09 14:21:00 -08:00
2021-09-28 10:31:02 -07:00
2022-01-10 11:52:53 -08:00
2020-03-24 15:04:44 -07:00
2022-01-03 16:24:15 -08:00
2022-01-10 11:52:56 -08:00
2022-02-16 15:14:30 -08:00
2022-01-05 13:31:00 -08:00
2021-11-03 13:25:36 -07:00
2020-08-11 18:04:11 -07:00