1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-01 06:47:52 +01:00
git/t/t4053-diff-no-index.sh
Thomas Gummerer 8a19dfa1aa diff: add test for --no-index executed outside repo
470faf9 diff: move no-index detection to builtin/diff.c breaks the error
message for "git diff --no-index", when the command is executed outside
of a git repository and the wrong number of arguments are given. 6df5762
diff: don't read index when --no-index is given fixes the problem.

Add a test to guard against similar breakages in the future.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-12-16 13:12:33 -08:00

58 lines
1.2 KiB
Bash
Executable file

#!/bin/sh
test_description='diff --no-index'
. ./test-lib.sh
test_expect_success 'setup' '
mkdir a &&
mkdir b &&
echo 1 >a/1 &&
echo 2 >a/2 &&
git init repo &&
echo 1 >repo/a &&
mkdir -p non/git &&
echo 1 >non/git/a &&
echo 1 >non/git/b
'
test_expect_success 'git diff --no-index directories' '
git diff --no-index a b >cnt
test $? = 1 && test_line_count = 14 cnt
'
test_expect_success 'git diff --no-index relative path outside repo' '
(
cd repo &&
test_expect_code 0 git diff --no-index a ../non/git/a &&
test_expect_code 0 git diff --no-index ../non/git/a ../non/git/b
)
'
test_expect_success 'git diff --no-index with broken index' '
(
cd repo &&
echo broken >.git/index &&
git diff --no-index a ../non/git/a
)
'
test_expect_success 'git diff outside repo with broken index' '
(
cd repo &&
git diff ../non/git/a ../non/git/b
)
'
test_expect_success 'git diff --no-index executed outside repo gives correct error message' '
(
GIT_CEILING_DIRECTORIES=$TRASH_DIRECTORY/non &&
export GIT_CEILING_DIRECTORIES &&
cd non/git &&
test_must_fail git diff --no-index a 2>actual.err &&
echo "usage: git diff --no-index <path> <path>" >expect.err &&
test_cmp expect.err actual.err
)
'
test_done