git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
To: git@vger.kernel.org
Cc: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
Subject: [PATCH] [PATCH] [Outreachy] builtin/patch-id.c: clarify SHA1 usage for patch IDs
Date: Mon, 13 Oct 2025 18:46:58 +0100	[thread overview]
Message-ID: <20251013174658.236940-1-okhuomonajayi54@gmail.com> (raw)

Patch IDs in Git must always use SHA1, regardless of the repository's
object hash. Previously, the code relied on `the_hash_algo` which could
vary depending on the repository, and included a NEEDSWORK comment
suggesting this should be fixed.

This patch updates the comment to clearly state that SHA1 is required
for patch IDs and sets the hash algorithm to SHA1 if it is not already
set. This ensures consistent computation of patch IDs in accordance
with git-patch-id(1).

No functional behavior is changed, but misleading comments are removed
and the code now explicitly enforces correct SHA1 usage for patch IDs.

Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
---
 builtin/patch-id.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/builtin/patch-id.c b/builtin/patch-id.c
index d26e9d0c1e..d47b6f5a3f 100644
--- a/builtin/patch-id.c
+++ b/builtin/patch-id.c
@@ -246,16 +246,11 @@ int cmd_patch_id(int argc,
 			     patch_id_usage, 0);
 
 	/*
-	 * We rely on `the_hash_algo` to compute patch IDs. This is dubious as
-	 * it means that the hash algorithm now depends on the object hash of
-	 * the repository, even though git-patch-id(1) clearly defines that
-	 * patch IDs always use SHA1.
-	 *
-	 * NEEDSWORK: This hack should be removed in favor of converting
-	 * the code that computes patch IDs to always use SHA1.
+	 * Patch IDs must always use SHA1, regardless of the repository's
+	 * object hash, See git-patch-id(1) for details. 
 	 */
 	if (!the_hash_algo)
-		repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT);
+		repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
 
 	generate_id_list(opts ? opts > 1 : config.stable,
 			 opts ? opts == 3 : config.verbatim);
-- 
2.43.0



             reply	other threads:[~2025-10-13 17:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-13 17:46 Okhuomon Ajayi [this message]
2025-10-14  3:00 ` [PATCH] [PATCH] [Outreachy] builtin/patch-id.c: clarify SHA1 usage for patch IDs Junio C Hamano
2025-10-14  8:04   ` Okhuomon Ajayi
2025-10-14 21:18 ` brian m. carlson
2025-10-14 22:29   ` Junio C Hamano
2025-10-14 22:49     ` brian m. carlson
2025-10-14 23:27       ` Okhuomon Ajayi
2025-10-15 13:37       ` Junio C Hamano
2025-10-15 13:59         ` Kristoffer Haugsbakk

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20251013174658.236940-1-okhuomonajayi54@gmail.com \
    --to=okhuomonajayi54@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).