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>

Thomas Gummerer committed Dec 16, 2013 at 21:19 UTC 8a19dfa1aa5bbbc6e3ea8553e418ad4f78448cb3
1 file changed +11
t/t4053-diff-no-index.sh
+11
@@ -44,4 +44,15 @@ test_expect_success 'git diff outside repo with broken index' '
44 )
45 '
46
47 +test_expect_success 'git diff --no-index executed outside repo gives correct error message' '
48 + (
49 + GIT_CEILING_DIRECTORIES=$TRASH_DIRECTORY/non &&
50 + export GIT_CEILING_DIRECTORIES &&
51 + cd non/git &&
52 + test_must_fail git diff --no-index a 2>actual.err &&
53 + echo "usage: git diff --no-index <path> <path>" >expect.err &&
54 + test_cmp expect.err actual.err
55 + )
56 +'
57 +
58 test_done