stagit

refs: dont make a table when there are no tags, add spacing between

Hiltjo Posthuma contact@arjunchoudhary.com

commit: 38fc501 parent: c609a66
1 files changed, 14 insertions(+), 6 deletions(-)
Mstagit.c+14-6
M · stagit.c +14, -6
 1@@ -881,17 +881,24 @@ writetags(FILE *fp)
 2 	const git_oid *id = NULL;
 3 	size_t i, len;
 4 
 5-	fputs("<h2>Tags</h2><table id=\"branches\"><thead>\n<tr><td>Tag</td>"
 6-	      "<td>Age</td><td>Commit message</td>"
 7-	      "<td>Author</td><td>Files</td><td class=\"num\">+</td>"
 8-	      "<td class=\"num\">-</td></tr>\n</thead><tbody>\n", fp);
 9-
10 	/* summary page with branches and tags */
11 	memset(&tagnames, 0, sizeof(tagnames));
12-	git_tag_list(&tagnames, repo);
13+	if (git_tag_list(&tagnames, repo))
14+		return -1;
15+	if (!tagnames.count) {
16+		git_strarray_free(&tagnames);
17+		return 0;
18+	}
19+
20 	/* sort names */
21 	qsort(tagnames.strings, tagnames.count, sizeof(char *),
22 	      (int (*)(const void *, const void *))&tagcompare);
23+
24+	fputs("<h2>Tags</h2><table id=\"branches\"><thead>\n<tr><td>Tag</td>"
25+	      "<td>Age</td><td>Commit message</td>"
26+	      "<td>Author</td><td>Files</td><td class=\"num\">+</td>"
27+	      "<td class=\"num\">-</td></tr>\n</thead><tbody>\n", fp);
28+
29 	for (i = 0; i < tagnames.count; i++) {
30 		if (git_revparse_single(&obj, repo, tagnames.strings[i]))
31 			continue;
32@@ -946,6 +953,7 @@ writerefs(FILE *fp)
33 
34 	if ((ret = writebranches(fp)))
35 		return ret;
36+	fputs("<br/>", fp);
37 	return writetags(fp);
38 }
39