[PATCH 4/7] worktree.c: add worktree_git_path_..._head()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]