diff options
| author | Leon Michalak <leonmichalak6@gmail.com> | 2025-07-29 07:01:50 +0000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-07-29 08:52:45 -0700 |
| commit | 2b0a2db2c0bf4870592656e8f50876957db8660c (patch) | |
| tree | 0a135457df2cec75e8bc75c44ef37f885db5f24f /t/t3701-add-interactive.sh | |
| parent | t: use test_config in t4055 (diff) | |
| download | git-2b0a2db2c0bf4870592656e8f50876957db8660c.tar.gz git-2b0a2db2c0bf4870592656e8f50876957db8660c.zip | |
add-patch: respect diff.context configuration
Various builtins that use add-patch infrastructure do not respect
the user's diff.context and diff.interHunkContext file configurations.
The user may be used to seeing their diffs with customized context size,
but not in the patches "git add -p" shows them to pick from.
Teach add-patch infrastructure to read these configuration variables and
pass their values when spawning the underlying plumbing commands as
their command line option.
Signed-off-by: Leon Michalak <leonmichalak6@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3701-add-interactive.sh')
| -rwxr-xr-x | t/t3701-add-interactive.sh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index b088ee141f..18dc329ea1 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -1230,4 +1230,26 @@ test_expect_success 'hunk splitting works with diff.suppressBlankEmpty' ' test_cmp expect actual ' +test_expect_success 'add -p respects diff.context' ' + test_write_lines a b c d e f g h i j k l m >file && + git add file && + test_write_lines a b c d e f G h i j k l m >file && + echo y | git -c diff.context=5 add -p >actual && + test_grep "@@ -2,11 +2,11 @@" actual +' + +test_expect_success 'add -p respects diff.interHunkContext' ' + test_write_lines a b c d e f g h i j k l m n o p q r s >file && + git add file && + test_write_lines a b c d E f g i i j k l m N o p q r s >file && + echo y | git -c diff.interhunkcontext=2 add -p >actual && + test_grep "@@ -2,16 +2,16 @@" actual +' + +test_expect_success 'add -p rejects negative diff.context' ' + test_config diff.context -1 && + test_must_fail git add -p 2>output && + test_grep "diff.context cannot be negative" output +' + test_done |
