Imported Upstream version 2.13.5
[platform/upstream/git.git] / t / t4053-diff-no-index.sh
index 596dfe7..453e6c3 100755 (executable)
@@ -17,8 +17,8 @@ test_expect_success 'setup' '
 '
 
 test_expect_success 'git diff --no-index directories' '
-       git diff --no-index a b >cnt
-       test $? = 1 && test_line_count = 14 cnt
+       test_expect_code 1 git diff --no-index a b >cnt &&
+       test_line_count = 14 cnt
 '
 
 test_expect_success 'git diff --no-index relative path outside repo' '
@@ -89,4 +89,42 @@ test_expect_success 'turning a file into a directory' '
        )
 '
 
+test_expect_success 'diff from repo subdir shows real paths (explicit)' '
+       echo "diff --git a/../../non/git/a b/../../non/git/b" >expect &&
+       test_expect_code 1 \
+               git -C repo/sub \
+               diff --no-index ../../non/git/a ../../non/git/b >actual &&
+       head -n 1 <actual >actual.head &&
+       test_cmp expect actual.head
+'
+
+test_expect_success 'diff from repo subdir shows real paths (implicit)' '
+       echo "diff --git a/../../non/git/a b/../../non/git/b" >expect &&
+       test_expect_code 1 \
+               git -C repo/sub \
+               diff ../../non/git/a ../../non/git/b >actual &&
+       head -n 1 <actual >actual.head &&
+       test_cmp expect actual.head
+'
+
+test_expect_success 'diff --no-index from repo subdir respects config (explicit)' '
+       echo "diff --git ../../non/git/a ../../non/git/b" >expect &&
+       test_config -C repo diff.noprefix true &&
+       test_expect_code 1 \
+               git -C repo/sub \
+               diff --no-index ../../non/git/a ../../non/git/b >actual &&
+       head -n 1 <actual >actual.head &&
+       test_cmp expect actual.head
+'
+
+test_expect_success 'diff --no-index from repo subdir respects config (implicit)' '
+       echo "diff --git ../../non/git/a ../../non/git/b" >expect &&
+       test_config -C repo diff.noprefix true &&
+       test_expect_code 1 \
+               git -C repo/sub \
+               diff ../../non/git/a ../../non/git/b >actual &&
+       head -n 1 <actual >actual.head &&
+       test_cmp expect actual.head
+'
+
 test_done