git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Starting to think about sha-256?

From
Linus Torvalds <torvalds@osdl.org>
Date
Aug 28, 2006, 20:20 UTC
Message-ID
<Pine.LNX.4.64.0608281317070.27779@g5.osdl.org>
In-Reply-To
<m34pvwfwl5.fsf@defiant.localdomain>
On Mon, 28 Aug 2006, Krzysztof Halasa wrote:
Show 10 quoted lines
>
> Linus Torvalds <torvalds@osdl.org> writes:
> 
> >    In related news, the question is what to do about the inadvertent 
> >    collision.. First off, let me remind people that the inadvertent kind 
> >    of collision is really really _really_ damn unlikely, so we'll quite 
> >    likely never ever see it in the full history of the universe.
> 
> Actually I think we may see it when somebody tries to put a real
> example of conflicting SHA-1 pair into git repository.
Well, by definition, I wouldn't call that "inadvertent" ;)

Anyway, the way to do it (if you want to use git to document SHA1 hash mismatches) is to just check the files that have an identical SHA1 in. It will magically work!

Why? Because a git SHA1 is actually _not_ the SHA1 of the file itself, it's the SHA1 of the file _with_the_git_header_added_.

So if you find two files that have the same SHA1, they would also have to have the same length in order to actually generate the same object name. If they have different lenths, you can just check them into git, and they'll get two different git SHA1 names and you'll have a cool git archive that when you check the files out, they checked-out files will share the same SHA1 ;)

		Linus
Previous: Krzysztof HalasaNext: Krzysztof Halasa
Message 14 of 19 in “Starting to think about sha-256?”
  1. Jeff GarzikAug 27, 2006
  2. Krzysztof HalasaAug 27, 2006
  3. Linus TorvaldsAug 27, 2006
  4. Krzysztof HalasaAug 27, 2006
  5. Johannes SchindelinAug 27, 2006
  6. Linus TorvaldsAug 27, 2006
  7. David LangAug 28, 2006
  8. Linus TorvaldsAug 28, 2006
  9. Linus TorvaldsAug 28, 2006
  10. Jeff KingAug 28, 2006
  11. Linus TorvaldsAug 28, 2006
  12. Jeff KingAug 28, 2006
  13. Krzysztof HalasaAug 28, 2006
  14. Linus TorvaldsAug 28, 2006
  15. Krzysztof HalasaAug 28, 2006
  16. Linus TorvaldsAug 28, 2006
  17. Johannes SchindelinAug 28, 2006
  18. Linus TorvaldsAug 28, 2006
  19. Florian WeimerAug 29, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.