Skip to content

Commit 6b1ddbd

Browse files
author
Junio C Hamano
committed
diff --abbrev=<n> option fix.
Earier specifying an abbreviation shorter than minimum fell back to full 40 letters, which was nonsense. Make it to fall back to the minimum number (currently 4). Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent f2d4227 commit 6b1ddbd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

diff.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,8 +847,13 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
847847
options->find_copies_harder = 1;
848848
else if (!strcmp(arg, "--abbrev"))
849849
options->abbrev = DEFAULT_ABBREV;
850-
else if (!strncmp(arg, "--abbrev=", 9))
850+
else if (!strncmp(arg, "--abbrev=", 9)) {
851851
options->abbrev = strtoul(arg + 9, NULL, 10);
852+
if (options->abbrev < MINIMUM_ABBREV)
853+
options->abbrev = MINIMUM_ABBREV;
854+
else if (40 < options->abbrev)
855+
options->abbrev = 40;
856+
}
852857
else
853858
return 0;
854859
return 1;

0 commit comments

Comments
 (0)