Subject: Re: [PATCH 1/2] diff: add test for --no-index executed outside repo

From: Junio C Hamano <[email-masked]>
Date: Mon, 16 Dec 2013 11:42:42 -0800

Thomas Gummerer <[email-masked]> writes:

> 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 <[email-masked]>
> ---
>
>>> 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?

Perhaps use CEILING, like this (untested)?

	mkdir -p test-outside/non/git &&
        (
                GIT_CEILING_DIRECTORIES=$TRASH_DIRECTORY/test-outside &&
		export GIT_CEILING_DIRECTORIES &&
		cd test-outside/non/git &&
		do whatever non-git thing here
	)