Skip to content

Commit 4f6a803

Browse files
Tian Yuchengitster
authored andcommitted
diff: document -U without <n> as using default context
The documentation for '-U<n>' implies that the numeric value '<n>' is mandatory. However, the command line parser has historically accepted '-U' without a number. Strictly requiring a number for '-U' would break existing tests (e.g., in 't4013') and likely disrupt user scripts relying on this undocumented behavior. Hence we retain this fallback behavior for backward compatibility, but document it as such. Signed-off-by: Tian Yuchen <cat@malon.dev> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 67ad421 commit 4f6a803

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

Documentation/diff-context-options.adoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
`-U<n>`::
22
`--unified=<n>`::
3-
Generate diffs with _<n>_ lines of context. Defaults to `diff.context`
4-
or 3 if the config option is unset.
3+
Generate diffs with _<n>_ lines of context. The number of context
4+
lines defaults to `diff.context` or 3 if the configuration variable
5+
is unset. (`-U` without `<n>` is silently accepted as a synonym for
6+
`-p` due to a historical accident).
57

68
`--inter-hunk-context=<n>`::
79
Show the context between diff hunks, up to the specified _<number>_

Documentation/diff-options.adoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,10 @@ endif::git-log[]
127127

128128
`-U<n>`::
129129
`--unified=<n>`::
130-
Generate diffs with _<n>_ lines of context instead of
131-
the usual three.
130+
Generate diffs with _<n>_ lines of context. The number of context
131+
lines defaults to `diff.context` or 3 if the configuration variable
132+
is unset. (`-U` without `<n>` is silently accepted as a synonym for
133+
`-p` due to a historical accident).
132134
ifndef::git-format-patch[]
133135
Implies `--patch`.
134136
endif::git-format-patch[]

0 commit comments

Comments
 (0)