From: Tian Yuchen <cat@malon.dev>
To: git@vger.kernel.org
Cc: gitster@pobox.com, phillip.wood@dunelm.org.uk,
Tian Yuchen <cat@malon.dev>
Subject: [PATCH v1] builtin/patch-id.c: make reliance on the_hash_algo explicit
Date: Tue, 17 Mar 2026 21:47:39 +0800 [thread overview]
Message-ID: <20260317134739.2465620-1-cat@malon.dev> (raw)
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
reply other threads:[~2026-03-17 13:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260317134739.2465620-1-cat@malon.dev \
--to=cat@malon.dev \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=phillip.wood@dunelm.org.uk \
/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