]> git.armaanb.net Git - stagit.git/commitdiff
lookup commits of annotated tags
authorHiltjo Posthuma <hiltjo@codemadness.org>
Wed, 6 Jan 2016 14:35:34 +0000 (15:35 +0100)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Wed, 6 Jan 2016 14:35:34 +0000 (15:35 +0100)
NOTE: as described in the TODO this will be rewritten more cleanly
      later using git_reference_*.

stagit.c

index fc58c0c11e13abee70ac8c3d45e8a6c82ec96929..817fb19cac6dbaafa96012e871850017029544c4 100644 (file)
--- a/stagit.c
+++ b/stagit.c
@@ -875,6 +875,7 @@ writetags(FILE *fp)
        struct commitinfo *ci;
        git_strarray tagnames;
        git_object *obj = NULL;
+       git_tag *tag = NULL;
        const git_oid *id = NULL;
        size_t i, len;
 
@@ -900,6 +901,18 @@ writetags(FILE *fp)
                if (git_revparse_single(&obj, repo, tagnames.strings[i]))
                        continue;
                id = git_object_id(obj);
+
+               /* lookup actual commit (from annotated tag etc) */
+               if (!git_tag_lookup(&tag, repo, id)) {
+                       git_object_free(obj);
+                       obj = NULL;
+                       if (git_tag_peel(&obj, tag))
+                               break;
+                       git_tag_free(tag);
+                       tag = NULL;
+                       id = git_object_id(obj);
+               }
+
                if (!(ci = commitinfo_getbyoid(id)))
                        break;
 
@@ -936,9 +949,12 @@ writetags(FILE *fp)
 
                commitinfo_free(ci);
                git_object_free(obj);
+               obj = NULL;
        }
        fputs("</tbody></table>", fp);
        git_strarray_free(&tagnames);
+       git_tag_free(tag);
+       git_object_free(obj);
 
        return 0;
 }