Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-08-18 03:02:46 +0300
committerJunio C Hamano <gitster@pobox.com>2020-08-18 03:02:46 +0300
commitca81676a105dbd387c28fbcc428e8959990678ec (patch)
tree7a2fc7d8b19afd1cd616c4b54936cca96c325b4f /t
parent47f0f94bc796037c43000a9852cdf9209a3c3274 (diff)
parent4c025c667ee29dd5e9260f423e8b0b3cc37e5e8c (diff)
Merge branch 'rp/apply-cached-with-i-t-a'
Recent versions of "git diff-files" shows a diff between the index and the working tree for "intent-to-add" paths as a "new file" patch; "git apply --cached" should be able to take "git diff-files" and should act as an equivalent to "git add" for the path, but the command failed to do so for such a path. * rp/apply-cached-with-i-t-a: t4140: test apply with i-t-a paths apply: make i-t-a entries never match worktree apply: allow "new file" patches on i-t-a entries
Diffstat (limited to 't')
-rwxr-xr-xt/t4140-apply-ita.sh56
1 files changed, 56 insertions, 0 deletions
diff --git a/t/t4140-apply-ita.sh b/t/t4140-apply-ita.sh
new file mode 100755
index 0000000000..c614eaf04c
--- /dev/null
+++ b/t/t4140-apply-ita.sh
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+test_description='git apply of i-t-a file'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+ test_write_lines 1 2 3 4 5 >blueprint &&
+
+ cat blueprint >test-file &&
+ git add -N test-file &&
+ git diff >creation-patch &&
+ grep "new file mode 100644" creation-patch &&
+
+ rm -f test-file &&
+ git diff >deletion-patch &&
+ grep "deleted file mode 100644" deletion-patch
+'
+
+test_expect_success 'apply creation patch to ita path (--cached)' '
+ git rm -f test-file &&
+ cat blueprint >test-file &&
+ git add -N test-file &&
+
+ git apply --cached creation-patch &&
+ git cat-file blob :test-file >actual &&
+ test_cmp blueprint actual
+'
+
+test_expect_success 'apply creation patch to ita path (--index)' '
+ git rm -f test-file &&
+ cat blueprint >test-file &&
+ git add -N test-file &&
+ rm -f test-file &&
+
+ test_must_fail git apply --index creation-patch
+'
+
+test_expect_success 'apply deletion patch to ita path (--cached)' '
+ git rm -f test-file &&
+ cat blueprint >test-file &&
+ git add -N test-file &&
+
+ git apply --cached deletion-patch &&
+ test_must_fail git ls-files --stage --error-unmatch test-file
+'
+
+test_expect_success 'apply deletion patch to ita path (--index)' '
+ cat blueprint >test-file &&
+ git add -N test-file &&
+
+ test_must_fail git apply --index deletion-patch &&
+ git ls-files --stage --error-unmatch test-file
+'
+
+test_done