0

saaaaaa

But when I paste the same content with the Git header prepended in https://passwordsgenerator.net/sha1-hash-generator/, I get

996DF2EBC2E14AF3D19B0D5EB791A09F8318353B

enter image description here

Dimoff
  • 120
  • 10
  • https://stackoverflow.com/search?q=%5Bgit%5D+hash-object – phd Sep 09 '20 at 20:08
  • `echo -en "blob 16\0what is up, doc?" | sha1sum` -> bd9dbf5aae1a3862dd1526723246b20206e5fc37 – phd Sep 09 '20 at 20:12
  • What's the difference between "blob 16\0" and "blob 16\u0000" (as per documentation)? – Dimoff Sep 09 '20 at 20:15
  • `blob 16\0` is the syntax for [`echo -e`](https://linux.die.net/man/1/echo). Not sure about `blob 16\u0000`, it's perhaps for [`printf`](https://linux.die.net/man/1/printf) but the result must be the same — one NULL character. – phd Sep 09 '20 at 20:26

1 Answers1

1

The ID of one object is not the sha1 of the content of what you put in. There's a header prepended that is considered as well for the ID that you get when you put the object in.

https://git-scm.com/book/en/v2/Git-Internals-Git-Objects

eftshift0
  • 26,375
  • 3
  • 36
  • 60
  • As you can clearly see in my screenshot, I've got "blob " + filesize + NUL prepended in front of the content... – Dimoff Sep 09 '20 at 20:10