tree-diff: remove the usage of the_hash_algo global
PATCH 1/1 tree-diff: remove the usage of the_hash_algo global
emit_path() uses the global the_hash_algo even though a local repository is already available via struct diff_options *opt.
Replace these uses with opt->repo->hash_algo. With no remaining reliance on global states in this file, drop the dependency on 'environment.h' and remove '#define USE_THE_REPOSITORY_VARIABLE'.
This follows earlier cleanups to introduce opt->repo in tree-diff.c [1][2].
[1]- https://lore.kernel.org/git/[email protected]/
[2]- https://lore.kernel.org/git/[email protected]/
--- tree-diff.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
tree-diff.c +2 -4
@@ -2,7 +2,6 @@* Helper functions for tree diff generation */ -#define USE_THE_REPOSITORY_VARIABLE #define DISABLE_SIGN_COMPARE_WARNINGS #include "git-compat-util.h"
@@ -11,7 +10,6 @@#include "hash.h" #include "tree.h" #include "tree-walk.h" -#include "environment.h" #include "repository.h" #include "dir.h"
@@ -253,7 +251,7 @@ static void emit_path(struct combine_diff_path ***tail,strbuf_add (base, path, pathlen); p =combine_diff_path_new (base->buf, base->len, mode, - oid ? oid :null_oid (the_hash_algo), + oid ? oid :null_oid (opt->repo->hash_algo), nparent);strbuf_setlen (base, old_baselen);
@@ -278,7 +276,7 @@ static void emit_path(struct combine_diff_path ***tail, mode_i = tp[i].entry.mode; }else { - oid_i =null_oid (the_hash_algo); + oid_i =null_oid (opt->repo->hash_algo); mode_i =0 ; }
Signature · 1 line
2.53.0
Quoted 9 lines · Shreyansh Paliwal
emit_path()uses the globalthe_hash_algoeven though a local repository is already available via structdiff_options*opt.Replace these uses with
opt->repo->hash_algo. With no remaining reliance on global states in this file, drop the dependency on 'environment.h' and remove '#defineUSE_THE_REPOSITORY_VARIABLE'.This follows earlier cleanups to introduce
opt->repointree-diff.c[1][2].
Quoted 7 lines
[1]- https://lore.kernel.org/git/[email protected]/
[2]- https://lore.kernel.org/git/[email protected]/Signed-off-by Shreyansh Paliwal <[email protected]>--- tree-diff.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
Nice. Will queue. Thanks.