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

Re: [PATCH] Add a birdview-on-the-source-code section to the user manual

From
Daniel Barkalow <barkalow@iabervon.org>
Date
May 9, 2007, 04:54 UTC
Message-ID
<Pine.LNX.4.64.0705090015360.18541@iabervon.org>
In-Reply-To
<Pine.LNX.4.64.0705090105450.4167@racer.site>
On Wed, 9 May 2007, Johannes Schindelin wrote:
Show 34 quoted lines
> Hi,
> 
> On Tue, 8 May 2007, Karl Hasselstr�m wrote:
> 
> > On 2007-05-08 23:07:04 +0200, Johannes Schindelin wrote:
> > 
> > > On Tue, 8 May 2007, Karl Hasselstr�m wrote:
> > >
> > > > On 2007-05-08 17:10:47 +0200, Johannes Schindelin wrote:
> > > >
> > > > > +  char *`, but is actually expected to be a pointer to `unsigned
> > > > > +  char[20]`.  This variable will contain the big endian version of the
> > > > > +  40-character hex string representation of the SHA-1.
> > > >
> > > > Either it should be "unsigned char[40]" (or possibly 41 with a
> > > > terminating \0), or else you shouldn't be talking about
> > > > hexadecimal since it's just a 20-byte big-endian unsigned integer.
> > > > (A third possibility is that I'm totally confused.)
> > >
> > > It is 40 hex-character, but 20 _byte_. If you have any ideas how to
> > > formulate that better than I did...
> > 
> > I think this is less confusing:
> > 
> >   This variable will contain the 160-bit SHA-1.
> > 
> > It avoids talking of hex, since it's not really stored in hex format
> > any more than any other binary number with a number of bits divisible
> > by four. And it avoids saying big-endian, which is not relevant anyway
> > since we don't use hashes as integers.
> 
> Well, I do not buy into that. First, we _have_ to say that it is 
> big-endian. It was utterly confusing to _me_ that the hash was not little 
> endian, as I expected on an Intel processor.

SHA-1 is defined as producing a octet sequence, and to have a canonical hex digit sequence conversion with the high nibbles first. Internally, it is canonically specified using big-endian math, but the same algorithm could equally be specified with little-endian math and different rules for input and output.

> And I'd rather mention the hex representation (what you see in git-log and 
> git-ls-tree). This helps debugging, believe me.

It's kind of important to distinguish between the hex representation and the octet representation, because your code will not work at all if you use the wrong one. And "unsigned char *" or "unsigned char[20]" is always the octets; the hex is always "char *". Primarily mentioning the one that is more intuitive but less frequently used doesn't help with understanding the actual code.

	-Daniel
*This .sig left intentionally blank*
Previous: Karl HasselströmNext: Karl Hasselström
Message 7 of 33 in “Add a birdview-on-the-source-code section to the user manual”
  1. Add a birdview-on-the-source-code section to the user manualJohannes Schindelin, May 8, 2007
  2. Karl HasselströmMay 8, 2007
  3. Johannes SchindelinMay 8, 2007
  4. Karl HasselströmMay 8, 2007
  5. Johannes SchindelinMay 8, 2007
  6. Karl HasselströmMay 8, 2007
  7. Daniel BarkalowMay 9, 2007
  8. Karl HasselströmMay 9, 2007
  9. Johannes SchindelinMay 9, 2007
  10. Karl HasselströmMay 9, 2007
  11. J. Bruce FieldsMay 9, 2007
  12. Junio C HamanoMay 9, 2007
  13. Junio C HamanoMay 9, 2007
  14. Johannes SchindelinMay 9, 2007
  15. J. Bruce FieldsMay 9, 2007
  16. Karl HasselströmMay 9, 2007
  17. Johannes SchindelinMay 9, 2007
  18. Johannes SchindelinMay 9, 2007
  19. Petr BaudisMay 9, 2007
  20. Johannes SchindelinMay 9, 2007
  21. Daniel BarkalowMay 9, 2007
  22. Johannes SchindelinMay 9, 2007
  23. J. Bruce FieldsMay 9, 2007
  24. Johannes SchindelinMay 9, 2007
  25. J. Bruce FieldsMay 9, 2007
  26. Daniel BarkalowMay 9, 2007
  27. Johannes SchindelinMay 9, 2007
  28. Karl HasselströmMay 10, 2007
  29. J. Bruce FieldsMay 9, 2007
  30. Junio C HamanoMay 10, 2007
  31. Add a birdview-on-the-source-code section to the user manualJohannes Schindelin, May 10, 2007
  32. Junio C HamanoMay 10, 2007
  33. Karl HasselströmMay 10, 2007

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.