Skip to content

Commit b7cc53e

Browse files
KarthikNayakgitster
authored andcommitted
tag.c: use 'ref-filter' APIs
Make 'tag.c' use 'ref-filter' APIs for iterating through refs, sorting and printing of refs. This removes most of the code used in 'tag.c' replacing it with calls to the 'ref-filter' library. Make 'tag.c' use the 'filter_refs()' function provided by 'ref-filter' to filter out tags based on the options set. For printing tags we use 'show_ref_array_item()' function provided by 'ref-filter'. We improve the sorting option provided by 'tag.c' by using the sorting options provided by 'ref-filter'. This causes the test 'invalid sort parameter on command line' in t7004 to fail, as 'ref-filter' throws an error for all sorting fields which are incorrect. The test is changed to reflect the same. Modify documentation for the same. Mentored-by: Christian Couder <[email protected]> Mentored-by: Matthieu Moy <[email protected]> Signed-off-by: Karthik Nayak <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ac4cc86 commit b7cc53e

File tree

3 files changed

+53
-316
lines changed

3 files changed

+53
-316
lines changed

Documentation/git-tag.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ SYNOPSIS
1313
<tagname> [<commit> | <object>]
1414
'git tag' -d <tagname>...
1515
'git tag' [-n[<num>]] -l [--contains <commit>] [--points-at <object>]
16-
[--column[=<options>] | --no-column] [--create-reflog] [<pattern>...]
16+
[--column[=<options>] | --no-column] [--create-reflog] [--sort=<key>] [<pattern>...]
1717
'git tag' -v <tagname>...
1818

1919
DESCRIPTION
@@ -94,14 +94,16 @@ OPTIONS
9494
using fnmatch(3)). Multiple patterns may be given; if any of
9595
them matches, the tag is shown.
9696

97-
--sort=<type>::
98-
Sort in a specific order. Supported type is "refname"
99-
(lexicographic order), "version:refname" or "v:refname" (tag
97+
--sort=<key>::
98+
Sort based on the key given. Prefix `-` to sort in
99+
descending order of the value. You may use the --sort=<key> option
100+
multiple times, in which case the last key becomes the primary
101+
key. Also supports "version:refname" or "v:refname" (tag
100102
names are treated as versions). The "version:refname" sort
101103
order can also be affected by the
102-
"versionsort.prereleaseSuffix" configuration variable. Prepend
103-
"-" to reverse sort order. When this option is not given, the
104-
sort order defaults to the value configured for the 'tag.sort'
104+
"versionsort.prereleaseSuffix" configuration variable.
105+
The keys supported are the same as those in `git for-each-ref`.
106+
Sort order defaults to the value configured for the 'tag.sort'
105107
variable if it exists, or lexicographic order otherwise. See
106108
linkgit:git-config[1].
107109

0 commit comments

Comments
 (0)