Skip to content

Commit 1e50d83

Browse files
shreyp135gitster
authored andcommitted
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/20180921155739.14407-21-pclouds@gmail.com/ [2]- https://lore.kernel.org/git/20260109213021.2546-2-l.s.r@web.de/ Signed-off-by: Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 67ad421 commit 1e50d83

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

tree-diff.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* Helper functions for tree diff generation
33
*/
44

5-
#define USE_THE_REPOSITORY_VARIABLE
65
#define DISABLE_SIGN_COMPARE_WARNINGS
76

87
#include "git-compat-util.h"
@@ -11,7 +10,6 @@
1110
#include "hash.h"
1211
#include "tree.h"
1312
#include "tree-walk.h"
14-
#include "environment.h"
1513
#include "repository.h"
1614
#include "dir.h"
1715

@@ -253,7 +251,7 @@ static void emit_path(struct combine_diff_path ***tail,
253251

254252
strbuf_add(base, path, pathlen);
255253
p = combine_diff_path_new(base->buf, base->len, mode,
256-
oid ? oid : null_oid(the_hash_algo),
254+
oid ? oid : null_oid(opt->repo->hash_algo),
257255
nparent);
258256
strbuf_setlen(base, old_baselen);
259257

@@ -278,7 +276,7 @@ static void emit_path(struct combine_diff_path ***tail,
278276
mode_i = tp[i].entry.mode;
279277
}
280278
else {
281-
oid_i = null_oid(the_hash_algo);
279+
oid_i = null_oid(opt->repo->hash_algo);
282280
mode_i = 0;
283281
}
284282

0 commit comments

Comments
 (0)