Skip to content

Commit 7e425c4

Browse files
spearcegitster
authored andcommitted
describe: Make --tags and --all match lightweight tags more often
If the caller supplies --tags they want the lightweight, unannotated tags to be searched for a match. If a lightweight tag is closer in the history, it should be matched, even if an annotated tag is reachable further back in the commit chain. The same applies with --all when matching any other type of ref. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Acked-By: Uwe Kleine-König <ukleinek@strlen.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 5c283eb commit 7e425c4

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

Documentation/git-describe.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ shown. Otherwise, it suffixes the tag name with the number of
1818
additional commits on top of the tagged object and the
1919
abbreviated object name of the most recent commit.
2020

21+
By default (without --all or --tags) `git describe` only shows
22+
annotated tags. For more information about creating annotated tags
23+
see the -a and -s options to linkgit:git-tag[1].
2124

2225
OPTIONS
2326
-------
@@ -26,11 +29,13 @@ OPTIONS
2629

2730
--all::
2831
Instead of using only the annotated tags, use any ref
29-
found in `.git/refs/`.
32+
found in `.git/refs/`. This option enables matching
33+
any known branch, remote branch, or lightweight tag.
3034

3135
--tags::
3236
Instead of using only the annotated tags, use any tag
33-
found in `.git/refs/tags`.
37+
found in `.git/refs/tags`. This option enables matching
38+
a lightweight (non-annotated) tag.
3439

3540
--contains::
3641
Instead of finding the tag that predates the commit, find

builtin-describe.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ static const char * const describe_usage[] = {
1515
};
1616

1717
static int debug; /* Display lots of verbose info */
18-
static int all; /* Default to annotated tags only */
19-
static int tags; /* But allow any tags if --tags is specified */
18+
static int all; /* Any valid ref can be used */
19+
static int tags; /* Allow lightweight tags */
2020
static int longformat;
2121
static int abbrev = DEFAULT_ABBREV;
2222
static int max_candidates = 10;
@@ -112,8 +112,6 @@ static int compare_pt(const void *a_, const void *b_)
112112
{
113113
struct possible_tag *a = (struct possible_tag *)a_;
114114
struct possible_tag *b = (struct possible_tag *)b_;
115-
if (a->name->prio != b->name->prio)
116-
return b->name->prio - a->name->prio;
117115
if (a->depth != b->depth)
118116
return a->depth - b->depth;
119117
if (a->found_order != b->found_order)

t/t6120-describe.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ check_describe D-* HEAD^^
9191
check_describe A-* HEAD^^2
9292
check_describe B HEAD^^2^
9393

94-
check_describe A-* --tags HEAD
95-
check_describe A-* --tags HEAD^
96-
check_describe D-* --tags HEAD^^
97-
check_describe A-* --tags HEAD^^2
94+
check_describe c-* --tags HEAD
95+
check_describe c-* --tags HEAD^
96+
check_describe e-* --tags HEAD^^
97+
check_describe c-* --tags HEAD^^2
9898
check_describe B --tags HEAD^^2^
9999

100100
check_describe B-0-* --long HEAD^^2^

0 commit comments

Comments
 (0)