commit a436ad14b580220cf835e8386b241b42903a0339 from: Stefan Sperling date: Tue Aug 13 08:41:25 2019 UTC make 'got log' display tags in addition to branch references commit - 52b5abe1665698ac9f94f7f2d95482d27e131c16 commit + a436ad14b580220cf835e8386b241b42903a0339 blob - a322f32e174306295c8b5682c8a19d3280485378 blob + 4fa694575494ec8f59dee0522b64488d33737df5 --- got/got.c +++ got/got.c @@ -1386,8 +1386,9 @@ print_commit(struct got_commit_object *commit, struct SIMPLEQ_FOREACH(re, refs, entry) { char *s; const char *name; - if (got_object_id_cmp(re->id, id) != 0) - continue; + struct got_tag_object *tag = NULL; + int cmp; + name = got_ref_get_name(re->ref); if (strcmp(name, GOT_REF_HEAD) == 0) continue; @@ -1399,6 +1400,17 @@ print_commit(struct got_commit_object *commit, struct name += 6; if (strncmp(name, "remotes/", 8) == 0) name += 8; + if (strncmp(name, "tags/", 5) == 0) { + err = got_object_open_as_tag(&tag, repo, re->id); + if (err) + break; + } + cmp = got_object_id_cmp(tag ? + got_object_tag_get_object_id(tag) : re->id, id); + if (tag) + got_object_tag_close(tag); + if (cmp != 0) + continue; s = refs_str; if (asprintf(&refs_str, "%s%s%s", s ? s : "", s ? ", " : "", name) == -1) { blob - fa21749675c7093587f9e3be79dea42b3d341fe4 blob + 9b8b3d3b4ca6b8a9fc2e2edc10f2165f8b745964 --- regress/cmdline/log.sh +++ regress/cmdline/log.sh @@ -124,7 +124,7 @@ function test_log_tag { (cd $testroot/repo && git tag -a -m "test" $tag) - echo "commit $commit_id (master)" > $testroot/stdout.expected + echo "commit $commit_id (master, tags/$tag)" > $testroot/stdout.expected (cd $testroot/wt && got log -l1 -c $tag | grep ^commit \ > $testroot/stdout) cmp -s $testroot/stdout.expected $testroot/stdout