Re: [PATCH v3 8/9] tag.c: implement '--format' option
From: Matthieu Moy <hidden>
Date: 2016-06-15 23:05:51
Karthik Nayak [off-list ref] writes:
quoted hunk
--- a/Documentation/git-tag.txt +++ b/Documentation/git-tag.txt@@ -13,7 +13,8 @@ SYNOPSIS <tagname> [<commit> | <object>] 'git tag' -d <tagname>... 'git tag' [-n[<num>]] -l [--contains <commit>] [--points-at <object>] - [--column[=<options>] | --no-column] [--sort=<key>] [<pattern>...] + [--column[=<options>] | --no-column] [--sort=<key>] [--format=<format>] + [<pattern>...] 'git tag' -v <tagname>... DESCRIPTION@@ -155,6 +156,19 @@ This option is only applicable when listing tags without annotation lines. The object that the new tag will refer to, usually a commit. Defaults to HEAD. +<format>:: + A string that interpolates `%(fieldname)` from the + object pointed at by a ref being shown. If `fieldname` + is prefixed with an asterisk (`*`) and the ref points + at a tag object, the value for the field in the object + tag refers is used. When unspecified, defaults to + `%(objectname) SPC %(objecttype) TAB %(refname)`.
I think this last sentence is taken from for-each-ref where it is true, but for 'git tag', the default is just %(refname:short), as written here:
- else + else if (!format) format = "%(refname:short)";
right?
quoted hunk
--- a/t/t7004-tag.sh +++ b/t/t7004-tag.sh@@ -1507,4 +1507,20 @@ EOF" test_cmp expect actual ' +test_expect_success '--format cannot be used with -n' ' + test_must_fail git tag -l -n4 --format="%(refname)" +' + +test_expect_success '--format should list tags as per format given' ' + cat >expect <<-\EOF && + foo1.10 + foo1.3 + foo1.6 + foo1.6-rc1 + foo1.6-rc2 + EOF + git tag -l --format="%(refname)" "foo*" >actual && + test_cmp expect actual +'
This tests the pattern argument, but the the test still passes if I remove the --format option, so it does not test what it claims. Also, why does "git tag"'s %(refname) behave like "git for-each-ref"'s %(refname:short)? I find it very confusing as I think --format's argument should be interpreted the same way for all ref-listing commands. Actually I didn't find a way to have "git tag" display the full refname other than with --format "refs/tags/%(refname)". -- Matthieu Moy http://www-verimag.imag.fr/~moy/