builtin/merge-recursive: make hash independent
authorbrian m. carlson <sandals@crustytoothpaste.net>
Mon, 16 Jul 2018 01:28:04 +0000 (01:28 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 Jul 2018 21:27:39 +0000 (14:27 -0700)
Use GIT_MAX_HEXSZ instead of GIT_SHA1_HEXSZ for an allocation so that it
is sufficiently large. Switch a comparison to use the_hash_algo to
determine the length of a hex object ID.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/merge-recursive.c
index 0dd902195878aedef76559ad67ad6dc9384141b3..9b2f707c291cf903b9151c2f3673b6fe0e0ca6d5 100644 (file)
@@ -9,10 +9,10 @@ static const char builtin_merge_recursive_usage[] =
 
 static const char *better_branch_name(const char *branch)
 {
-       static char githead_env[8 + GIT_SHA1_HEXSZ + 1];
+       static char githead_env[8 + GIT_MAX_HEXSZ + 1];
        char *name;
 
-       if (strlen(branch) != GIT_SHA1_HEXSZ)
+       if (strlen(branch) != the_hash_algo->hexsz)
                return branch;
        xsnprintf(githead_env, sizeof(githead_env), "GITHEAD_%s", branch);
        name = getenv(githead_env);