From 7c2b3029df45a74d0ebd11afcc94259791cfb90d Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 7 Apr 2009 03:14:20 -0400 Subject: make get_short_ref a public function Often we want to shorten a full ref name to something "prettier" to show a user. For example, "refs/heads/master" is often shown simply as "master", or "refs/remotes/origin/master" is shown as "origin/master". Many places in the code use a very simple formula: skip common prefixes like refs/heads, refs/remotes, etc. This is codified in the prettify_ref function. for-each-ref has a more correct (but more expensive) approach: consider the ref lookup rules, and try shortening as much as possible while remaining unambiguous. This patch makes the latter strategy globally available as shorten_unambiguous_ref. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- refs.h | 1 + 1 file changed, 1 insertion(+) (limited to 'refs.h') diff --git a/refs.h b/refs.h index 68c2d16d53..2d0f961c7c 100644 --- a/refs.h +++ b/refs.h @@ -80,6 +80,7 @@ extern int for_each_reflog(each_ref_fn, void *); extern int check_ref_format(const char *target); extern const char *prettify_ref(const struct ref *ref); +extern char *shorten_unambiguous_ref(const char *ref); /** rename ref, return 0 on success **/ extern int rename_ref(const char *oldref, const char *newref, const char *logmsg); -- cgit v1.2.3