aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2016-06-03 19:19:40 +0700
committerJunio C Hamano <gitster@pobox.com>2016-06-03 21:58:35 -0700
commit984ad9e56c9d884f7f1aa7d6b2052f3fb082ee5d (patch)
treed286f5932f63dc4005655468cb6fa520b3539dba
parent6835314459794831a1b88bed56549653710e910c (diff)
downloadgit-984ad9e56c9d884f7f1aa7d6b2052f3fb082ee5d.tar.gz
git-984ad9e56c9d884f7f1aa7d6b2052f3fb082ee5d.tar.xz
worktree.c: add is_main_worktree()
Main worktree _is_ different. You can lock (*) a linked worktree but not the main one, for example. Provide an API for checking that. (*) Add the file $GIT_DIR/worktrees/xxx/locked to avoid worktree xxx from being removed or moved. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--worktree.c5
-rw-r--r--worktree.h5
2 files changed, 10 insertions, 0 deletions
diff --git a/worktree.c b/worktree.c
index 0782e0098..12a766a38 100644
--- a/worktree.c
+++ b/worktree.c
@@ -229,6 +229,11 @@ struct worktree *find_worktree(struct worktree **list,
return *list;
}
+int is_main_worktree(const struct worktree *wt)
+{
+ return !wt->id;
+}
+
int is_worktree_being_rebased(const struct worktree *wt,
const char *target)
{
diff --git a/worktree.h b/worktree.h
index 7ad15da0d..e1c471523 100644
--- a/worktree.h
+++ b/worktree.h
@@ -38,6 +38,11 @@ extern struct worktree *find_worktree(struct worktree **list,
const char *arg);
/*
+ * Return true if the given worktree is the main one.
+ */
+extern int is_main_worktree(const struct worktree *wt);
+
+/*
* Free up the memory for worktree(s)
*/
extern void free_worktrees(struct worktree **);