Skip to content

Commit hashes are wrong in Git Internals chapter #1423

@Smaug123

Description

@Smaug123

Which version of the book is affected?
All versions since 4f55250

Describe the bug:

An update changed commit messages without correspondingly changing the commit hashes in the walkthroughs of how to create a commit and so on (Chapter 10).

Steps to reproduce:

export GIT_AUTHOR_DATE="2009-05-22T18:09:34+00:00-0700" \
export GIT_AUTHOR_EMAIL="schacon@gmail.com" \
export GIT_AUTHOR_NAME="Scott Chacon" \
export GIT_COMMITTER_DATE="2009-05-22T18:09:34+00:00-0700" \
export GIT_COMMITTER_EMAIL="schacon@gmail.com" \
export GIT_COMMITTER_NAME="Scott Chacon"

Then follow the instructions in the book, chapter 10.2 onwards.

Expected behavior:
The commit hashes to match the book. In fact they don't; commit 1 is 70d4408b5020e81d19906d6abdd87a73233ebf34, commit 2 is 1513b13a72f5277252cfce4ed0eda0620aca2f6a; commit 3 is 95cce637b4e889eee8042515db402128bd62c0d2.

I am doing this with git version 2.26.1, but I don't think this has changed ever.

Additional context:
I raised #1422 before realising that this was an annoying amount of work to update the diagrams and the rest of the chapter.

I then tried to simply back out the rogue part of the bad commit, but while this fixed commit 1, I got a different hash again for commit 2:

➜ echo 'second commit' | git commit-tree 0155eb -p fdf4fc3
bd9c476d4e5b95299f01fd2c711a7d23c7a00c6b
➜ git cat-file -p bd9c476d4e5b95299f01fd2c711a7d23c7a00c6b
tree 0155eb4229851634a0f03eb265b69f5a2d56f341
parent fdf4fc3344e67ab068f836878b6c4951e3b15f3d
author Scott Chacon <schacon@gmail.com> 1243040974 -0700
committer Scott Chacon <schacon@gmail.com> 1243040974 -0700

second commit                                  

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions