summaryrefslogtreecommitdiff
path: root/builtin-describe.c
diff options
context:
space:
mode:
authorSanti Béjar <sbejar@gmail.com>2008-02-25 10:43:33 +0100
committerJunio C Hamano <gitster@pobox.com>2008-02-25 18:59:20 -0800
commit518120e3487a00148f8001454f1e76e484442a22 (patch)
tree1af7db66d8c13f49b46a87cb4205a8777729c166 /builtin-describe.c
parent99d8ea2c5ce6fc0b06fe8a43e7c0c108ddad853b (diff)
downloadgit-518120e3487a00148f8001454f1e76e484442a22.tar.gz
git-describe: --long shows the object name even for a tagged commit
This is useful when you want to see parts of the commit object name in "describe" output, even when the commit in question happens to be a tagged version. Instead of just emitting the tag name, it will describe such a commit as v1.2-0-deadbeef (0th commit since tag v1.2 that points at object deadbeef....). Signed-off-by: Santi Béjar <sbejar@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-describe.c')
-rw-r--r--builtin-describe.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/builtin-describe.c b/builtin-describe.c
index 3428483134..3fd2e7371f 100644
--- a/builtin-describe.c
+++ b/builtin-describe.c
@@ -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;
@@ -155,7 +156,11 @@ static void describe(const char *arg, int last_one)
n = cmit->util;
if (n) {
- printf("%s\n", n->path);
+ if (!longformat)
+ printf("%s\n", n->path);
+ else
+ printf("%s-0-g%s\n", n->path,
+ find_unique_abbrev(cmit->object.sha1, abbrev));
return;
}
@@ -254,6 +259,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_INTEGER(0, "candidates", &max_candidates,
"consider <n> most recent tags (default: 10)"),
@@ -270,6 +276,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;