Skip to content

Commit

Permalink
tag.c: use 'ref-filter' APIs
Browse files Browse the repository at this point in the history
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 <christian.couder@gmail.com>
Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Karthik Nayak authored and Junio C Hamano committed Sep 17, 2015
1 parent ac4cc86 commit b7cc53e
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 316 deletions.
16 changes: 9 additions & 7 deletions Documentation/git-tag.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SYNOPSIS
<tagname> [<commit> | <object>]
'git tag' -d <tagname>...
'git tag' [-n[<num>]] -l [--contains <commit>] [--points-at <object>]
[--column[=<options>] | --no-column] [--create-reflog] [<pattern>...]
[--column[=<options>] | --no-column] [--create-reflog] [--sort=<key>] [<pattern>...]
'git tag' -v <tagname>...

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

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

Expand Down
Loading

0 comments on commit b7cc53e

Please sign in to comment.