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 <sand...@crustytoothpaste.net>
---
 merge-recursive.c | 2 +-
 submodule.c       | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/merge-recursive.c b/merge-recursive.c
index 4851825aeb..b8bd5d4f8d 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1122,7 +1122,7 @@ static int find_first_merges(struct repository *repo,
        struct commit *commit;
        int contains_another;
 
-       char merged_revision[42];
+       char merged_revision[GIT_MAX_HEXSZ + 2];
        const char *rev_args[] = { "rev-list", "--merges", "--ancestry-path",
                                   "--all", merged_revision, NULL };
        struct rev_info revs;
diff --git a/submodule.c b/submodule.c
index 934ecfa294..0e2faaa41b 100644
--- a/submodule.c
+++ b/submodule.c
@@ -990,7 +990,7 @@ static int submodule_needs_pushing(struct repository *r,
                if (start_command(&cp))
                        die("Could not run 'git rev-list <commits> --not 
--remotes -n 1' command in submodule %s",
                                        path);
-               if (strbuf_read(&buf, cp.out, 41))
+               if (strbuf_read(&buf, cp.out, the_hash_algo->hexsz + 1))
                        needs_pushing = 1;
                finish_command(&cp);
                close(cp.out);

Reply via email to