Thread (158 messages) 158 messages, 7 authors, 2021-04-09

[PATCH 2/2] diff: test and document -W interaction with -U<n>

flat view
STALE2008d

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2021-02-15 16:05:05
Subsystem: documentation, the rest · Maintainers: Jonathan Corbet, Linus Torvalds

Revision v2 of 3 in this series.

Revisions (3)
  1. v1 [diff vs current]
  2. v2 current
  3. v2
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
 Documentation/diff-options.txt | 8 ++++++++
 t/t4018-diff-funcname.sh       | 5 +++++
 2 files changed, 13 insertions(+)
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 8ca59effa7..3c19c78616 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -88,6 +88,11 @@ endif::git-log[]
 --unified=<n>::
 	Generate diffs with <n> lines of context instead of
 	the usual three.
++
+Under `-W` generates diffs with at least <n> lines of context, if the
+number is lower than the context `-U<n>` would extend the diff to then
+`-U<n>` takes precedence.
+
 ifndef::git-format-patch[]
 	Implies `--patch`.
 endif::git-format-patch[]
@@ -763,6 +768,9 @@ endif::git-format-patch[]
 When showing the whole function for context the "@@" context line
 itself will always be empty, since the context that would otherwise be
 shown there will be the first line of the hunk being shown.
++
+See the documentation for `-U<n>` above for how the two options
+interact.
 
 ifndef::git-format-patch[]
 ifndef::git-log[]
diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
index f3374abd98..38dc029917 100755
--- a/t/t4018-diff-funcname.sh
+++ b/t/t4018-diff-funcname.sh
@@ -98,6 +98,11 @@ test_diff_funcname () {
 		test_cmp W-U0-expected W-U0-actual
 	' &&
 
+	test_expect_success "$desc -W interaction with -U<n>" '
+		git diff -U9001 "$what" >W-U9001-diff &&
+		grep "^@@ -1," W-U9001-diff
+	' &&
+
 	test_expect_success "$desc (accumulated)" '
 		git diff -U1 "$what".acc >diff &&
 		last_diff_context_line diff >actual.lines &&
-- 
2.30.0.284.gd98b1dd5eaa7
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help