Skip to content

Commit 91af7ae

Browse files
committed
core.whitespace: documentation updates.
This adds description of core.whitespace to the manual page of git-config, and updates the stale description of whitespace handling in the manual page of git-apply. Also demote "strip" to a synonym status for "fix" as the value of --whitespace option given to git-apply. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent d5a4164 commit 91af7ae

File tree

3 files changed

+38
-17
lines changed

3 files changed

+38
-17
lines changed

Documentation/config.txt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,20 @@ core.pager::
293293
The command that git will use to paginate output. Can be overridden
294294
with the `GIT_PAGER` environment variable.
295295

296+
core.whitespace::
297+
A comma separated list of common whitespace problems to
298+
notice. `git diff` will use `color.diff.whitespace` to
299+
highlight them, and `git apply --whitespace=error` will
300+
consider them as errors:
301+
+
302+
* `trailing-space` treats trailing whitespaces at the end of the line
303+
as an error (enabled by default).
304+
* `space-before-tab` treats a space character that appears immediately
305+
before a tab character in the initial indent part of the line as an
306+
error (enabled by default).
307+
* `indent-with-non-tab` treats a line that is indented with 8 or more
308+
space characters that can be replaced with tab characters.
309+
296310
alias.*::
297311
Command aliases for the gitlink:git[1] command wrapper - e.g.
298312
after defining "alias.last = cat-file commit HEAD", the invocation
@@ -378,8 +392,8 @@ color.diff.<slot>::
378392
which part of the patch to use the specified color, and is one
379393
of `plain` (context text), `meta` (metainformation), `frag`
380394
(hunk header), `old` (removed lines), `new` (added lines),
381-
`commit` (commit headers), or `whitespace` (highlighting dubious
382-
whitespace). The values of these variables may be specified as
395+
`commit` (commit headers), or `whitespace` (highlighting
396+
whitespace errors). The values of these variables may be specified as
383397
in color.branch.<slot>.
384398

385399
color.pager::

Documentation/git-apply.txt

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ SYNOPSIS
1313
[--apply] [--no-add] [--build-fake-ancestor <file>] [-R | --reverse]
1414
[--allow-binary-replacement | --binary] [--reject] [-z]
1515
[-pNUM] [-CNUM] [--inaccurate-eof] [--cached]
16-
[--whitespace=<nowarn|warn|error|error-all|strip>]
16+
[--whitespace=<nowarn|warn|fix|error|error-all>]
1717
[--exclude=PATH] [--verbose] [<patch>...]
1818

1919
DESCRIPTION
@@ -135,25 +135,32 @@ discouraged.
135135
be useful when importing patchsets, where you want to exclude certain
136136
files or directories.
137137

138-
--whitespace=<option>::
139-
When applying a patch, detect a new or modified line
140-
that ends with trailing whitespaces (this includes a
141-
line that solely consists of whitespaces). By default,
142-
the command outputs warning messages and applies the
143-
patch.
144-
When gitlink:git-apply[1] is used for statistics and not applying a
145-
patch, it defaults to `nowarn`.
146-
You can use different `<option>` to control this
147-
behavior:
138+
--whitespace=<action>::
139+
When applying a patch, detect a new or modified line that has
140+
whitespace errors. What are considered whitespace errors is
141+
controlled by `core.whitespace` configuration. By default,
142+
trailing whitespaces (including lines that solely consist of
143+
whitespaces) and a space character that is immediately followed
144+
by a tab character inside the initial indent of the line are
145+
considered whitespace errors.
146+
+
147+
By default, the command outputs warning messages but applies the patch.
148+
When gitlink:git-apply[1] is used for statistics and not applying a
149+
patch, it defaults to `nowarn`.
150+
+
151+
You can use different `<action>` to control this
152+
behavior:
148153
+
149154
* `nowarn` turns off the trailing whitespace warning.
150155
* `warn` outputs warnings for a few such errors, but applies the
151-
patch (default).
156+
patch as-is (default).
157+
* `fix` outputs warnings for a few such errors, and applies the
158+
patch after fixing them (`strip` is a synonym --- the tool
159+
used to consider only trailing whitespaces as errors, and the
160+
fix involved 'stripping' them, but modern gits do more).
152161
* `error` outputs warnings for a few such errors, and refuses
153162
to apply the patch.
154163
* `error-all` is similar to `error` but shows all errors.
155-
* `strip` outputs warnings for a few such errors, strips out the
156-
trailing whitespaces and applies the patch.
157164

158165
--inaccurate-eof::
159166
Under certain circumstances, some versions of diff do not correctly

builtin-apply.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static const char *fake_ancestor;
4545
static int line_termination = '\n';
4646
static unsigned long p_context = ULONG_MAX;
4747
static const char apply_usage[] =
48-
"git-apply [--stat] [--numstat] [--summary] [--check] [--index] [--cached] [--apply] [--no-add] [--index-info] [--allow-binary-replacement] [--reverse] [--reject] [--verbose] [-z] [-pNUM] [-CNUM] [--whitespace=<nowarn|warn|error|error-all|strip>] <patch>...";
48+
"git-apply [--stat] [--numstat] [--summary] [--check] [--index] [--cached] [--apply] [--no-add] [--index-info] [--allow-binary-replacement] [--reverse] [--reject] [--verbose] [-z] [-pNUM] [-CNUM] [--whitespace=<nowarn|warn|fix|error|error-all>] <patch>...";
4949

5050
static enum ws_error_action {
5151
nowarn_ws_error,

0 commit comments

Comments
 (0)