git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v1] builtin/patch-id.c: make reliance on the_hash_algo explicit

From
Tian Yuchen <cat@malon.dev>
Date
Mar 17, 2026, 13:47 UTC
Message-ID
<20260317134739.2465620-1-cat@malon.dev>

Call get_oid_hex_algop() directly with 'the_hash_algo' to make the reliance on the global hash algorithm explicit rather than hiding it behind get_oid_hex().

Signed-off-by: Tian Yuchen <cat@malon.dev>
---
I tried to modify all relevant functions to support calling 'repo->hash_algo'.
However, this failed the test:

not ok 26 - patch-id without repository # # cat >diff <<-\EOF && # diff --git a/bar b/bar # index bdaf90f..31051f6 100644 # --- a/bar # +++ b/bar # @@ -2 +2,2 @@ # b # +c # EOF # nongit git patch-id <diff

repo=NULL happened here. 

I can't think of a particularly good way to solve this, so I didn't bother with it anymore. In other words, replacing the_repository with repo here isn't worth the effort IMO.

At least for now, this section is no longer "secretly" reading global variable.

Regards, Yuchen

 builtin/patch-id.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/patch-id.c b/builtin/patch-id.c
index 2781598ede..2939c353fd 100644
--- a/builtin/patch-id.c
+++ b/builtin/patch-id.c
@@ -90,7 +90,7 @@ static size_t get_one_patchid(struct object_id *next_oid, struct object_id *resu
 			continue;
 		}
 
-		if (!get_oid_hex(p, next_oid)) {
+		if (!get_oid_hex_algop(p, next_oid, the_hash_algo)) {
 			found_next = 1;
 			break;
 		}
-- 
2.43.0
Message 1 of 1 in “builtin/patch-id.c: make reliance on the_hash_algo explicit”
  1. builtin/patch-id.c: make reliance on the_hash_algo explicitTian Yuchen, Mar 17, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.