diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-04-18 10:48:11 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-04-18 10:48:11 -0700 |
commit | 741a6942eb241dfc1317b7692381fc41dbb92501 (patch) | |
tree | d716da40ac03d8fbe811aeebacd9168d247ba186 /branch.c | |
parent | b8b4d93100651876299eabaf76248510e616fab3 (diff) | |
parent | 18eb3a9ce7c544e74d424b942c5a5c9720c20112 (diff) | |
download | git-741a6942eb241dfc1317b7692381fc41dbb92501.tar.gz git-741a6942eb241dfc1317b7692381fc41dbb92501.tar.xz |
Merge branch 'ky/branch-m-worktree'
When "git worktree" feature is in use, "git branch -m" renamed a
branch that is checked out in another worktree without adjusting
the HEAD symbolic ref for the worktree.
* ky/branch-m-worktree:
set_worktree_head_symref(): fix error message
branch -m: update all per-worktree HEADs
refs: add a new function set_worktree_head_symref
Diffstat (limited to 'branch.c')
-rw-r--r-- | branch.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -344,3 +344,26 @@ void die_if_checked_out(const char *branch) die(_("'%s' is already checked out at '%s'"), branch, existing); } } + +int replace_each_worktree_head_symref(const char *oldref, const char *newref) +{ + int ret = 0; + struct worktree **worktrees = get_worktrees(); + int i; + + for (i = 0; worktrees[i]; i++) { + if (worktrees[i]->is_detached) + continue; + if (strcmp(oldref, worktrees[i]->head_ref)) + continue; + + if (set_worktree_head_symref(worktrees[i]->git_dir, newref)) { + ret = -1; + error(_("HEAD of working tree %s is not updated"), + worktrees[i]->path); + } + } + + free_worktrees(worktrees); + return ret; +} |