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>2021-03-31 00:35:37 +0300
committerJunio C Hamano <gitster@pobox.com>2021-03-31 00:35:37 +0300
commitb2309ad822500ba2c1088800b369851fad261e77 (patch)
tree494ef087bb4dab577c2bcc72374db3a8e207dfc2 /t
parentad16f748f22c82d096664f15f1a1c7fcc361cfe3 (diff)
parent2be927f3d1c64217ac5f4d3139ad73c1f59c173b (diff)
Merge branch 'ab/diff-no-index-tests'
More test coverage over "diff --no-index". * ab/diff-no-index-tests: diff --no-index tests: test mode normalization diff --no-index tests: add test for --exit-code
Diffstat (limited to 't')
-rwxr-xr-xt/t4053-diff-no-index.sh60
1 files changed, 60 insertions, 0 deletions
diff --git a/t/t4053-diff-no-index.sh b/t/t4053-diff-no-index.sh
index 0168946b63..3feadf0e35 100755
--- a/t/t4053-diff-no-index.sh
+++ b/t/t4053-diff-no-index.sh
@@ -16,6 +16,11 @@ test_expect_success 'setup' '
echo 1 >non/git/b
'
+test_expect_success 'git diff --no-index --exit-code' '
+ git diff --no-index --exit-code a/1 non/git/a &&
+ test_expect_code 1 git diff --no-index --exit-code a/1 a/2
+'
+
test_expect_success 'git diff --no-index directories' '
test_expect_code 1 git diff --no-index a b >cnt &&
test_line_count = 14 cnt
@@ -144,4 +149,59 @@ test_expect_success 'diff --no-index allows external diff' '
test_cmp expect actual
'
+test_expect_success 'diff --no-index normalizes mode: no changes' '
+ echo foo >x &&
+ cp x y &&
+ git diff --no-index x y >out &&
+ test_must_be_empty out
+'
+
+test_expect_success POSIXPERM 'diff --no-index normalizes mode: chmod +x' '
+ chmod +x y &&
+ cat >expected <<-\EOF &&
+ diff --git a/x b/y
+ old mode 100644
+ new mode 100755
+ EOF
+ test_expect_code 1 git diff --no-index x y >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success POSIXPERM 'diff --no-index normalizes: mode not like git mode' '
+ chmod 666 x &&
+ chmod 777 y &&
+ cat >expected <<-\EOF &&
+ diff --git a/x b/y
+ old mode 100644
+ new mode 100755
+ EOF
+ test_expect_code 1 git diff --no-index x y >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success POSIXPERM,SYMLINKS 'diff --no-index normalizes: mode not like git mode (symlink)' '
+ ln -s y z &&
+ X_OID=$(git hash-object --stdin <x) &&
+ Z_OID=$(printf y | git hash-object --stdin) &&
+ cat >expected <<-EOF &&
+ diff --git a/x b/x
+ deleted file mode 100644
+ index $X_OID..$ZERO_OID
+ --- a/x
+ +++ /dev/null
+ @@ -1 +0,0 @@
+ -foo
+ diff --git a/z b/z
+ new file mode 120000
+ index $ZERO_OID..$Z_OID
+ --- /dev/null
+ +++ b/z
+ @@ -0,0 +1 @@
+ +y
+ \ No newline at end of file
+ EOF
+ test_expect_code 1 git -c core.abbrev=no diff --no-index x z >actual &&
+ test_cmp expected actual
+'
+
test_done