{"thread":{"id":"65031","subject":"[PATCH] tree-diff: remove the usage of the_hash_algo global","startedAt":"2026-02-20T17:53:51Z","lastAt":"2026-02-20T20:21:32Z","messageCount":2,"participants":["Shreyansh Paliwal","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"536543","messageId":"20260220175331.1250726-1-shreyanshpaliwalcmsmn@gmail.com","threadId":"65031","inReplyTo":null,"subject":"[PATCH] tree-diff: remove the usage of the_hash_algo global","fromName":"Shreyansh Paliwal","fromEmail":"shreyanshpaliwalcmsmn@gmail.com","sentAt":"2026-02-20T17:51:26Z","receivedAt":"2026-02-20T17:53:51Z","isPatch":true,"sender":{"key":"shreyanshpaliwalcmsmn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/152720574?v=4"},"body":"emit_path() uses the global the_hash_algo even though a local repository is\nalready available via struct diff_options *opt.\n\nReplace these uses with opt->repo->hash_algo. With no remaining reliance on\nglobal states in this file, drop the dependency on 'environment.h' and remove\n'#define USE_THE_REPOSITORY_VARIABLE'.\n\nThis follows earlier cleanups to introduce opt->repo in tree-diff.c [1][2].\n\n[1]- https://lore.kernel.org/git/20180921155739.14407-21-pclouds@gmail.com/\n[2]- https://lore.kernel.org/git/20260109213021.2546-2-l.s.r@web.de/\n\nSigned-off-by: Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>\n---\n tree-diff.c | 6 ++----\n 1 file changed, 2 insertions(+), 4 deletions(-)\n\ndiff --git a/tree-diff.c b/tree-diff.c\nindex 631ea86812..2f5c956d02 100644\n--- a/tree-diff.c\n+++ b/tree-diff.c\n@@ -2,7 +2,6 @@\n  * Helper functions for tree diff generation\n  */\n \n-#define USE_THE_REPOSITORY_VARIABLE\n #define DISABLE_SIGN_COMPARE_WARNINGS\n \n #include \"git-compat-util.h\"\n@@ -11,7 +10,6 @@\n #include \"hash.h\"\n #include \"tree.h\"\n #include \"tree-walk.h\"\n-#include \"environment.h\"\n #include \"repository.h\"\n #include \"dir.h\"\n \n@@ -253,7 +251,7 @@ static void emit_path(struct combine_diff_path ***tail,\n \n \t\tstrbuf_add(base, path, pathlen);\n \t\tp = combine_diff_path_new(base->buf, base->len, mode,\n-\t\t\t\t\t  oid ? oid : null_oid(the_hash_algo),\n+\t\t\t\t\t  oid ? oid : null_oid(opt->repo->hash_algo),\n \t\t\t\t\t  nparent);\n \t\tstrbuf_setlen(base, old_baselen);\n \n@@ -278,7 +276,7 @@ static void emit_path(struct combine_diff_path ***tail,\n \t\t\t\tmode_i = tp[i].entry.mode;\n \t\t\t}\n \t\t\telse {\n-\t\t\t\toid_i = null_oid(the_hash_algo);\n+\t\t\t\toid_i = null_oid(opt->repo->hash_algo);\n \t\t\t\tmode_i = 0;\n \t\t\t}\n \n-- \n2.53.0\n\n"},{"id":"536549","messageId":"xmqq342vxj1y.fsf@gitster.g","threadId":"65031","inReplyTo":"20260220175331.1250726-1-shreyanshpaliwalcmsmn@gmail.com","subject":"Re: [PATCH] tree-diff: remove the usage of the_hash_algo global","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-20T20:21:29Z","receivedAt":"2026-02-20T20:21:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com> writes:\n\n> emit_path() uses the global the_hash_algo even though a local repository is\n> already available via struct diff_options *opt.\n>\n> Replace these uses with opt->repo->hash_algo. With no remaining reliance on\n> global states in this file, drop the dependency on 'environment.h' and remove\n> '#define USE_THE_REPOSITORY_VARIABLE'.\n>\n> This follows earlier cleanups to introduce opt->repo in tree-diff.c [1][2].\n>\n> [1]- https://lore.kernel.org/git/20180921155739.14407-21-pclouds@gmail.com/\n> [2]- https://lore.kernel.org/git/20260109213021.2546-2-l.s.r@web.de/\n>\n> Signed-off-by: Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>\n> ---\n>  tree-diff.c | 6 ++----\n>  1 file changed, 2 insertions(+), 4 deletions(-)\n\nNice.  Will queue.  Thanks.\n"}]}