git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Possible BUG in 'git log -z' last commit is not '\0' terminated
@ 2007-06-22 19:27 Marco Costalba
  2007-06-22 21:29 ` Junio C Hamano
  2007-06-22 21:56 ` Linus Torvalds
  0 siblings, 2 replies; 4+ messages in thread
From: Marco Costalba @ 2007-06-22 19:27 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List

It seems '-z' option is not honoured by the last revision printed that
is just '\n' terminated.

Thanks
Marco

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Possible BUG in 'git log -z' last commit is not '\0' terminated
  2007-06-22 19:27 Possible BUG in 'git log -z' last commit is not '\0' terminated Marco Costalba
@ 2007-06-22 21:29 ` Junio C Hamano
  2007-06-22 21:56 ` Linus Torvalds
  1 sibling, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2007-06-22 21:29 UTC (permalink / raw)
  To: Marco Costalba; +Cc: Junio C Hamano, Git Mailing List

I am a bit busy right now and do not have time to dig into this,
but I suspect the LF you are seeing at the end belongs to the
commit log of the last entry, as I think -z is not about
termination but separation.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Possible BUG in 'git log -z' last commit is not '\0' terminated
  2007-06-22 19:27 Possible BUG in 'git log -z' last commit is not '\0' terminated Marco Costalba
  2007-06-22 21:29 ` Junio C Hamano
@ 2007-06-22 21:56 ` Linus Torvalds
  2007-06-23  5:51   ` Marco Costalba
  1 sibling, 1 reply; 4+ messages in thread
From: Linus Torvalds @ 2007-06-22 21:56 UTC (permalink / raw)
  To: Marco Costalba; +Cc: Junio C Hamano, Git Mailing List



On Fri, 22 Jun 2007, Marco Costalba wrote:
>
> It seems '-z' option is not honoured by the last revision printed that
> is just '\n' terminated.

It's not a bug - it's by design.

What the -z option does is to replace the normal "\n" that delineates 
commits from each other with a "\0".

And we only put that delimeter in *between* commits, not *after* commits. 
The reason? It's prettier. Do a 

	git log -1

to get a single commit, and notice how we do *not* add an empty line at 
the end (or beginning), and compare that to

	git log -2

that shows two commits, and has an empty line in *between*.

Now, add the "-z" flag, and notice how that empty line is now replaced by 
a "\0" character instead.

So you should think of the "\0" as being a delimeter that goes between
commits, not something that "ends" the commit. It's not a "end of record" 
thing, it's a "between records" thing.

		Linus

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Possible BUG in 'git log -z' last commit is not '\0' terminated
  2007-06-22 21:56 ` Linus Torvalds
@ 2007-06-23  5:51   ` Marco Costalba
  0 siblings, 0 replies; 4+ messages in thread
From: Marco Costalba @ 2007-06-23  5:51 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Junio C Hamano, Git Mailing List

On 6/22/07, Linus Torvalds <torvalds@linux-foundation.org> wrote:
>
> So you should think of the "\0" as being a delimeter that goes between
> commits, not something that "ends" the commit. It's not a "end of record"
> thing, it's a "between records" thing.
>

Thanks for explanation.

Interesting enough git-dif-tree with -z, documented as

"-z  \0 line termination on output"

has a different behaviour, with and without -p option:

git diff-tree -z HEAD ---> a '\0' is printed at the end

git diff-tree -z -p HEAD --> No '\0' is printed.

I suppose 'git log' passes '-z' to 'git diff-tree' because no
documentation exsists in 'git log' man page.

Thanks
Marco

BTW git-rev-list --header uses '\0' differently (appends to each
record), but that's another story.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-06-23  5:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-22 19:27 Possible BUG in 'git log -z' last commit is not '\0' terminated Marco Costalba
2007-06-22 21:29 ` Junio C Hamano
2007-06-22 21:56 ` Linus Torvalds
2007-06-23  5:51   ` Marco Costalba

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).