summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Hjemli <hjemli@gmail.com>2008-12-03 17:34:23 +0100
committerLars Hjemli <hjemli@gmail.com>2008-12-03 17:34:23 +0100
commita1b01b2513510f8f93f7f8ca39969002cd496a19 (patch)
tree143e569416a89b31de6f96e8e79f8841c24dd935
parentc7d1402b177f4cf835e81f962e2faa3c9e28c549 (diff)
downloadcgit-a1b01b2513510f8f93f7f8ca39969002cd496a19.tar.gz
cgit-a1b01b2513510f8f93f7f8ca39969002cd496a19.tar.bz2
cgit-a1b01b2513510f8f93f7f8ca39969002cd496a19.zip
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 '')
-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)
cgit_free_commitinfo(info);
}
+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;
+}
void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern,
char *path, int pager)
{
struct rev_info rev;
struct commit *commit;
- const char *argv[] = {NULL, tip, NULL, NULL, NULL};
+ const char *argv[] = {NULL, NULL, NULL, NULL, NULL};
int argc = 2;
int i, columns = 3;
if (!tip)
- argv[1] = ctx.qry.head;
+ tip = ctx.qry.head;
+
+ argv[1] = disambiguate_ref(tip);
if (grep && pattern && (!strcmp(grep, "grep") ||
!strcmp(grep, "author") ||
ache-root option to /cgit/rcLars Hjemli1-0/+2 2006-12-16Add argument parsing + switch for uncached operationLars Hjemli3-3/+51 2006-12-16Add head comment to shared.cLars Hjemli1-0/+8 2006-12-16Add head comment to ui-commit.cLars Hjemli1-0/+8 2006-12-16gitweb ripoff: set tr:hover to highligt current rowLars Hjemli1-3/+7 2006-12-16Make repo header a link to summary pageLars Hjemli2-1/+12 2006-12-16Move cgit_print_date into ui-shared, reuse in ui-summaryLars Hjemli4-20/+24 2006-12-16Add ui-commit.c + misc ui cleanupsLars Hjemli9-19/+140 2006-12-15Add a common commit parserLars Hjemli3-63/+75 2006-12-14Add simple pager to log pageLars Hjemli4-6/+37 2006-12-13Add separate makefile-rule to clear current cacheLars Hjemli1-2/+4 2006-12-13Remove implementation details from READMELars Hjemli1-53/+34 2006-12-13Small layout adjustments to summary and blob viewLars Hjemli3-5/+13 2006-12-13Add display of tree content w/ui-tree.cLars Hjemli9-8/+113 2006-12-12cache_lock: do xstrdup/free on lockfileLars Hjemli1-1/+2 2006-12-11Don't truncate valid cachefilesLars Hjemli3-4/+16 2006-12-11Move global variables + callback functions into shared.cLars Hjemli4-82/+86 2006-12-11Move functions for generic object output into ui-view.cLars Hjemli4-34/+43 2006-12-11Move log-functions into ui-log.cLars Hjemli5-111/+121 2006-12-11Move repo summary functions into ui-summary.cLars Hjemli4-47/+59 2006-12-11Move functions for repolist output into ui-repolist.cLars Hjemli5-70/+90 2006-12-11Move common output-functions into ui-shared.cLars Hjemli4-82/+99 2006-12-11Rename config.c to parsing.c + move cgit_parse_query from cgit.c to parsing.cLars Hjemli4-28/+29 2006-12-11Avoid infinite loops in caching layerLars Hjemli3-14/+31 2006-12-11Let 'make install' clear all cachefilesLars Hjemli1-0/+2 2006-12-11Fix cache algorithm loopholeLars Hjemli3-11/+16 2006-12-10Add version identifier in generated filesLars Hjemli2-9/+14 2006-12-10Add license file and copyright noticesLars Hjemli5-0/+372 2006-12-10Add caching infrastructureLars Hjemli9-28/+353