Skip to content

Commit 7e0d029

Browse files
bk2204gitster
authored andcommitted
builtin/rev-parse: switch to use the_hash_algo
Switch several hard-coded uses of the constant 40 to references to the_hash_algo. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 3190096 commit 7e0d029

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

builtin/rev-parse.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
593593
const char *name = NULL;
594594
struct object_context unused;
595595
struct strbuf buf = STRBUF_INIT;
596+
const int hexsz = the_hash_algo->hexsz;
596597

597598
if (argc > 1 && !strcmp("--parseopt", argv[1]))
598599
return cmd_parseopt(argc - 1, argv + 1, prefix);
@@ -730,8 +731,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
730731
abbrev = strtoul(arg, NULL, 10);
731732
if (abbrev < MINIMUM_ABBREV)
732733
abbrev = MINIMUM_ABBREV;
733-
else if (40 <= abbrev)
734-
abbrev = 40;
734+
else if (hexsz <= abbrev)
735+
abbrev = hexsz;
735736
continue;
736737
}
737738
if (!strcmp(arg, "--sq")) {

0 commit comments

Comments
 (0)