submodule: avoid hard-coded constants

Instead of using hard-coded 40-based constants, express these values in terms of the_hash_algo and GIT_MAX_HEXSZ. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Feb 19, 2019 at 00:04 UTC db1ba2a2302e7942981c70f9356c70e21e3f7bc7
2 files changed +2 -2
merge-recursive.c
+1 -1
@@ -1122,7 +1122,7 @@ static int find_first_merges(struct repository *repo,
1122 struct commit *commit;
1123 int contains_another;
1124
1125 - char merged_revision[42];
1125 + char merged_revision[GIT_MAX_HEXSZ + 2];
1126 const char *rev_args[] = { "rev-list", "--merges", "--ancestry-path",
1127 "--all", merged_revision, NULL };
1128 struct rev_info revs;
submodule.c
+1 -1
@@ -994,7 +994,7 @@ static int submodule_needs_pushing(struct repository *r,
994 if (start_command(&cp))
995 die("Could not run 'git rev-list <commits> --not --remotes -n 1' command in submodule %s",
996 path);
997 - if (strbuf_read(&buf, cp.out, 41))
997 + if (strbuf_read(&buf, cp.out, the_hash_algo->hexsz + 1))
998 needs_pushing = 1;
999 finish_command(&cp);
1000 close(cp.out);