]> git.ipfire.org Git - thirdparty/git.git/commitdiff
builtin/rev-parse: switch to use the_hash_algo
authorbrian m. carlson <sandals@crustytoothpaste.net>
Sun, 18 Aug 2019 20:04:07 +0000 (20:04 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 19 Aug 2019 22:04:57 +0000 (15:04 -0700)
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>
builtin/rev-parse.c

index f8bbe6d47ec397f55bec62d6a71bc6db8f08b54b..308c67e4fc668ec59343bbaba210b505c90a9e2c 100644 (file)
@@ -593,6 +593,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
        const char *name = NULL;
        struct object_context unused;
        struct strbuf buf = STRBUF_INIT;
+       const int hexsz = the_hash_algo->hexsz;
 
        if (argc > 1 && !strcmp("--parseopt", argv[1]))
                return cmd_parseopt(argc - 1, argv + 1, prefix);
@@ -730,8 +731,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
                                abbrev = strtoul(arg, NULL, 10);
                                if (abbrev < MINIMUM_ABBREV)
                                        abbrev = MINIMUM_ABBREV;
-                               else if (40 <= abbrev)
-                                       abbrev = 40;
+                               else if (hexsz <= abbrev)
+                                       abbrev = hexsz;
                                continue;
                        }
                        if (!strcmp(arg, "--sq")) {