[PATCH 4/7] worktree.c: add worktree_git_path_..._head()
- From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
- Date
- Apr 17, 2016, 12:59 UTC
- Message-ID
- <1460897965-486-5-git-send-email-pclouds@gmail.com>
- In-Reply-To
- <1460897965-486-1-git-send-email-pclouds@gmail.com>
These are a variant of git_path_..._head(), defined with GIT_PATH_FUNC macro but they takes worktree into account. To be used when wt_status_get_state() is converted to be worktree-aware.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> --- worktree.c | 4 ++++ worktree.h | 13 +++++++++++++ 2 files changed, 17 insertions(+)
diff --git a/worktree.c b/worktree.c index 5ae54f0..c5bf583 100644 --- a/worktree.c +++ b/worktree.c @@ -222,3 +222,7 @@ char *find_shared_symref(const char *symref, const char *target) return existing; } + +WORKTREE_GIT_PATH_FUNC(merge_head, "MERGE_HEAD") +WORKTREE_GIT_PATH_FUNC(cherry_pick_head, "CHERRY_PICK_HEAD") +WORKTREE_GIT_PATH_FUNC(revert_head, "REVERT_HEAD") diff --git a/worktree.h b/worktree.h index 9ae2028..b7c5da0 100644 --- a/worktree.h +++ b/worktree.h @@ -52,4 +52,17 @@ extern char *worktree_git_pathdup(const struct worktree *wt, const char *fmt, ...) __attribute__((format (printf, 2, 3))); +#define WORKTREE_GIT_PATH_FUNC(func, filename) \ + const char *worktree_git_path_ ## func(const struct worktree *wt) \ + { \ + static char *ret; \ + if (!ret) \ + ret = worktree_git_pathdup(wt, filename); \ + return ret; \ + } + +const char *worktree_git_path_merge_head(const struct worktree *); +const char *worktree_git_path_cherry_pick_head(const struct worktree *); +const char *worktree_git_path_revert_head(const struct worktree *); + #endif
-- 2.8.0.rc0.210.gd302cd2