git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Daniel Barkalow <barkalow@iabervon.org>
Cc: "Karl Hasselström" <kha@treskal.com>,
	bfields@citi.umich.edu, junio@cox.net, git@vger.kernel.org
Subject: Re: [PATCH] Add a birdview-on-the-source-code section to the user manual
Date: Wed, 9 May 2007 11:38:34 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0705091137190.4167@racer.site> (raw)
In-Reply-To: <Pine.LNX.4.64.0705090015360.18541@iabervon.org>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: TEXT/PLAIN; charset=UTF-8, Size: 2681 bytes --]

Hi,

On Wed, 9 May 2007, Daniel Barkalow wrote:

> On Wed, 9 May 2007, Johannes Schindelin wrote:
> 
> > 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.

That's a really good idea, to point out that "unsigned char *" refers to 
octets, while "char *" refers to the ASCII representation. I will add 
this, together with a simple example (the initial commit).

Ciao,
Dscho

  parent reply	other threads:[~2007-05-09  9:38 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-08 15:10 [PATCH] Add a birdview-on-the-source-code section to the user manual Johannes Schindelin
2007-05-08 21:01 ` Karl Hasselström
2007-05-08 21:07   ` Johannes Schindelin
2007-05-08 21:31     ` Karl Hasselström
2007-05-08 23:10       ` Johannes Schindelin
2007-05-08 23:22         ` Karl Hasselström
2007-05-09  4:54         ` Daniel Barkalow
2007-05-09  6:31           ` Karl Hasselström
2007-05-09  9:38           ` Johannes Schindelin [this message]
2007-05-09 10:43             ` Karl Hasselström
2007-05-09  3:18 ` J. Bruce Fields
2007-05-09  4:06   ` Junio C Hamano
2007-05-09  5:05     ` Junio C Hamano
2007-05-09  9:33       ` Johannes Schindelin
2007-05-09 17:36       ` J. Bruce Fields
2007-05-09  6:48   ` Karl Hasselström
2007-05-09  9:27   ` Johannes Schindelin
2007-05-09 12:19   ` Johannes Schindelin
2007-05-09 12:32     ` Petr Baudis
2007-05-09 12:50       ` Johannes Schindelin
2007-05-09 16:18         ` Daniel Barkalow
2007-05-09 16:25           ` Johannes Schindelin
2007-05-09 17:07             ` J. Bruce Fields
2007-05-09 20:15               ` Johannes Schindelin
2007-05-09 20:32                 ` J. Bruce Fields
2007-05-09 20:45                 ` Daniel Barkalow
2007-05-09 22:23                   ` Johannes Schindelin
2007-05-10 20:01                     ` Karl Hasselström
2007-05-09 13:18     ` J. Bruce Fields
2007-05-10  4:15       ` Junio C Hamano
2007-05-10 10:36         ` Johannes Schindelin
2007-05-10 20:42           ` Junio C Hamano
2007-05-10 21:14             ` Karl Hasselström

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0705091137190.4167@racer.site \
    --to=johannes.schindelin@gmx.de \
    --cc=barkalow@iabervon.org \
    --cc=bfields@citi.umich.edu \
    --cc=git@vger.kernel.org \
    --cc=junio@cox.net \
    --cc=kha@treskal.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).