Subject: Re: [PATCH] [kernel] completion: silence "fatal: Not a git repository" error

From: Junio C Hamano <[email-masked]>
Date: Tue, 14 Oct 2014 15:14:06 -0700

John Szakmeister <[email-masked]> writes:

> On Tue, Oct 14, 2014 at 2:29 PM, Junio C Hamano <[email-masked]> wrote:
> ...
>> Hmph, do you mean this one?
>>
>>     $ cd /var/tmp ;# not a git repository
>>     $ git checkout <TAB>
>>
>> ->
>>
>>     $ git checkout fatal: Not a git repository (or any of the parent directories): .git
>>     HEAD
>>
>> I agree it is ugly, but would it be an improvement for the end user,
>> who did not realize that she was not in a directory where "git checkout"
>> makes sense, not to tell her that she is not in a git repository in
>> some way?
>
> I had thought about that too, but I think--for me--it comes down to two things:
>
> 1) We're not intentionally trying to inform the user anywhere else
> that they are not in a git repo.  We simply fail to complete anything,
> which I think is an established behavior.
> 2) It mingles with the stuff already on the command line, making it
> confusing to know what you typed.  Then you end up ctrl-c'ing your way
> out of it and starting over--which is the frustrating part.

It is not that I am unsympathetic.  It's just it looks to me that
the patch is potentially adding one more failed step by hiding the
error message to further frustrate the user.

    $ git checkout <TAB>
    ... completes nothing; puzzled but decides not to be worried for now
    $ git checkout master<RET>
    fatal: not a git repository

As you noticed, however, we do not show the ugly error message by
design.  It is not done consistently, either (happens only when we
try to complete refnames).

I was just hoping that somebody (not necessarily you) could suggest
a way to do better than hide the error message only because it looks
ugly (iow, perhaps show it not in the middle of the command line,
and do so more consistently).  Yes I would imagine it would be a lot
harder, but the end user experience _might_ become so much better to
make it worthwhile.  I dunno.

I am not strongly opposed to queuing the patch.