Code

Merge branch 'sp/describe-tag'
[git.git] / builtin-describe.c
index 08d18507ac99a6c852f04d5b069857347dc5c0b8..2f1e7ba150098dfa85c8ffe009b318c22bedcbbd 100644 (file)
@@ -17,6 +17,7 @@ static const char * const describe_usage[] = {
 static int debug;      /* Display lots of verbose info */
 static int all;        /* Default to annotated tags only */
 static int tags;       /* But allow any tags if --tags is specified */
+static int longformat;
 static int abbrev = DEFAULT_ABBREV;
 static int max_candidates = 10;
 const char *pattern = NULL;
@@ -165,6 +166,9 @@ static void display_name(struct commit_name *n)
                printf("%s", n->tag->tag);
        else
                printf("%s", n->path);
+       if (longformat)
+               printf("-0-g%s",
+                      find_unique_abbrev(n->tag->tagged->sha1, abbrev));
 }
 
 static void describe(const char *arg, int last_one)
@@ -293,6 +297,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
                OPT_BOOLEAN(0, "debug",      &debug, "debug search strategy on stderr"),
                OPT_BOOLEAN(0, "all",        &all, "use any ref in .git/refs"),
                OPT_BOOLEAN(0, "tags",       &tags, "use any tag in .git/refs/tags"),
+               OPT_BOOLEAN(0, "long",       &longformat, "always use long format"),
                OPT__ABBREV(&abbrev),
                OPT_SET_INT(0, "exact-match", &max_candidates,
                            "only output exact matches", 0),
@@ -311,6 +316,9 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
 
        save_commit_buffer = 0;
 
+       if (longformat && abbrev == 0)
+               die("--long is incompatible with --abbrev=0");
+
        if (contains) {
                const char **args = xmalloc((6 + argc) * sizeof(char*));
                int i = 0;