Skip to content

pr-git-2494/OphirBleicher/sha1-compat-rev-parse-v1

tagged this 20 Nov 15:08
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>

Submitted-As: https://lore.kernel.org/git/pull.2494.git.git.1795187313105.gitgitgadget@gmail.com
Assets 2
Loading