aboutsummaryrefslogtreecommitdiffstats
path: root/ui-log.c
diff options
context:
space:
mode:
authorGravatar Lars Hjemli <hjemli@gmail.com>2008-12-04 01:34:23 (JST)
committerGravatar Lars Hjemli <hjemli@gmail.com>2008-12-04 01:34:23 (JST)
commita1b01b2513510f8f93f7f8ca39969002cd496a19 (patch)
tree143e569416a89b31de6f96e8e79f8841c24dd935 /ui-log.c
parentc7d1402b177f4cf835e81f962e2faa3c9e28c549 (diff)
downloadcgit-a1b01b2513510f8f93f7f8ca39969002cd496a19.zip
cgit-a1b01b2513510f8f93f7f8ca39969002cd496a19.tar.gz
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 (limited to 'ui-log.c')
-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
@@ -64,18 +64,31 @@ void print_commit(struct commit *commit)
64 cgit_free_commitinfo(info); 64 cgit_free_commitinfo(info);
65} 65}
66 66
67static const char *disambiguate_ref(const char *ref)
68{
69 unsigned char sha1[20];
70 const char *longref;
71
72 longref = fmt("refs/heads/%s", ref);
73 if (get_sha1(longref, sha1) == 0)
74 return longref;
75
76 return ref;
77}
67 78
68void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, 79void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern,
69 char *path, int pager) 80 char *path, int pager)
70{ 81{
71 struct rev_info rev; 82 struct rev_info rev;
72 struct commit *commit; 83 struct commit *commit;
73 const char *argv[] = {NULL, tip, NULL, NULL, NULL}; 84 const char *argv[] = {NULL, NULL, NULL, NULL, NULL};
74 int argc = 2; 85 int argc = 2;
75 int i, columns = 3; 86 int i, columns = 3;
76 87
77 if (!tip) 88 if (!tip)
78 argv[1] = ctx.qry.head; 89 tip = ctx.qry.head;
90
91 argv[1] = disambiguate_ref(tip);
79 92
80 if (grep && pattern && (!strcmp(grep, "grep") || 93 if (grep && pattern && (!strcmp(grep, "grep") ||
81 !strcmp(grep, "author") || 94 !strcmp(grep, "author") ||