Re: [PATCH 3/3] Do not create commits whose message contains NUL
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:52:38
Nguyễn Thái Ngọc Duy [off-list ref] writes:
We assume that the commit log messages are uninterpreted sequences of non-NUL bytes (see Documentation/i18n.txt). However the assumption does not really stand out and it's quite easy to set an editor to save in a NUL-included encoding. Currently we silently cut at the first NUL we see. Make it more obvious that NUL is not welcome by refusing to create such commits. Those who deliberately want to create them can still do with hash-object. Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
Limiting the Porcelain layer to deal only with reasonable text encodings (yes, I am declaring that utf16 is not among them) is perfectly fine, but I was somehow hoping that you would allow the option for the low-level function commit_tree() to create a commit object with binary blob in the body part, especially after seeing the patch 1/3 to do so. Certainly that kind of usage would not give the binary blob literally in "git log" output, but it is with or without the issue around NUL byte. A custom program linked with commit.c to call commit_tree() may not be using the data structure to store anything that is meant to be read by "git log" to begin with. Not a strong veto at all, just throwing out something to think about.