git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git-log --pretty=format:'[%x00]%w(0,0,1)' doesn't print NUL and "]"
@ 2011-12-29 18:41 Tanaka Akira
  2011-12-29 19:23 ` Jeff King
  0 siblings, 1 reply; 2+ messages in thread
From: Tanaka Akira @ 2011-12-29 18:41 UTC (permalink / raw)
  To: git

I found that git-log doesn't print characters in --pretty option as follows.

  % git log --pretty=format:'[%x00]%w(0,0,1)' |od -c
  0000000   [  \n   [  \n   [  \n   [  \n   [  \n   [  \n   [  \n   [  \n
  *
  0022320   [  \n   [  \n   [  \n   [
  0022327

I think NUL and "]" should be printed.

Note that git log works as I expected if I use %w(0,0,0) instead of %w(0,0,1),
I don't use %w(0,0,1) or I use %x01 instead of %x00.

  % git log --pretty=format:'[%x00]%w(0,0,0)' |od -c
  0000000   [  \0   ]  \n   [  \0   ]  \n   [  \0   ]  \n   [  \0   ]  \n
  *
  0044640   [  \0   ]  \n   [  \0   ]  \n   [  \0   ]  \n   [  \0   ]
  0044657
  % git log --pretty=format:'[%x00]' |od -c
  0000000   [  \0   ]  \n   [  \0   ]  \n   [  \0   ]  \n   [  \0   ]  \n
  *
  0044640   [  \0   ]  \n   [  \0   ]  \n   [  \0   ]  \n   [  \0   ]
  0044657
  % git log --pretty=format:'[%x01]%w(0,0,1)' |od -c
  0000000   [ 001   ]  \n   [ 001   ]  \n   [ 001   ]  \n   [ 001   ]  \n
  *
  0044640   [ 001   ]  \n   [ 001   ]  \n   [ 001   ]  \n   [ 001   ]
  0044657

I used git 1.7.8.2.

  % git --version
  git version 1.7.8.2
-- 
Tanaka Akira

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

* Re: git-log --pretty=format:'[%x00]%w(0,0,1)' doesn't print NUL and "]"
  2011-12-29 18:41 git-log --pretty=format:'[%x00]%w(0,0,1)' doesn't print NUL and "]" Tanaka Akira
@ 2011-12-29 19:23 ` Jeff King
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2011-12-29 19:23 UTC (permalink / raw)
  To: Tanaka Akira; +Cc: git

On Fri, Dec 30, 2011 at 03:41:20AM +0900, Tanaka Akira wrote:

> I found that git-log doesn't print characters in --pretty option as follows.
> 
>   % git log --pretty=format:'[%x00]%w(0,0,1)' |od -c
>   0000000   [  \n   [  \n   [  \n   [  \n   [  \n   [  \n   [  \n   [  \n
>   *
>   0022320   [  \n   [  \n   [  \n   [
>   0022327
> 
> I think NUL and "]" should be printed.

I think there is a bug in strbuf_add_indented_text, which uses
strchrnul, even though a strbuf may contain literal NULs. Although one
could argue that trying to wrap a NUL is questionable (after all, what
is its character width?), the current behavior seems pretty wrong.

I think the whole wrapping callchain needs to be adjusted to handle
arbitrary bytes (there are also several checks in
strbuf_add_wrapped_text for NUL terminators).

-Peff

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

end of thread, other threads:[~2011-12-29 19:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-29 18:41 git-log --pretty=format:'[%x00]%w(0,0,1)' doesn't print NUL and "]" Tanaka Akira
2011-12-29 19:23 ` Jeff King

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