Skip to content

Commit

Permalink
diff: add test for --no-index executed outside repo
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Thomas Gummerer authored and Junio C Hamano committed Dec 16, 2013
1 parent 6df5762 commit 8a19dfa
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions t/t4053-diff-no-index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,15 @@ test_expect_success 'git diff outside repo with broken index' '
)
'

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

0 comments on commit 8a19dfa

Please sign in to comment.