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
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-06-25 23:22:36 +0300
committerJunio C Hamano <gitster@pobox.com>2018-06-25 23:22:36 +0300
commitac997db0c13d3acde8fcb6c79ff095ba6bd27169 (patch)
tree3a1294218762ac16d06596c8ab3ac342103bfd99 /t/t2203-add-intent.sh
parenta856e7d69f51776e40633d6f1f1f38a7fd64f0d5 (diff)
parentcff5dc09ed0d07461bf77e9abef57dc86a11ab77 (diff)
Merge branch 'nd/diff-apply-ita'
"git diff" compares the index and the working tree. For paths added with intent-to-add bit, the command shows the full contents of them as added, but the paths themselves were not marked as new files. They are now shown as new by default. "git apply" learned the "--intent-to-add" option so that an otherwise working-tree-only application of a patch will add new paths to the index marked with the "intent-to-add" bit. * nd/diff-apply-ita: apply: add --intent-to-add t2203: add a test about "diff HEAD" case diff: turn --ita-invisible-in-index on by default diff: ignore --ita-[in]visible-in-index when diffing worktree-to-tree
Diffstat (limited to 't/t2203-add-intent.sh')
-rwxr-xr-xt/t2203-add-intent.sh64
1 files changed, 58 insertions, 6 deletions
diff --git a/t/t2203-add-intent.sh b/t/t2203-add-intent.sh
index 04d840a544..e7a400b4c7 100755
--- a/t/t2203-add-intent.sh
+++ b/t/t2203-add-intent.sh
@@ -70,8 +70,7 @@ test_expect_success 'i-t-a entry is simply ignored' '
git commit -m second &&
test $(git ls-tree HEAD -- nitfol | wc -l) = 0 &&
test $(git diff --name-only HEAD -- nitfol | wc -l) = 1 &&
- test $(git diff --name-only --ita-invisible-in-index HEAD -- nitfol | wc -l) = 0 &&
- test $(git diff --name-only --ita-invisible-in-index -- nitfol | wc -l) = 1
+ test $(git diff --name-only -- nitfol | wc -l) = 1
'
test_expect_success 'can commit with an unrelated i-t-a entry in index' '
@@ -99,13 +98,13 @@ test_expect_success 'cache-tree invalidates i-t-a paths' '
: >dir/bar &&
git add -N dir/bar &&
- git diff --cached --name-only >actual &&
+ git diff --name-only >actual &&
echo dir/bar >expect &&
test_cmp expect actual &&
git write-tree >/dev/null &&
- git diff --cached --name-only >actual &&
+ git diff --name-only >actual &&
echo dir/bar >expect &&
test_cmp expect actual
'
@@ -186,7 +185,19 @@ test_expect_success 'rename detection finds the right names' '
cat >expected.3 <<-EOF &&
2 .R N... 100644 100644 100644 $hash $hash R100 third first
EOF
- test_cmp expected.3 actual.3
+ test_cmp expected.3 actual.3 &&
+
+ git diff --stat >actual.4 &&
+ cat >expected.4 <<-EOF &&
+ first => third | 0
+ 1 file changed, 0 insertions(+), 0 deletions(-)
+ EOF
+ test_cmp expected.4 actual.4 &&
+
+ git diff --cached --stat >actual.5 &&
+ : >expected.5 &&
+ test_cmp expected.5 actual.5
+
)
'
@@ -222,5 +233,46 @@ test_expect_success 'double rename detection in status' '
)
'
-test_done
+test_expect_success 'diff-files/diff-cached shows ita as new/not-new files' '
+ git reset --hard &&
+ echo new >new-ita &&
+ git add -N new-ita &&
+ git diff --summary >actual &&
+ echo " create mode 100644 new-ita" >expected &&
+ test_cmp expected actual &&
+ git diff --cached --summary >actual2 &&
+ : >expected2 &&
+ test_cmp expected2 actual2
+'
+
+test_expect_success '"diff HEAD" includes ita as new files' '
+ git reset --hard &&
+ echo new >new-ita &&
+ git add -N new-ita &&
+ git diff HEAD >actual &&
+ cat >expected <<-\EOF &&
+ diff --git a/new-ita b/new-ita
+ new file mode 100644
+ index 0000000..3e75765
+ --- /dev/null
+ +++ b/new-ita
+ @@ -0,0 +1 @@
+ +new
+ EOF
+ test_cmp expected actual
+'
+
+test_expect_success 'apply --intent-to-add' '
+ git reset --hard &&
+ echo new >new-ita &&
+ git add -N new-ita &&
+ git diff >expected &&
+ grep "new file" expected &&
+ git reset --hard &&
+ git apply --intent-to-add expected &&
+ git diff >actual &&
+ test_cmp expected actual
+'
+
+test_done