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>
brian m. carlson committed
Aug 18, 2019 at 20:04 UTC
7e0d029f187dfe3fee9de9ccce43200202fc14f6
1 file changed
+3
-2
builtin/rev-parse.c
+3
-2
@@ -593,6 +593,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
593
const char *name = NULL;
594
struct object_context unused;
595
struct strbuf buf = STRBUF_INIT;
596
+ const int hexsz = the_hash_algo->hexsz;
597
598
if (argc > 1 && !strcmp("--parseopt", argv[1]))
599
return cmd_parseopt(argc - 1, argv + 1, prefix);
@@ -730,8 +731,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
731
abbrev = strtoul(arg, NULL, 10);
732
if (abbrev < MINIMUM_ABBREV)
733
abbrev = MINIMUM_ABBREV;
733
- else if (40 <= abbrev)
734
- abbrev = 40;
734
+ else if (hexsz <= abbrev)
735
+ abbrev = hexsz;
736
continue;
737
}
738
if (!strcmp(arg, "--sq")) {