public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>
To: git@vger.kernel.org
Cc: Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>
Subject: [PATCH] tree-diff: remove the usage of the_hash_algo global
Date: Fri, 20 Feb 2026 23:21:26 +0530	[thread overview]
Message-ID: <20260220175331.1250726-1-shreyanshpaliwalcmsmn@gmail.com> (raw)

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>
---
 tree-diff.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/tree-diff.c b/tree-diff.c
index 631ea86812..2f5c956d02 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -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;
 			}
 
-- 
2.53.0


             reply	other threads:[~2026-02-20 17:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-20 17:51 Shreyansh Paliwal [this message]
2026-02-20 20:21 ` [PATCH] tree-diff: remove the usage of the_hash_algo global Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260220175331.1250726-1-shreyanshpaliwalcmsmn@gmail.com \
    --to=shreyanshpaliwalcmsmn@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox