summaryrefslogtreecommitdiff
path: root/branch.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-05-16 02:51:51 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-05-16 02:51:51 (GMT)
commit4b44b7b1df44d371eaf3fbed75829d1a749bc7df (patch)
treed8ea9ed31a6946e476db01034a653a2bbd86084c /branch.c
parenta0ab83ebd807f2bfe1a565ff94fe7d3c6903efee (diff)
parentd026a25657cbe15ceb6bcb5d5047a36a0a70b33e (diff)
downloadgit-4b44b7b1df44d371eaf3fbed75829d1a749bc7df.zip
git-4b44b7b1df44d371eaf3fbed75829d1a749bc7df.tar.gz
git-4b44b7b1df44d371eaf3fbed75829d1a749bc7df.tar.bz2
Merge branch 'nd/worktree-kill-parse-ref'
"git gc" did not interact well with "git worktree"-managed per-worktree refs. * nd/worktree-kill-parse-ref: refs: kill set_worktree_head_symref() worktree.c: kill parse_ref() in favor of refs_resolve_ref_unsafe() refs: introduce get_worktree_ref_store() refs: add REFS_STORE_ALL_CAPS refs.c: make submodule ref store hashmap generic environment.c: fix potential segfault by get_git_common_dir()
Diffstat (limited to 'branch.c')
-rw-r--r--branch.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/branch.c b/branch.c
index ad5a229..bb9eb60 100644
--- a/branch.c
+++ b/branch.c
@@ -353,17 +353,18 @@ int replace_each_worktree_head_symref(const char *oldref, const char *newref,
int i;
for (i = 0; worktrees[i]; i++) {
+ struct ref_store *refs;
+
if (worktrees[i]->is_detached)
continue;
- if (strcmp(oldref, worktrees[i]->head_ref))
+ if (worktrees[i]->head_ref &&
+ strcmp(oldref, worktrees[i]->head_ref))
continue;
- if (set_worktree_head_symref(get_worktree_git_dir(worktrees[i]),
- newref, logmsg)) {
- ret = -1;
- error(_("HEAD of working tree %s is not updated"),
- worktrees[i]->path);
- }
+ refs = get_worktree_ref_store(worktrees[i]);
+ if (refs_create_symref(refs, "HEAD", newref, logmsg))
+ ret = error(_("HEAD of working tree %s is not updated"),
+ worktrees[i]->path);
}
free_worktrees(worktrees);