On the git checkout part of git pull, see torek's answer.
On the git fetch part of git pull, there is an --atomic flag, Git 2.36 (Q2 2022) clarifies it.
"git fetch"(man) can make two separate fetches, but ref updates coming from them were in two separate ref transactions under "--atomic", which has been corrected with Git 2.36 (Q2 2022).
See commit 583bc41, commit b3a8046, commit 4f2ba2d, commit 62091b4, commit 2983cec, commit efbade0, commit 2a0cafd (17 Feb 2022) by Patrick Steinhardt (pks-t).
(Merged by Junio C Hamano -- gitster -- in commit 851d2f0, 13 Mar 2022)
fetch: increase test coverage of fetches
Signed-off-by: Patrick Steinhardt
When using git fetch with the --atomic flag, the expectation is that either all of the references are updated, or alternatively none are in case the fetch fails.
While we already have tests for this, we do not have any tests which exercise atomicity either when pruning deleted refs or when backfilling tags.
This gap in test coverage hides that we indeed don't handle atomicity correctly for both of these cases.
Add test cases which cover these testing gaps to demonstrate the broken behaviour.
Warning:
With Git 2.36 (Q2 2022), revert the "deletion of a ref should not trigger transaction events for loose and packed ref backends separately" that regresses the behaviour when a ref is not modified since it was packed.
See commit 4315986, commit 347cc1b, commit c6da34a (13 Apr 2022) by Junio C Hamano (gitster).
(Merged by Junio C Hamano -- gitster -- in commit 4027e30, 14 Apr 2022)
4027e30c53:Merge branch 'jc/revert-ref-transaction-hook-changes'
Revert "fetch: increase test coverage of fetches"
Revert "Merge branch 'ps/avoid-unnecessary-hook-invocation-with-packed-refs'"
"git fetch --atomic"(man) issued an unnecessary empty error message, which has been corrected with Git 2.44 (Q1 2024).
See commit 18ce489, commit 97d82b2 (17 Dec 2023) by Jiang Xin (jiangxin).
(Merged by Junio C Hamano -- gitster -- in commit deb67d1, 27 Dec 2023)
fetch: no redundant error message for atomic fetch
Helped-by: Patrick Steinhardt
Signed-off-by: Jiang Xin
Acked-by: Patrick Steinhardt
If an error occurs during an atomic fetch, a redundant error message will appear at the end of do_fetch().
It was introduced in b3a8046 ("fetch: make --atomic flag cover backfilling of tags", 2022-02-17, Git v2.36.0-rc0 -- merge listed in batch #11).
Because a failure message is displayed before setting retcode in the function do_fetch(), calling error() on the err message at the end of this function may result in redundant or empty error message to be displayed.
We can remove the redundant error() function, because we know that the function ref_transaction_abort() never fails.
While we can find a common pattern for calling ref_transaction_abort() by running command "git grep"(man) -A1 ref_transaction_abort", e.g.:
if (ref_transaction_abort(transaction, &error)) error("abort: %s", error.buf);
Following this pattern, we can tolerate the return value of the function ref_transaction_abort() being changed in the future.
We also delay the output of the err message to the end of do_fetch() to reduce redundant code.