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

Re: git-log --pretty=format:'[%x00]%w(0,0,1)' doesn't print NUL and "]"

From
Jeff King <peff@peff.net>
Date
Dec 29, 2011, 19:23 UTC
Message-ID
<20111229192328.GA18723@sigill.intra.peff.net>
In-Reply-To
<CANjopZFqiy+Ai4u6QYYnza5J7A3NAt-f17yR9AsYok-g3Hbb3w@mail.gmail.com>
On Fri, Dec 30, 2011 at 03:41:20AM +0900, Tanaka Akira wrote:
Show 9 quoted lines
> 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
Previous: Tanaka Akira
Message 2 of 2 in “git-log --pretty=format:'[%x00]%w(0,0,1)' doesn't print NUL and "]"”
  1. Tanaka AkiraDec 29, 2011
  2. Jeff KingDec 29, 2011

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.