summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2008-12-03 16:34:23 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2008-12-03 16:34:23 (UTC)
commita1b01b2513510f8f93f7f8ca39969002cd496a19 (patch) (side-by-side diff)
tree143e569416a89b31de6f96e8e79f8841c24dd935
parentc7d1402b177f4cf835e81f962e2faa3c9e28c549 (diff)
downloadcgit-a1b01b2513510f8f93f7f8ca39969002cd496a19.zip
cgit-a1b01b2513510f8f93f7f8ca39969002cd496a19.tar.gz
cgit-a1b01b2513510f8f93f7f8ca39969002cd496a19.tar.bz2
ui-log: try to disambiguate ref names
The 'h' querystring parameter in cgit is normally used to specify a branch (i.e. a ref below refs/heads/), but if a repository contains a tag with the same name as a branch the output from ui-log would use the tag as start-revision. This patch tries to fix the issue by checking if the specified ref is valid as a branch name; if so, the full refname is used in the call to setup_revisions(). Noticed-by: Takamori Yamaguchi <akschar@gmail.com> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--ui-log.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/ui-log.c b/ui-log.c
index 8dd8b89..d212984 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -66,2 +66,13 @@ void print_commit(struct commit *commit)
+static const char *disambiguate_ref(const char *ref)
+{
+ unsigned char sha1[20];
+ const char *longref;
+
+ longref = fmt("refs/heads/%s", ref);
+ if (get_sha1(longref, sha1) == 0)
+ return longref;
+
+ return ref;
+}
@@ -72,3 +83,3 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
struct commit *commit;
- const char *argv[] = {NULL, tip, NULL, NULL, NULL};
+ const char *argv[] = {NULL, NULL, NULL, NULL, NULL};
int argc = 2;
@@ -77,3 +88,5 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
if (!tip)
- argv[1] = ctx.qry.head;
+ tip = ctx.qry.head;
+
+ argv[1] = disambiguate_ref(tip);