{"thread":{"id":"65275","subject":"[PATCH v1] builtin/patch-id.c: make reliance on the_hash_algo explicit","startedAt":"2026-03-17T13:48:08Z","lastAt":"2026-03-17T13:48:08Z","messageCount":1,"participants":["Tian Yuchen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"539220","messageId":"20260317134739.2465620-1-cat@malon.dev","threadId":"65275","inReplyTo":null,"subject":"[PATCH v1] builtin/patch-id.c: make reliance on the_hash_algo explicit","fromName":"Tian Yuchen","fromEmail":"cat@malon.dev","sentAt":"2026-03-17T13:47:39Z","receivedAt":"2026-03-17T13:48:08Z","isPatch":true,"sender":{"key":"cat@malon.dev","avatar":"https://avatars.githubusercontent.com/u/232002048?v=4"},"body":"Call get_oid_hex_algop() directly with 'the_hash_algo' to make the\nreliance on the global hash algorithm explicit rather than hiding\nit behind get_oid_hex().\n\nSigned-off-by: Tian Yuchen <cat@malon.dev>\n---\nI tried to modify all relevant functions to support calling 'repo->hash_algo'.\n\nHowever, this failed the test:\n\nnot ok 26 - patch-id without repository\n#    \n#        cat >diff <<-\\EOF &&\n#        diff --git a/bar b/bar\n#        index bdaf90f..31051f6 100644\n#        --- a/bar\n#        +++ b/bar\n#        @@ -2 +2,2 @@\n#         b\n#        +c\n#        EOF\n#        nongit git patch-id <diff\n\nrepo=NULL happened here. \n\nI can't think of a particularly good way to solve this, so I didn't bother\nwith it anymore. In other words, replacing the_repository with repo here isn't\nworth the effort IMO.\n\nAt least for now, this section is no longer \"secretly\" reading global variable.\n\nRegards,\nYuchen\n\n builtin/patch-id.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/patch-id.c b/builtin/patch-id.c\nindex 2781598ede..2939c353fd 100644\n--- a/builtin/patch-id.c\n+++ b/builtin/patch-id.c\n@@ -90,7 +90,7 @@ static size_t get_one_patchid(struct object_id *next_oid, struct object_id *resu\n \t\t\tcontinue;\n \t\t}\n \n-\t\tif (!get_oid_hex(p, next_oid)) {\n+\t\tif (!get_oid_hex_algop(p, next_oid, the_hash_algo)) {\n \t\t\tfound_next = 1;\n \t\t\tbreak;\n \t\t}\n-- \n2.43.0\n\n"}]}