From ab3e1f78ae8ecb3371cf85a36d73fd341fad3884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sun, 21 Oct 2018 10:08:56 +0200 Subject: revision.c: better error reporting on ref from different worktrees MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make use of the new ref aliases to pass refs from another worktree around and access them from the current ref store instead. This does not change any functionality, but when a problem arises, we would like the reported messages to mention full ref aliases, like this: fatal: bad object worktrees/ztemp/HEAD warning: reflog of 'main-worktree/HEAD' references pruned commits instead of fatal: bad object HEAD warning: reflog of 'HEAD' references pruned commits which does not really tell where the refs are from. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- worktree.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'worktree.h') diff --git a/worktree.h b/worktree.h index 440bb219dd..1164ca396f 100644 --- a/worktree.h +++ b/worktree.h @@ -117,4 +117,19 @@ extern const char *worktree_git_path(const struct worktree *wt, */ int parse_worktree_ref(const char *worktree_ref, const char **name, int *name_length, const char **ref); + +/* + * Return a refname suitable for access from the current ref store. + */ +void strbuf_worktree_ref(const struct worktree *wt, + struct strbuf *sb, + const char *refname); + +/* + * Return a refname suitable for access from the current ref + * store. The result will be destroyed at the next call. + */ +const char *worktree_ref(const struct worktree *wt, + const char *refname); + #endif -- cgit v1.2.3