From 64485b4aba98b39f2cf4528aed95b6ddca62f332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Sun, 22 Nov 2009 20:43:20 +0100 Subject: [PATCH 1/5] Clarify and correct -z MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- 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 2b37193a37..18366b1be6 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 5ee8c91f2d..0156ca9112 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:: Remove leading slashes from traditional diff paths. The From 38a39647b43ea57c96bd6e4a351d0d5353c805bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Sun, 22 Nov 2009 20:43:42 +0100 Subject: [PATCH 2/5] apply: apply works outside a repository MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The documentation for 'git apply' talks about applying a patch/diff to the index and to the working tree, which seems to imply that it will not work outside a git repository. Actually 'git patch' works outside a repository (which can be useful especially for applying binary or rename patches that the standard "patch" utility cannot handle), so the documentation should mention it. Thanks to Junio for suggesting better wording. Signed-off-by: Björn Gustavsson Signed-off-by: Junio C Hamano --- Documentation/git-apply.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt index 0156ca9112..0c55ca92e0 100644 --- a/Documentation/git-apply.txt +++ b/Documentation/git-apply.txt @@ -3,7 +3,7 @@ git-apply(1) NAME ---- -git-apply - Apply a patch on a git index file and/or a working tree +git-apply - Apply a patch to files and/or to the index SYNOPSIS @@ -20,8 +20,11 @@ SYNOPSIS DESCRIPTION ----------- -Reads supplied 'diff' output and applies it on a git index file -and a work tree. +Reads the supplied diff output (i.e. "a patch") and applies it to files. +With the `--index` option the patch is also applied to the index, and +with the `--cache` option the patch is only applied to the index. +Without these options, the command applies the patch only to files, +and does not require them to be in a git repository. OPTIONS ------- From f9821e2b2139e5e2fbe9fde3df58ddc98ae4ce19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Sun, 22 Nov 2009 20:43:53 +0100 Subject: [PATCH 3/5] apply: Format all options using back-quotes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Björn Gustavsson Signed-off-by: Junio C Hamano --- Documentation/git-apply.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt index 0c55ca92e0..6a07ec22a4 100644 --- a/Documentation/git-apply.txt +++ b/Documentation/git-apply.txt @@ -37,7 +37,7 @@ OPTIONS input. Turns off "apply". --numstat:: - Similar to \--stat, but shows the number of added and + Similar to `--stat`, but shows the number of added and deleted lines in decimal notation and the pathname without abbreviation, to make it more machine friendly. For binary files, outputs two `-` instead of saying @@ -55,7 +55,7 @@ OPTIONS file and detects errors. Turns off "apply". --index:: - When --check is in effect, or when applying the patch + When `--check` is in effect, or when applying the patch (which is the default when none of the options that disables it is in effect), make sure the patch is applicable to what the current index file records. If @@ -66,7 +66,7 @@ OPTIONS --cached:: Apply a patch without touching the working tree. Instead take the cached data, apply the patch, and store the result in the index - without using the working tree. This implies '--index'. + without using the working tree. This implies `--index`. --build-fake-ancestor=:: Newer 'git-diff' output has embedded 'index information' @@ -112,8 +112,8 @@ any of those replacements occurred. By default, 'git-apply' expects that the patch being applied is a unified diff with at least one line of context. This provides good safety measures, but breaks down when - applying a diff generated with --unified=0. To bypass these - checks use '--unidiff-zero'. + applying a diff generated with `--unified=0`. To bypass these + checks use `--unidiff-zero`. + Note, for the reasons stated above usage of context-free patches is discouraged. @@ -149,7 +149,7 @@ discouraged. be useful when importing patchsets, where you want to include certain files or directories. + -When --exclude and --include patterns are used, they are examined in the +When `--exclude` and `--include` patterns are used, they are examined in the order they appear on the command line, and the first match determines if a patch to each path is used. A patch to a path that does not match any include/exclude pattern is used by default if there is no include pattern @@ -232,13 +232,13 @@ Submodules If the patch contains any changes to submodules then 'git-apply' treats these changes as follows. -If --index is specified (explicitly or implicitly), then the submodule +If `--index` is specified (explicitly or implicitly), then the submodule commits must match the index exactly for the patch to apply. If any of the submodules are checked-out, then these check-outs are completely ignored, i.e., they are not required to be up-to-date or clean and they are not updated. -If --index is not specified, then the submodule commits in the patch +If `--index` is not specified, then the submodule commits in the patch are ignored and only the absence or presence of the corresponding subdirectory is checked and (if possible) updated. From c34ec65567793d16119c28df6ebeecfe8eb3d9f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Sun, 22 Nov 2009 20:53:29 +0100 Subject: [PATCH 4/5] apply: Use the term "working tree" consistently MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The documentation for 'git apply' uses both the terms "work tree" and "working tree". Since the glossary uses the term "working tree", change all occurrences of "work tree" to "working tree". Signed-off-by: Björn Gustavsson Signed-off-by: Junio C Hamano --- Documentation/git-apply.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt index 6a07ec22a4..c2528a7654 100644 --- a/Documentation/git-apply.txt +++ b/Documentation/git-apply.txt @@ -51,7 +51,7 @@ OPTIONS --check:: Instead of applying the patch, see if the patch is - applicable to the current work tree and/or the index + applicable to the current working tree and/or the index file and detects errors. Turns off "apply". --index:: @@ -59,7 +59,7 @@ OPTIONS (which is the default when none of the options that disables it is in effect), make sure the patch is applicable to what the current index file records. If - the file to be patched in the work tree is not + the file to be patched in the working tree is not up-to-date, it is flagged as an error. This flag also causes the index file to be updated. From 5c931c8da2db4a8e0b5713e97cce474b6596e2ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Mon, 23 Nov 2009 08:40:24 +0100 Subject: [PATCH 5/5] Fix over-simplified documentation for 'git log -z' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In commit 64485b4a, the documentation for 'git log -z' was simplified too much. The -z option actually changes the behavior of 'git log' in two ways: commits will be ended with a NUL instead of a LF (correctly documented) and the --raw and --numstat will have NUL as field terminators (omitted in the documentation for 'git log'). Signed-off-by: Björn Gustavsson Signed-off-by: Junio C Hamano --- Documentation/diff-options.txt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index 18366b1be6..8707d0e740 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -87,19 +87,21 @@ endif::git-format-patch[] ifndef::git-format-patch[] -z:: +ifdef::git-log[] + Separate the commits with NULs instead of with new newlines. ++ +Also, when `--raw` or `--numstat` has been given, do not munge +pathnames and use NULs as output field terminators. +endif::git-log[] ifndef::git-log[] When `--raw` or `--numstat` has been given, do not munge pathnames and use NULs as output field terminators. +endif::git-log[] + 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.