Skip to content

Commit 8a19dfa

Browse files
tgummerergitster
authored andcommitted
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>
1 parent 6df5762 commit 8a19dfa

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

t/t4053-diff-no-index.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,15 @@ test_expect_success 'git diff outside repo with broken index' '
4444
)
4545
'
4646

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+
4758
test_done

0 commit comments

Comments
 (0)