[PATCH v3 10/21] Use cgit_namespaced_dwim_ref for finding logs to show

Richard Maw richard.maw at gmail.com
Mon Aug 1 23:35:42 CEST 2016


This replaces the previous behaviour of disambiguate_ref,
which would only prepend refs/heads to the branch name,
so would not disambiguate tags to their full refs.

Now when an abbreviated ref is provided
the namespace is prepended to it
as well as the disambiguating path.

Signed-off-by: Richard Maw <richard.maw at gmail.com>
---
 ui-log.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/ui-log.c b/ui-log.c
index 28ef3c0..71ef3d4 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -322,16 +322,12 @@ static void print_commit(struct commit *commit, struct rev_info *revs)
 static const char *disambiguate_ref(const char *ref, int *must_free_result)
 {
 	struct object_id oid;
-	struct strbuf longref = STRBUF_INIT;
 
-	strbuf_addf(&longref, "refs/heads/%s", ref);
-	if (cgit_get_sha1(longref.buf, oid.hash) == 0) {
+	if (cgit_namespaced_dwim_ref(ref, oid.hash, (char**)&ref))
 		*must_free_result = 1;
-		return strbuf_detach(&longref, NULL);
-	}
+	else
+		*must_free_result = 0;
 
-	*must_free_result = 0;
-	strbuf_release(&longref);
 	return ref;
 }
 
-- 
2.9.0



More information about the CGit mailing list