From: Junio C Hamano Date: Thu, 26 Jan 2006 08:48:19 +0000 (-0800) Subject: rev-parse --abbrev: do not try abbrev shorter than minimum. X-Git-Tag: v1.2.0~100^5~4 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=1dc4fb84b5914621cf59b6b508ad7c9c86c61fa4;p=git.git 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 --- diff --git a/rev-parse.c b/rev-parse.c index 42969a6f..8bf316ee 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")) {