Skip to content

Commit d2cd665

Browse files
committed
Merge branch 'bg/apply-doc'
* bg/apply-doc: Fix over-simplified documentation for 'git log -z' apply: Use the term "working tree" consistently apply: Format all options using back-quotes apply: apply works outside a repository Clarify and correct -z
2 parents 444e10d + 5c931c8 commit d2cd665

File tree

2 files changed

+39
-21
lines changed

2 files changed

+39
-21
lines changed

Documentation/diff-options.txt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,23 @@ ifndef::git-format-patch[]
8585
endif::git-format-patch[]
8686

8787
ifndef::git-format-patch[]
88+
8889
-z::
89-
NUL-line termination on output. This affects the `--raw`
90-
output field terminator. Also output from commands such
91-
as `git-log` will be delimited with NUL between commits.
90+
ifdef::git-log[]
91+
Separate the commits with NULs instead of with new newlines.
92+
+
93+
Also, when `--raw` or `--numstat` has been given, do not munge
94+
pathnames and use NULs as output field terminators.
95+
endif::git-log[]
96+
ifndef::git-log[]
97+
When `--raw` or `--numstat` has been given, do not munge
98+
pathnames and use NULs as output field terminators.
99+
endif::git-log[]
100+
+
101+
Without this option, each pathname output will have TAB, LF, double quotes,
102+
and backslash characters replaced with `\t`, `\n`, `\"`, and `\\`,
103+
respectively, and the pathname will be enclosed in double quotes if
104+
any of those replacements occurred.
92105

93106
--name-only::
94107
Show only names of changed files.

Documentation/git-apply.txt

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ git-apply(1)
33

44
NAME
55
----
6-
git-apply - Apply a patch on a git index file and/or a working tree
6+
git-apply - Apply a patch to files and/or to the index
77

88

99
SYNOPSIS
@@ -20,8 +20,11 @@ SYNOPSIS
2020

2121
DESCRIPTION
2222
-----------
23-
Reads supplied 'diff' output and applies it on a git index file
24-
and a work tree.
23+
Reads the supplied diff output (i.e. "a patch") and applies it to files.
24+
With the `--index` option the patch is also applied to the index, and
25+
with the `--cache` option the patch is only applied to the index.
26+
Without these options, the command applies the patch only to files,
27+
and does not require them to be in a git repository.
2528

2629
OPTIONS
2730
-------
@@ -34,7 +37,7 @@ OPTIONS
3437
input. Turns off "apply".
3538

3639
--numstat::
37-
Similar to \--stat, but shows the number of added and
40+
Similar to `--stat`, but shows the number of added and
3841
deleted lines in decimal notation and the pathname without
3942
abbreviation, to make it more machine friendly. For
4043
binary files, outputs two `-` instead of saying
@@ -48,22 +51,22 @@ OPTIONS
4851

4952
--check::
5053
Instead of applying the patch, see if the patch is
51-
applicable to the current work tree and/or the index
54+
applicable to the current working tree and/or the index
5255
file and detects errors. Turns off "apply".
5356

5457
--index::
55-
When --check is in effect, or when applying the patch
58+
When `--check` is in effect, or when applying the patch
5659
(which is the default when none of the options that
5760
disables it is in effect), make sure the patch is
5861
applicable to what the current index file records. If
59-
the file to be patched in the work tree is not
62+
the file to be patched in the working tree is not
6063
up-to-date, it is flagged as an error. This flag also
6164
causes the index file to be updated.
6265

6366
--cached::
6467
Apply a patch without touching the working tree. Instead take the
6568
cached data, apply the patch, and store the result in the index
66-
without using the working tree. This implies '--index'.
69+
without using the working tree. This implies `--index`.
6770

6871
--build-fake-ancestor=<file>::
6972
Newer 'git-diff' output has embedded 'index information'
@@ -87,11 +90,13 @@ the information is read from the current index instead.
8790
rejected hunks in corresponding *.rej files.
8891

8992
-z::
90-
When showing the index information, do not munge paths,
91-
but use NUL terminated machine readable format. Without
92-
this flag, the pathnames output will have TAB, LF, and
93-
backslash characters replaced with `\t`, `\n`, and `\\`,
94-
respectively.
93+
When `--numstat` has been given, do not munge pathnames,
94+
but use a NUL-terminated machine-readable format.
95+
+
96+
Without this option, each pathname output will have TAB, LF, double quotes,
97+
and backslash characters replaced with `\t`, `\n`, `\"`, and `\\`,
98+
respectively, and the pathname will be enclosed in double quotes if
99+
any of those replacements occurred.
95100

96101
-p<n>::
97102
Remove <n> leading slashes from traditional diff paths. The
@@ -107,8 +112,8 @@ the information is read from the current index instead.
107112
By default, 'git-apply' expects that the patch being
108113
applied is a unified diff with at least one line of context.
109114
This provides good safety measures, but breaks down when
110-
applying a diff generated with --unified=0. To bypass these
111-
checks use '--unidiff-zero'.
115+
applying a diff generated with `--unified=0`. To bypass these
116+
checks use `--unidiff-zero`.
112117
+
113118
Note, for the reasons stated above usage of context-free patches is
114119
discouraged.
@@ -144,7 +149,7 @@ discouraged.
144149
be useful when importing patchsets, where you want to include certain
145150
files or directories.
146151
+
147-
When --exclude and --include patterns are used, they are examined in the
152+
When `--exclude` and `--include` patterns are used, they are examined in the
148153
order they appear on the command line, and the first match determines if a
149154
patch to each path is used. A patch to a path that does not match any
150155
include/exclude pattern is used by default if there is no include pattern
@@ -227,13 +232,13 @@ Submodules
227232
If the patch contains any changes to submodules then 'git-apply'
228233
treats these changes as follows.
229234

230-
If --index is specified (explicitly or implicitly), then the submodule
235+
If `--index` is specified (explicitly or implicitly), then the submodule
231236
commits must match the index exactly for the patch to apply. If any
232237
of the submodules are checked-out, then these check-outs are completely
233238
ignored, i.e., they are not required to be up-to-date or clean and they
234239
are not updated.
235240

236-
If --index is not specified, then the submodule commits in the patch
241+
If `--index` is not specified, then the submodule commits in the patch
237242
are ignored and only the absence or presence of the corresponding
238243
subdirectory is checked and (if possible) updated.
239244

0 commit comments

Comments
 (0)