summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: eb3204d)
raw | patch | inline | side by side (parent: eb3204d)
author | Andy Parkins <andyparkins@gmail.com> | |
Fri, 26 Jan 2007 14:28:55 +0000 (14:28 +0000) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sat, 27 Jan 2007 06:38:52 +0000 (22:38 -0800) |
When on a non-tag commit, git-describe normally outputs descriptions of
the form
v1.0.0-g1234567890
Some scripts (for example the update hook script) might just want to
know the name of the nearest tag, so they then have to do
x=$(git-describe HEAD | sed 's/-g*//')
This is costly, but more importantly is fragile as it is relying on the
output format of git-describe, which we would then have to maintain
forever.
This patch adds support for setting the --abbrev option to zero. In
that case git-describe does as it always has, but outputs only the
nearest found tag instead of a completely unique name. This means that
scripts would not have to parse the output format and won't need
changing if the git-describe suffix is ever changed.
Signed-off-by: Andy Parkins <andyparkins@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
the form
v1.0.0-g1234567890
Some scripts (for example the update hook script) might just want to
know the name of the nearest tag, so they then have to do
x=$(git-describe HEAD | sed 's/-g*//')
This is costly, but more importantly is fragile as it is relying on the
output format of git-describe, which we would then have to maintain
forever.
This patch adds support for setting the --abbrev option to zero. In
that case git-describe does as it always has, but outputs only the
nearest found tag instead of a completely unique name. This means that
scripts would not have to parse the output format and won't need
changing if the git-describe suffix is ever changed.
Signed-off-by: Andy Parkins <andyparkins@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-describe.c | patch | blob | history |
diff --git a/builtin-describe.c b/builtin-describe.c
index 4921eee9e2170dd29b546cb2ac3ed53a78655040..f3ac2d5f89d88790c4336be279ddbfb7ea203d6f 100644 (file)
--- a/builtin-describe.c
+++ b/builtin-describe.c
sha1_to_hex(gave_up_on->object.sha1));
}
}
- printf("%s-g%s\n", all_matches[0].name->path,
- find_unique_abbrev(cmit->object.sha1, abbrev));
+ if (abbrev == 0)
+ printf("%s\n", all_matches[0].name->path );
+ else
+ printf("%s-g%s\n", all_matches[0].name->path,
+ find_unique_abbrev(cmit->object.sha1, abbrev));
if (!last_one)
clear_commit_marks(cmit, -1);
tags = 1;
else if (!strncmp(arg, "--abbrev=", 9)) {
abbrev = strtoul(arg + 9, NULL, 10);
- if (abbrev < MINIMUM_ABBREV || 40 < abbrev)
+ if (abbrev != 0 && (abbrev < MINIMUM_ABBREV || 40 < abbrev))
abbrev = DEFAULT_ABBREV;
}
else if (!strncmp(arg, "--candidates=", 13)) {