aboutsummaryrefslogtreecommitdiffstats
path: root/commit-graph.c
diff options
context:
space:
mode:
authorDerrick Stolee <derrickstolee@github.com>2022-06-14 19:27:31 +0000
committerJunio C Hamano <gitster@pobox.com>2022-06-15 10:47:18 -0700
commit12d47e3b1fbdc3891ec9d2106a43809ce7fa1363 (patch)
treee77641c24fa711a86d784688c057429089b69277 /commit-graph.c
parentbranch: check for bisects and rebases (diff)
downloadgit-12d47e3b1fbdc3891ec9d2106a43809ce7fa1363.tar.gz
git-12d47e3b1fbdc3891ec9d2106a43809ce7fa1363.zip
fetch: use new branch_checked_out() and add tests
When fetching refs from a remote, it is possible that the refspec will cause use to overwrite a ref that is checked out in a worktree. The existing logic in builtin/fetch.c uses a possibly-slow mechanism. Update those sections to use the new, more efficient branch_checked_out() helper. These uses were not previously tested, so add a test case that can be used for these kinds of collisions. There is only one test now, but more tests will be added as other consumers of branch_checked_out() are added. Note that there are two uses in builtin/fetch.c, but only one of the messages is tested. This is because the tested check is run before completing the fetch, and the untested check is not reachable without concurrent updates to the filesystem. Thus, it is beneficial to keep that extra check for the sake of defense-in-depth. However, we should not attempt to test the check, as the effort required is too complicated to be worth the effort. This use in update_local_ref() also requires a change in the error message because we no longer have access to the worktree struct, only the path of the worktree. This error is so rare that making a distinction between the two is not critical. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit-graph.c')
0 files changed, 0 insertions, 0 deletions