]> asedeno.scripts.mit.edu Git - git.git/commitdiff
rev-parse --abbrev: do not try abbrev shorter than minimum.
authorJunio C Hamano <junkio@cox.net>
Thu, 26 Jan 2006 08:48:19 +0000 (00:48 -0800)
committerJunio C Hamano <junkio@cox.net>
Sat, 28 Jan 2006 08:09:39 +0000 (00:09 -0800)
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>
rev-parse.c

index 42969a6fc1b7591b13a2fc664421e4f1da465cdb..8bf316eeddba1407927dd3fd1cd9b580f81d6840 100644 (file)
@@ -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")) {