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>
#include "cache.h"
#include "commit.h"
#include "cache.h"
#include "commit.h"
#include "refs.h"
#define SEEN (1u << 0)
static const char describe_usage[] = "git-describe [--all] <committish>*";
#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 {
static int names = 0, allocs = 0;
static struct commit_name {
struct commit *commit = lookup_commit_reference_gently(sha1, 1);
if (!commit)
return 0;
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);