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>
Shawn O. Pearce committed
Oct 13, 2008 at 07:39 UTC
7e425c4fbbe9affffa822f154d8bb2d0da6699ef
3 files changed
+13
-10
Documentation/git-describe.txt
+7
-2
@@ -18,6 +18,9 @@ shown. Otherwise, it suffixes the tag name with the number of
18
additional commits on top of the tagged object and the
19
abbreviated object name of the most recent commit.
20
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].
24
25
OPTIONS
26
-------
@@ -26,11 +29,13 @@ OPTIONS
29
30
--all::
31
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.
34
35
--tags::
36
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.
39
40
--contains::
41
Instead of finding the tag that predates the commit, find
builtin-describe.c
+2
-4
@@ -15,8 +15,8 @@ static const char * const describe_usage[] = {
15
};
16
17
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 */
20
static int longformat;
21
static int abbrev = DEFAULT_ABBREV;
22
static int max_candidates = 10;
@@ -112,8 +112,6 @@ static int compare_pt(const void *a_, const void *b_)
112
{
113
struct possible_tag *a = (struct possible_tag *)a_;
114
struct possible_tag *b = (struct possible_tag *)b_;
115
- if (a->name->prio != b->name->prio)
116
- return b->name->prio - a->name->prio;
115
if (a->depth != b->depth)
116
return a->depth - b->depth;
117
if (a->found_order != b->found_order)
t/t6120-describe.sh
+4
-4
@@ -91,10 +91,10 @@ check_describe D-* HEAD^^
91
check_describe A-* HEAD^^2
92
check_describe B HEAD^^2^
93
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
98
check_describe B --tags HEAD^^2^
99
100
check_describe B-0-* --long HEAD^^2^