summaryrefslogtreecommitdiff
path: root/describe.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-12-27 22:36:49 (GMT)
committerJunio C Hamano <junkio@cox.net>2005-12-28 01:57:27 (GMT)
commit635d413430d5419cfd0ac18e2318cf46c1984750 (patch)
tree03c16ffcb95419724c61332964e78bc7e222f249 /describe.c
parent908e5310b958619559d34b0b6da122f058faa47e (diff)
downloadgit-635d413430d5419cfd0ac18e2318cf46c1984750.zip
git-635d413430d5419cfd0ac18e2318cf46c1984750.tar.gz
git-635d413430d5419cfd0ac18e2318cf46c1984750.tar.bz2
git-describe: really prefer tags only.
Often there are references other than annotated tags under refs/tags hierarchy that are used to "keep things just in case". default to use annotated tags only, still leaving the option to use any ref with --all flag. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'describe.c')
-rw-r--r--describe.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/describe.c b/describe.c
index ebfa429..e1b6588 100644
--- a/describe.c
+++ b/describe.c
@@ -1,12 +1,13 @@
#include "cache.h"
#include "commit.h"
+#include "tag.h"
#include "refs.h"
#define SEEN (1u << 0)
static const char describe_usage[] = "git-describe [--all] <committish>*";
-static int all = 0; /* Default to tags only */
+static int all = 0; /* Default to annotated tags only */
static int names = 0, allocs = 0;
static struct commit_name {
@@ -49,9 +50,15 @@ static int get_name(const char *path, const unsigned char *sha1)
struct commit *commit = lookup_commit_reference_gently(sha1, 1);
if (!commit)
return 0;
- if (!all && strncmp(path, "refs/tags/", 10))
- return 0;
- add_to_known_names(path, commit);
+ if (!all) {
+ struct object *object;
+ if (strncmp(path, "refs/tags/", 10))
+ return 0;
+ object = parse_object(sha1);
+ if (object->type != tag_type)
+ return 0;
+ }
+ add_to_known_names(all ? path : path + 10, commit);
return 0;
}