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>
This commit is contained in:
Nguyễn Thái Ngọc Duy 2016-06-03 19:19:40 +07:00 коммит произвёл Junio C Hamano
Родитель 6835314459
Коммит 984ad9e56c
2 изменённых файлов: 10 добавлений и 0 удалений

Просмотреть файл

@ -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)
{

Просмотреть файл

@ -37,6 +37,11 @@ extern struct worktree *find_worktree(struct worktree **list,
const char *prefix,
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)
*/