summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-01-26 08:48:19 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-01-28 08:09:39 (GMT)
commit1dc4fb84b5914621cf59b6b508ad7c9c86c61fa4 (patch)
treec46dc65e40d7e11afa69ea0eace49674758ad5f2
parentb2d4c56f2f370481c80e478ac323ebb13eece807 (diff)
downloadgit-1dc4fb84b5914621cf59b6b508ad7c9c86c61fa4.zip
git-1dc4fb84b5914621cf59b6b508ad7c9c86c61fa4.tar.gz
git-1dc4fb84b5914621cf59b6b508ad7c9c86c61fa4.tar.bz2
rev-parse --abbrev: do not try abbrev shorter than minimum.
We do not allow abbreviation shorter than 4 letters in other parts of the system so do not attempt to generate such. Noticed by Uwe Zeisberger. Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r--rev-parse.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/rev-parse.c b/rev-parse.c
index 42969a6..8bf316e 100644
--- a/rev-parse.c
+++ b/rev-parse.c
@@ -206,8 +206,10 @@ int main(int argc, char **argv)
abbrev = DEFAULT_ABBREV;
if (arg[8] == '=')
abbrev = strtoul(arg + 9, NULL, 10);
- if (abbrev < 0 || 40 <= abbrev)
- abbrev = DEFAULT_ABBREV;
+ if (abbrev < MINIMUM_ABBREV)
+ abbrev = MINIMUM_ABBREV;
+ else if (40 <= abbrev)
+ abbrev = 40;
continue;
}
if (!strcmp(arg, "--sq")) {