summaryrefslogtreecommitdiff
path: root/worktree.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2018-02-12 09:49:35 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-02-12 21:13:35 (GMT)
commit9c620fc7a60c64e183a661f4df4f7b9e25501099 (patch)
tree2ade890bbdf75a6bdb0bd6718c838b815c778f3e /worktree.c
parent4ddddc1f1d763d3c4e0e57af1153c6d48ca4db9b (diff)
downloadgit-9c620fc7a60c64e183a661f4df4f7b9e25501099.zip
git-9c620fc7a60c64e183a661f4df4f7b9e25501099.tar.gz
git-9c620fc7a60c64e183a661f4df4f7b9e25501099.tar.bz2
worktree.c: add update_worktree_location()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'worktree.c')
-rw-r--r--worktree.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/worktree.c b/worktree.c
index b238d87..0373faf 100644
--- a/worktree.c
+++ b/worktree.c
@@ -326,6 +326,23 @@ done:
return ret;
}
+void update_worktree_location(struct worktree *wt, const char *path_)
+{
+ struct strbuf path = STRBUF_INIT;
+
+ if (is_main_worktree(wt))
+ die("BUG: can't relocate main worktree");
+
+ strbuf_realpath(&path, path_, 1);
+ if (fspathcmp(wt->path, path.buf)) {
+ write_file(git_common_path("worktrees/%s/gitdir", wt->id),
+ "%s/.git", path.buf);
+ free(wt->path);
+ wt->path = strbuf_detach(&path, NULL);
+ }
+ strbuf_release(&path);
+}
+
int is_worktree_being_rebased(const struct worktree *wt,
const char *target)
{