author | Lars Hjemli <hjemli@gmail.com> | 2007-06-17 11:57:51 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-06-17 11:57:51 (UTC) |
commit | 48c487d72daef7e71683a85f775db8d36ab20341 (patch) (unidiff) | |
tree | 8770334d7c77bd3e81f42ee12550e6db5febd4d2 /ui-summary.c | |
parent | 426032f767763b46f462de51d1ebded34f671d79 (diff) | |
download | cgit-48c487d72daef7e71683a85f775db8d36ab20341.zip cgit-48c487d72daef7e71683a85f775db8d36ab20341.tar.gz cgit-48c487d72daef7e71683a85f775db8d36ab20341.tar.bz2 |
Add git_log_link() and fix bug in generic repolink function
The generic repolink function compared head with cgit_query_head, which
almost always would be the same pointer. The test now compares with
repo.defbranch, which is the wanted behavour.
Bug discovered while adding cgit_log_link(), so this commit also contain
that change.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-summary.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/ui-summary.c b/ui-summary.c index 4bda4c2..29b76e3 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -1,64 +1,60 @@ | |||
1 | /* ui-summary.c: functions for generating repo summary page | 1 | /* ui-summary.c: functions for generating repo summary page |
2 | * | 2 | * |
3 | * Copyright (C) 2006 Lars Hjemli | 3 | * Copyright (C) 2006 Lars Hjemli |
4 | * | 4 | * |
5 | * Licensed under GNU General Public License v2 | 5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) | 6 | * (see COPYING for full license text) |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "cgit.h" | 9 | #include "cgit.h" |
10 | 10 | ||
11 | static int header; | 11 | static int header; |
12 | 12 | ||
13 | static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, | 13 | static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, |
14 | int flags, void *cb_data) | 14 | int flags, void *cb_data) |
15 | { | 15 | { |
16 | struct commit *commit; | 16 | struct commit *commit; |
17 | struct commitinfo *info; | 17 | struct commitinfo *info; |
18 | char buf[256], *url; | 18 | char buf[256], *url; |
19 | 19 | ||
20 | strncpy(buf, refname, sizeof(buf)); | 20 | strncpy(buf, refname, sizeof(buf)); |
21 | commit = lookup_commit(sha1); | 21 | commit = lookup_commit(sha1); |
22 | // object is not really parsed at this point, because of some fallout | 22 | // object is not really parsed at this point, because of some fallout |
23 | // from previous calls to git functions in cgit_print_log() | 23 | // from previous calls to git functions in cgit_print_log() |
24 | commit->object.parsed = 0; | 24 | commit->object.parsed = 0; |
25 | if (commit && !parse_commit(commit)){ | 25 | if (commit && !parse_commit(commit)){ |
26 | info = cgit_parse_commit(commit); | 26 | info = cgit_parse_commit(commit); |
27 | html("<tr><td>"); | 27 | html("<tr><td>"); |
28 | url = cgit_pageurl(cgit_query_repo, "log", | 28 | cgit_log_link(refname, NULL, NULL, refname, NULL, NULL); |
29 | fmt("h=%s", refname)); | ||
30 | html_link_open(url, NULL, NULL); | ||
31 | html_txt(buf); | ||
32 | html_link_close(); | ||
33 | html("</td><td>"); | 29 | html("</td><td>"); |
34 | cgit_print_age(commit->date, -1, NULL); | 30 | cgit_print_age(commit->date, -1, NULL); |
35 | html("</td><td>"); | 31 | html("</td><td>"); |
36 | html_txt(info->author); | 32 | html_txt(info->author); |
37 | html("</td><td>"); | 33 | html("</td><td>"); |
38 | url = cgit_pageurl(cgit_query_repo, "commit", | 34 | url = cgit_pageurl(cgit_query_repo, "commit", |
39 | fmt("h=%s", sha1_to_hex(sha1))); | 35 | fmt("h=%s", sha1_to_hex(sha1))); |
40 | html_link_open(url, NULL, NULL); | 36 | html_link_open(url, NULL, NULL); |
41 | html_ntxt(cgit_max_msg_len, info->subject); | 37 | html_ntxt(cgit_max_msg_len, info->subject); |
42 | html_link_close(); | 38 | html_link_close(); |
43 | html("</td></tr>\n"); | 39 | html("</td></tr>\n"); |
44 | cgit_free_commitinfo(info); | 40 | cgit_free_commitinfo(info); |
45 | } else { | 41 | } else { |
46 | html("<tr><td>"); | 42 | html("<tr><td>"); |
47 | html_txt(buf); | 43 | html_txt(buf); |
48 | html("</td><td colspan='3'>"); | 44 | html("</td><td colspan='3'>"); |
49 | htmlf("*** bad ref %s ***", sha1_to_hex(sha1)); | 45 | htmlf("*** bad ref %s ***", sha1_to_hex(sha1)); |
50 | html("</td></tr>\n"); | 46 | html("</td></tr>\n"); |
51 | } | 47 | } |
52 | return 0; | 48 | return 0; |
53 | } | 49 | } |
54 | 50 | ||
55 | 51 | ||
56 | static void cgit_print_object_ref(struct object *obj) | 52 | static void cgit_print_object_ref(struct object *obj) |
57 | { | 53 | { |
58 | char *page, *arg, *url; | 54 | char *page, *arg, *url; |
59 | 55 | ||
60 | if (obj->type == OBJ_COMMIT) { | 56 | if (obj->type == OBJ_COMMIT) { |
61 | page = "commit"; | 57 | page = "commit"; |
62 | arg = "h"; | 58 | arg = "h"; |
63 | } else if (obj->type == OBJ_TREE) { | 59 | } else if (obj->type == OBJ_TREE) { |
64 | page = "tree"; | 60 | page = "tree"; |