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

[PATCH 1/4] Clarify and correct -z

From
Björn Gustavsson <bgustavsson@gmail.com>
Date
Nov 22, 2009, 19:43 UTC
Message-ID
<4B099458.6000909@gmail.com>

The description for -z is too vague and general for the apply, diff*, and log commands.

Change the description of -z for 'git log' to note that commits will be separated by NULs.

Change the description of -z for 'git diff*' and 'git apply' to note that it applies to the --numstat option, and for 'git diff*' also for --raw option.

Also correct the description of the "munging" of pathanmes that takes place in the absence of -z for the 'git diff*' and 'git apply' commands, namely that apart from the characters mentioned, double quotes will also be escaped and that the pathname will be enclosed in double quotes if any characters are escaped.

Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
---
The original documentation for -z in diff-options.txt says:

"Also output from commands such as `git-log` will be delimited with NUL between commits."

I am not sure about "such as git-log". What other command would that be? In my patch, I have assumed that only 'git log' behaves in that way (i.e. that it is the only command -z will change the behavior of even when no other options are given).

 Documentation/diff-options.txt |   17 ++++++++++++++---
 Documentation/git-apply.txt    |   12 +++++++-----
 2 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 2b37193..18366b1 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -85,10 +85,21 @@ ifndef::git-format-patch[]
 endif::git-format-patch[]
 
 ifndef::git-format-patch[]
+
 -z::
-	NUL-line termination on output.  This affects the `--raw`
-	output field terminator.  Also output from commands such
-	as `git-log` will be delimited with NUL between commits.
+ifndef::git-log[]
+	When `--raw` or `--numstat` has been given, do not munge
+	pathnames and use NULs as output field terminators.
++
+Without this option, each pathname output will have TAB, LF, double quotes,
+and backslash characters replaced with `\t`, `\n`, `\"`, and `\\`,
+respectively, and the pathname will be enclosed in double quotes if
+any of those replacements occurred.
+endif::git-log[]
+
+ifdef::git-log[]
+	Separate the commits with NULs instead of with new newlines.
+endif::git-log[]
 
 --name-only::
 	Show only names of changed files.
diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt
index 5ee8c91..0156ca9 100644
--- a/Documentation/git-apply.txt
+++ b/Documentation/git-apply.txt
@@ -87,11 +87,13 @@ the information is read from the current index instead.
 	rejected hunks in corresponding *.rej files.
 
 -z::
-	When showing the index information, do not munge paths,
-	but use NUL terminated machine readable format.  Without
-	this flag, the pathnames output will have TAB, LF, and
-	backslash characters replaced with `\t`, `\n`, and `\\`,
-	respectively.
+	When `--numstat` has been given, do not munge pathnames,
+	but use a NUL-terminated machine-readable format.
++
+Without this option, each pathname output will have TAB, LF, double quotes,
+and backslash characters replaced with `\t`, `\n`, `\"`, and `\\`,
+respectively, and the pathname will be enclosed in double quotes if
+any of those replacements occurred.
 
 -p<n>::
 	Remove <n> leading slashes from traditional diff paths. The
-- 
1.6.5.3.298.g39add
Message 1 of 1 in “Clarify and correct -z”
  1. 1/4 Clarify and correct -zBjörn Gustavsson, Nov 22, 2009

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.