From: Dirk Gouders Date: Thu, 29 Feb 2024 13:05:07 GMT Subject: [PATCH 1/1] Documentation/user-manual.txt: example for generating object hashes Message-ID: In-Reply-To: If someone spends the time to work through the documentation, the subject "hashes" can lead to contradictions: The README of the initial commit states hashes are generated from compressed data (which changed very soon), whereas Documentation/user-manual.txt says they are generated from original data. Don't give doubts a chance: clarify this and present a simple example on how object hashes can be generated manually. Signed-off-by: Dirk Gouders --- Documentation/user-manual.txt | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt index 6433903491..8dfb81e045 100644 --- a/Documentation/user-manual.txt +++ b/Documentation/user-manual.txt @@ -4095,6 +4095,39 @@ that is used to name the object is the hash of the original data plus this header, so `sha1sum` 'file' does not match the object name for 'file'. +Starting with the initial commit, hashing was done on the compressed +data and the file README of that commit explicitely states this: + +"The SHA1 hash is always the hash of the _compressed_ object, not the +original one." + +This changed soon after that with commit +d98b46f8d9a3 (Do SHA1 hash _before_ compression.). Unfortunately, the +commit message doesn't provide the detailed reasoning. + +The following is a short example that demonstrates how hashes can be +generated manually: + +Let's asume a small text file with the content "Hello git.\n" +------------------------------------------------- +$ cat > hello.txt <