aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2019-12-06 13:08:21 +0000
committerJunio C Hamano <gitster@pobox.com>2019-12-06 08:57:34 -0800
commit24be352d52f96b2cace4d3e5f01f02917b7d649b (patch)
treec933564c7ccbb29558b4bedaf14605c52a5e7f0b
parent8539b465341cc475f219ed46273a1c157bddafa0 (diff)
downloadgit-24be352d52f96b2cace4d3e5f01f02917b7d649b.tar.xz
t3701: add a test for the different `add -p` prompts
The `git add -p` command offers different prompts for regular diff hunks vs mode change pseudo hunks vs diffs deleting files. Let's cover this in the regresion test suite, in preparation for re-implementing `git add -p` in C. For the mode change prompt, we use a trick that lets this test case pass even on systems without executable bit, i.e. where `core.filemode = false` (such as Windows): we first add the file to the index with `git add --chmod=+x`, and then call `git add -p` with `core.filemode` forced to `true`. The file on disk has no executable bit set, therefore we will see a mode change. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xt/t3701-add-interactive.sh19
1 files changed, 18 insertions, 1 deletions
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index 793ce28297..c90aaa25b0 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -105,7 +105,6 @@ test_expect_success 'revert works (commit)' '
grep "unchanged *+3/-0 file" output
'
-
test_expect_success 'setup expected' '
cat >expected <<-\EOF
EOF
@@ -274,6 +273,24 @@ test_expect_success FILEMODE 'stage mode and hunk' '
# end of tests disabled when filemode is not usable
+test_expect_success 'different prompts for mode change/deleted' '
+ git reset --hard &&
+ >file &&
+ >deleted &&
+ git add --chmod=+x file deleted &&
+ echo changed >file &&
+ rm deleted &&
+ test_write_lines n n n |
+ git -c core.filemode=true add -p >actual &&
+ sed -n "s/^\(([0-9/]*) Stage .*?\).*/\1/p" actual >actual.filtered &&
+ cat >expect <<-\EOF &&
+ (1/1) Stage deletion [y,n,q,a,d,?]?
+ (1/2) Stage mode change [y,n,q,a,d,j,J,g,/,?]?
+ (2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,?]?
+ EOF
+ test_cmp expect actual.filtered
+'
+
test_expect_success 'setup again' '
git reset --hard &&
test_chmod +x file &&