stagit

lookup commits of annotated tags

NOTE: as described in the TODO this will be rewritten more cleanly
      later using git_reference_*.

Hiltjo Posthuma contact@arjunchoudhary.com

commit: 6019456 parent: 43d1b46
1 files changed, 16 insertions(+), 0 deletions(-)
Mstagit.c+16-0
M · stagit.c +16, -0
 1@@ -875,6 +875,7 @@ writetags(FILE *fp)
 2 	struct commitinfo *ci;
 3 	git_strarray tagnames;
 4 	git_object *obj = NULL;
 5+	git_tag *tag = NULL;
 6 	const git_oid *id = NULL;
 7 	size_t i, len;
 8 
 9@@ -900,6 +901,18 @@ writetags(FILE *fp)
10 		if (git_revparse_single(&obj, repo, tagnames.strings[i]))
11 			continue;
12 		id = git_object_id(obj);
13+
14+		/* lookup actual commit (from annotated tag etc) */
15+		if (!git_tag_lookup(&tag, repo, id)) {
16+			git_object_free(obj);
17+			obj = NULL;
18+			if (git_tag_peel(&obj, tag))
19+				break;
20+			git_tag_free(tag);
21+			tag = NULL;
22+			id = git_object_id(obj);
23+		}
24+
25 		if (!(ci = commitinfo_getbyoid(id)))
26 			break;
27 
28@@ -936,9 +949,12 @@ writetags(FILE *fp)
29 
30 		commitinfo_free(ci);
31 		git_object_free(obj);
32+		obj = NULL;
33 	}
34 	fputs("</tbody></table>", fp);
35 	git_strarray_free(&tagnames);
36+	git_tag_free(tag);
37+	git_object_free(obj);
38 
39 	return 0;
40 }