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,128 +1,124 @@ | |||
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"; |
65 | arg = "id"; | 61 | arg = "id"; |
66 | } else { | 62 | } else { |
67 | page = "view"; | 63 | page = "view"; |
68 | arg = "id"; | 64 | arg = "id"; |
69 | } | 65 | } |
70 | 66 | ||
71 | url = cgit_pageurl(cgit_query_repo, page, | 67 | url = cgit_pageurl(cgit_query_repo, page, |
72 | fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); | 68 | fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); |
73 | html_link_open(url, NULL, NULL); | 69 | html_link_open(url, NULL, NULL); |
74 | htmlf("%s %s", typename(obj->type), | 70 | htmlf("%s %s", typename(obj->type), |
75 | sha1_to_hex(obj->sha1)); | 71 | sha1_to_hex(obj->sha1)); |
76 | html_link_close(); | 72 | html_link_close(); |
77 | } | 73 | } |
78 | 74 | ||
79 | static void print_tag_header() | 75 | static void print_tag_header() |
80 | { | 76 | { |
81 | html("<tr class='nohover'><th class='left'>Tag</th>" | 77 | html("<tr class='nohover'><th class='left'>Tag</th>" |
82 | "<th class='left'>Age</th>" | 78 | "<th class='left'>Age</th>" |
83 | "<th class='left'>Author</th>" | 79 | "<th class='left'>Author</th>" |
84 | "<th class='left'>Reference</th></tr>\n"); | 80 | "<th class='left'>Reference</th></tr>\n"); |
85 | header = 1; | 81 | header = 1; |
86 | } | 82 | } |
87 | 83 | ||
88 | static int cgit_print_tag_cb(const char *refname, const unsigned char *sha1, | 84 | static int cgit_print_tag_cb(const char *refname, const unsigned char *sha1, |
89 | int flags, void *cb_data) | 85 | int flags, void *cb_data) |
90 | { | 86 | { |
91 | struct tag *tag; | 87 | struct tag *tag; |
92 | struct taginfo *info; | 88 | struct taginfo *info; |
93 | struct object *obj; | 89 | struct object *obj; |
94 | char buf[256], *url; | 90 | char buf[256], *url; |
95 | 91 | ||
96 | strncpy(buf, refname, sizeof(buf)); | 92 | strncpy(buf, refname, sizeof(buf)); |
97 | obj = parse_object(sha1); | 93 | obj = parse_object(sha1); |
98 | if (!obj) | 94 | if (!obj) |
99 | return 1; | 95 | return 1; |
100 | if (obj->type == OBJ_TAG) { | 96 | if (obj->type == OBJ_TAG) { |
101 | tag = lookup_tag(sha1); | 97 | tag = lookup_tag(sha1); |
102 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) | 98 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) |
103 | return 2; | 99 | return 2; |
104 | if (!header) | 100 | if (!header) |
105 | print_tag_header(); | 101 | print_tag_header(); |
106 | html("<tr><td>"); | 102 | html("<tr><td>"); |
107 | url = cgit_pageurl(cgit_query_repo, "view", | 103 | url = cgit_pageurl(cgit_query_repo, "view", |
108 | fmt("id=%s", sha1_to_hex(sha1))); | 104 | fmt("id=%s", sha1_to_hex(sha1))); |
109 | html_link_open(url, NULL, NULL); | 105 | html_link_open(url, NULL, NULL); |
110 | html_txt(buf); | 106 | html_txt(buf); |
111 | html_link_close(); | 107 | html_link_close(); |
112 | html("</td><td>"); | 108 | html("</td><td>"); |
113 | if (info->tagger_date > 0) | 109 | if (info->tagger_date > 0) |
114 | cgit_print_age(info->tagger_date, -1, NULL); | 110 | cgit_print_age(info->tagger_date, -1, NULL); |
115 | html("</td><td>"); | 111 | html("</td><td>"); |
116 | if (info->tagger) | 112 | if (info->tagger) |
117 | html(info->tagger); | 113 | html(info->tagger); |
118 | html("</td><td>"); | 114 | html("</td><td>"); |
119 | cgit_print_object_ref(tag->tagged); | 115 | cgit_print_object_ref(tag->tagged); |
120 | html("</td></tr>\n"); | 116 | html("</td></tr>\n"); |
121 | } else { | 117 | } else { |
122 | if (!header) | 118 | if (!header) |
123 | print_tag_header(); | 119 | print_tag_header(); |
124 | html("<tr><td>"); | 120 | html("<tr><td>"); |
125 | html_txt(buf); | 121 | html_txt(buf); |
126 | html("</td><td colspan='2'/><td>"); | 122 | html("</td><td colspan='2'/><td>"); |
127 | cgit_print_object_ref(obj); | 123 | cgit_print_object_ref(obj); |
128 | html("</td></tr>\n"); | 124 | html("</td></tr>\n"); |