aboutsummaryrefslogtreecommitdiffstats
path: root/worktree.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-12-21 15:03:16 -0800
committerJunio C Hamano <gitster@pobox.com>2021-12-21 15:03:16 -0800
commit13fa77b6899d0068303761c449d9a7e01dd85eb8 (patch)
treeb15e735aa90f701444aaa66ab080695f10a85549 /worktree.c
parentee1dc493d10d814ceba1a551d9a185b9da627ad8 (diff)
parent593a2a5d0639b4b4f91ff6e6ffb64e72020f8fd8 (diff)
downloadgit-13fa77b6899d0068303761c449d9a7e01dd85eb8.tar.gz
Merge branch 'ak/protect-any-current-branch'
"git fetch" without the "--update-head-ok" option ought to protect a checked out branch from getting updated, to prevent the working tree that checks it out to go out of sync. The code was written before the use of "git worktree" got widespread, and only checked the branch that was checked out in the current worktree, which has been updated. (originally called ak/fetch-not-overwrite-any-current-branch) * ak/protect-any-current-branch: branch: protect branches checked out in all worktrees receive-pack: protect current branch for bare repository worktree receive-pack: clean dead code from update_worktree() fetch: protect branches checked out in all worktrees worktree: simplify find_shared_symref() memory ownership model branch: lowercase error messages receive-pack: lowercase error messages fetch: lowercase error messages
Diffstat (limited to 'worktree.c')
-rw-r--r--worktree.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/worktree.c b/worktree.c
index 2c155b1015..6f598dcfcd 100644
--- a/worktree.c
+++ b/worktree.c
@@ -404,17 +404,13 @@ int is_worktree_being_bisected(const struct worktree *wt,
* bisect). New commands that do similar things should update this
* function as well.
*/
-const struct worktree *find_shared_symref(const char *symref,
+const struct worktree *find_shared_symref(struct worktree **worktrees,
+ const char *symref,
const char *target)
{
const struct worktree *existing = NULL;
- static struct worktree **worktrees;
int i = 0;
- if (worktrees)
- free_worktrees(worktrees);
- worktrees = get_worktrees();
-
for (i = 0; worktrees[i]; i++) {
struct worktree *wt = worktrees[i];
const char *symref_target;