summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore 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
@@ -43,60 +43,73 @@ void print_commit(struct commit *commit)
43 html_link_open(tmp, NULL, NULL); 43 html_link_open(tmp, NULL, NULL);
44 cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); 44 cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE);
45 html_link_close(); 45 html_link_close();
46 html("</td><td>"); 46 html("</td><td>");
47 cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, 47 cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head,
48 sha1_to_hex(commit->object.sha1)); 48 sha1_to_hex(commit->object.sha1));
49 html("</td><td>"); 49 html("</td><td>");
50 html_txt(info->author); 50 html_txt(info->author);
51 if (ctx.repo->enable_log_filecount) { 51 if (ctx.repo->enable_log_filecount) {
52 files = 0; 52 files = 0;
53 add_lines = 0; 53 add_lines = 0;
54 rem_lines = 0; 54 rem_lines = 0;
55 cgit_diff_commit(commit, inspect_files); 55 cgit_diff_commit(commit, inspect_files);
56 html("</td><td>"); 56 html("</td><td>");
57 htmlf("%d", files); 57 htmlf("%d", files);
58 if (ctx.repo->enable_log_linecount) { 58 if (ctx.repo->enable_log_linecount) {
59 html("</td><td>"); 59 html("</td><td>");
60 htmlf("-%d/+%d", rem_lines, add_lines); 60 htmlf("-%d/+%d", rem_lines, add_lines);
61 } 61 }
62 } 62 }
63 html("</td></tr>\n"); 63 html("</td></tr>\n");
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") ||
82 !strcmp(grep, "committer"))) 95 !strcmp(grep, "committer")))
83 argv[argc++] = fmt("--%s=%s", grep, pattern); 96 argv[argc++] = fmt("--%s=%s", grep, pattern);
84 97
85 if (path) { 98 if (path) {
86 argv[argc++] = "--"; 99 argv[argc++] = "--";
87 argv[argc++] = path; 100 argv[argc++] = path;
88 } 101 }
89 init_revisions(&rev, NULL); 102 init_revisions(&rev, NULL);
90 rev.abbrev = DEFAULT_ABBREV; 103 rev.abbrev = DEFAULT_ABBREV;
91 rev.commit_format = CMIT_FMT_DEFAULT; 104 rev.commit_format = CMIT_FMT_DEFAULT;
92 rev.verbose_header = 1; 105 rev.verbose_header = 1;
93 rev.show_root_diff = 0; 106 rev.show_root_diff = 0;
94 setup_revisions(argc, argv, &rev, NULL); 107 setup_revisions(argc, argv, &rev, NULL);
95 rev.grep_filter.regflags |= REG_ICASE; 108 rev.grep_filter.regflags |= REG_ICASE;
96 compile_grep_patterns(&rev.grep_filter); 109 compile_grep_patterns(&rev.grep_filter);
97 prepare_revision_walk(&rev); 110 prepare_revision_walk(&rev);
98 111
99 if (pager) 112 if (pager)
100 html("<table class='list nowrap'>"); 113 html("<table class='list nowrap'>");
101 114
102 html("<tr class='nohover'><th class='left'>Age</th>" 115 html("<tr class='nohover'><th class='left'>Age</th>"