🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.git
1 messages
1 total messages Started by "Ophir Bleicher via GitGitGadget... Fri, 20 Nov 2026 15:08
[PATCH] rev-parse: output requested object format in SHA-1 compatible repos
#3457
Author: "Ophir Bleicher via GitGitGadget...
Date: Fri, 20 Nov 2026 15:08
52 lines
12192 bytes
From: Ophir Bleicher <ophirble@gmail.com>

git rev-parse --output-object-format=sha1 <oid> outputs the wrong
hash when the repository uses SHA-256 but is SHA-1 compatible, and
the requested object was made before the repository was SHA-1
compatible.

For example:
git init --object-format=sha256
oid=$(echo unmapped | git hash-object -w --stdin)
git config extensions.compatObjectFormat sha1
git rev-parse --output-object-format=sha1 "$oid"

The last command outputs the SHA-256 value of the object, even
though --output-object-format=sha1 was passed.

Now an error is raised instead of outputting a wrong hash.

Signed-off-by: Ophir Bleicher <ophirble@gmail.com>
---
    rev-parse: output requested object format in SHA-1 compatible repos

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2494%2FOphirBleicher%2Fsha1-compat-rev-parse-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2494/OphirBleicher/sha1-compat-rev-parse-v1
Pull-Request: https://github.com/git/git/pull/2494

 builtin/rev-parse.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index fbc5ef8727..5d3ac2a865 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -1175,9 +1175,10 @@ int cmd_rev_parse(int argc,
 		}
 		if (!repo_get_oid_with_flags(the_repository, name, &oid,
 					     flags)) {
-			if (output_algo)
-				repo_oid_to_algop(the_repository, &oid,
-						  output_algo, &oid);
+			if (output_algo && repo_oid_to_algop(the_repository, &oid,
+							     output_algo, &oid))
+				die(_("cannot map object %s to %s"), oid_to_hex(&oid),
+				      output_algo->name);
 			if (verify)
 				revs_count++;
 			else

base-commit: f7de81456940dd6f3274e461149bba12965de609
-- 
gitgitgadget
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads