[PATCH 1/2] diff: add test for --no-index executed outside repo
- From
Thomas Gummerer <t.gummerer@gmail.com>
- Date
- Dec 16, 2013, 19:23 UTC
- Message-ID
- <1387221810-32374-1-git-send-email-t.gummerer@gmail.com>
- In-Reply-To
- <xmqqtxe8pu05.fsf@gitster.dls.corp.google.com>
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> ---
Show 5 quoted lines
>> Thanks, I've missed that one. It only happens when run outside a git >> repository, but the same comments still apply. Will fix and send a >> re-roll. > > Please don't, as the last round has already been pushed on 'next'.
Sorry about that, should have checked first.
> An incremental change on top would also illustrate more clearly what > breakage needed to be fixed, which would be another good thing. It > could even come with a new test that makes sure that the above > command line is diagnosed correctly as a mistake ;-).
The breakage is actually fixed with the second patch as described in the commit message above, so here is just a test against future breakages. This test only works when the test root is outside of a git repository, as otherwise nongit will not be set. Is there another way to write it?
t/t4053-diff-no-index.sh | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/t/t4053-diff-no-index.sh b/t/t4053-diff-no-index.sh index 077c775..eb4f380 100755 --- a/t/t4053-diff-no-index.sh +++ b/t/t4053-diff-no-index.sh @@ -44,4 +44,11 @@ test_expect_success 'git diff outside repo with broken index' ' ) ' +test_expect_success 'git diff --no-index executed outside repo gives correct error message' ' + rm -rf .git && + test_must_fail git diff --no-index a b b 2>actual.err && + echo "usage: git diff --no-index <path> <path>" >expect.err && + test_cmp expect.err actual.err +' + test_done
-- 1.8.5.4.g8639e57