summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2007-10-28 14:36:18 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-10-28 14:38:19 (UTC)
commitcbcdbcf2bff23113fe81df8f11fe7843b8ed637e (patch) (side-by-side diff)
tree1c434e9005aa946daa8f7aa49a9c9f3656349068
parent68ca032dbe7379f78775fb03ef34a9ad2abc409f (diff)
downloadcgit-cbcdbcf2bff23113fe81df8f11fe7843b8ed637e.zip
cgit-cbcdbcf2bff23113fe81df8f11fe7843b8ed637e.tar.gz
cgit-cbcdbcf2bff23113fe81df8f11fe7843b8ed637e.tar.bz2
Make print_branch() handle refs not pointing at commits
The master branch of stable/linux-2.6.20 currently references a tag object, which makes print_branch() die with a segfault. This teaches print_branch() to handle such cases more gracefully. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ui-summary.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/ui-summary.c b/ui-summary.c
index 04a466a..ba90510 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -37,53 +37,59 @@ static int cmp_branch_age(const void *a, const void *b)
struct refinfo *r1 = *(struct refinfo **)a;
struct refinfo *r2 = *(struct refinfo **)b;
return cmp_age(r1->commit->committer_date, r2->commit->committer_date);
}
static int cmp_tag_age(const void *a, const void *b)
{
struct refinfo *r1 = *(struct refinfo **)a;
struct refinfo *r2 = *(struct refinfo **)b;
return cmp_age(r1->tag->tagger_date, r2->tag->tagger_date);
}
static int print_branch(struct refinfo *ref)
{
struct commitinfo *info = ref->commit;
char *name = (char *)ref->refname;
if (!info)
return 1;
html("<tr><td>");
cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0);
html("</td><td>");
- cgit_print_age(info->commit->date, -1, NULL);
- html("</td><td>");
- html_txt(info->author);
- html("</td><td>");
- cgit_commit_link(info->subject, NULL, NULL, name, NULL);
+
+ if (ref->object->type == OBJ_COMMIT) {
+ cgit_print_age(info->commit->date, -1, NULL);
+ html("</td><td>");
+ html_txt(info->author);
+ html("</td><td>");
+ cgit_commit_link(info->subject, NULL, NULL, name, NULL);
+ } else {
+ html("</td><td></td><td>");
+ cgit_object_link(ref->object);
+ }
html("</td></tr>\n");
return 0;
}
static void print_tag_header()
{
html("<tr class='nohover'><th class='left'>Tag</th>"
"<th class='left'>Age</th>"
"<th class='left'>Author</th>"
"<th class='left'>Reference</th></tr>\n");
header = 1;
}
static int print_tag(struct refinfo *ref)
{
struct tag *tag;
struct taginfo *info;
char *url, *name = (char *)ref->refname;
if (ref->object->type == OBJ_TAG) {
tag = (struct tag *)ref->object;
info = ref->tag;
if (!tag || !info)
return 1;