{"thread":{"id":"29264","subject":"git-log --pretty=format:'[%x00]%w(0,0,1)' doesn't print NUL and \"]\"","startedAt":"2011-12-29T18:41:20Z","lastAt":"2011-12-29T19:23:29Z","messageCount":2,"participants":["Tanaka Akira","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"181784","messageId":"CANjopZFqiy+Ai4u6QYYnza5J7A3NAt-f17yR9AsYok-g3Hbb3w@mail.gmail.com","threadId":"29264","inReplyTo":null,"subject":"git-log --pretty=format:'[%x00]%w(0,0,1)' doesn't print NUL and \"]\"","fromName":"Tanaka Akira","fromEmail":"akr@fsij.org","sentAt":"2011-12-29T18:41:20Z","receivedAt":"2011-12-29T18:41:20Z","isPatch":false,"sender":{"key":"akr@fsij.org","avatar":null},"body":"I found that git-log doesn't print characters in --pretty option as follows.\n\n  % git log --pretty=format:'[%x00]%w(0,0,1)' |od -c\n  0000000   [  \\n   [  \\n   [  \\n   [  \\n   [  \\n   [  \\n   [  \\n   [  \\n\n  *\n  0022320   [  \\n   [  \\n   [  \\n   [\n  0022327\n\nI think NUL and \"]\" should be printed.\n\nNote that git log works as I expected if I use %w(0,0,0) instead of %w(0,0,1),\nI don't use %w(0,0,1) or I use %x01 instead of %x00.\n\n  % git log --pretty=format:'[%x00]%w(0,0,0)' |od -c\n  0000000   [  \\0   ]  \\n   [  \\0   ]  \\n   [  \\0   ]  \\n   [  \\0   ]  \\n\n  *\n  0044640   [  \\0   ]  \\n   [  \\0   ]  \\n   [  \\0   ]  \\n   [  \\0   ]\n  0044657\n  % git log --pretty=format:'[%x00]' |od -c\n  0000000   [  \\0   ]  \\n   [  \\0   ]  \\n   [  \\0   ]  \\n   [  \\0   ]  \\n\n  *\n  0044640   [  \\0   ]  \\n   [  \\0   ]  \\n   [  \\0   ]  \\n   [  \\0   ]\n  0044657\n  % git log --pretty=format:'[%x01]%w(0,0,1)' |od -c\n  0000000   [ 001   ]  \\n   [ 001   ]  \\n   [ 001   ]  \\n   [ 001   ]  \\n\n  *\n  0044640   [ 001   ]  \\n   [ 001   ]  \\n   [ 001   ]  \\n   [ 001   ]\n  0044657\n\nI used git 1.7.8.2.\n\n  % git --version\n  git version 1.7.8.2\n-- \nTanaka Akira\n"},{"id":"181785","messageId":"20111229192328.GA18723@sigill.intra.peff.net","threadId":"29264","inReplyTo":"CANjopZFqiy+Ai4u6QYYnza5J7A3NAt-f17yR9AsYok-g3Hbb3w@mail.gmail.com","subject":"Re: git-log --pretty=format:'[%x00]%w(0,0,1)' doesn't print NUL and \"]\"","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-12-29T19:23:29Z","receivedAt":"2011-12-29T19:23:29Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Dec 30, 2011 at 03:41:20AM +0900, Tanaka Akira wrote:\n\n> I found that git-log doesn't print characters in --pretty option as follows.\n> \n>   % git log --pretty=format:'[%x00]%w(0,0,1)' |od -c\n>   0000000   [  \\n   [  \\n   [  \\n   [  \\n   [  \\n   [  \\n   [  \\n   [  \\n\n>   *\n>   0022320   [  \\n   [  \\n   [  \\n   [\n>   0022327\n> \n> I think NUL and \"]\" should be printed.\n\nI think there is a bug in strbuf_add_indented_text, which uses\nstrchrnul, even though a strbuf may contain literal NULs. Although one\ncould argue that trying to wrap a NUL is questionable (after all, what\nis its character width?), the current behavior seems pretty wrong.\n\nI think the whole wrapping callchain needs to be adjusted to handle\narbitrary bytes (there are also several checks in\nstrbuf_add_wrapped_text for NUL terminators).\n\n-Peff\n"}]}