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>
Junio C Hamano committed
Jan 26, 2006 at 00:48 UTC
1dc4fb84b5914621cf59b6b508ad7c9c86c61fa4
1 file changed
+4
-2
rev-parse.c
+4
-2
@@ -206,8 +206,10 @@ int main(int argc, char **argv)
206
abbrev = DEFAULT_ABBREV;
207
if (arg[8] == '=')
208
abbrev = strtoul(arg + 9, NULL, 10);
209
- if (abbrev < 0 || 40 <= abbrev)
210
- abbrev = DEFAULT_ABBREV;
209
+ if (abbrev < MINIMUM_ABBREV)
210
+ abbrev = MINIMUM_ABBREV;
211
+ else if (40 <= abbrev)
212
+ abbrev = 40;
213
continue;
214
}
215
if (!strcmp(arg, "--sq")) {