git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 14, 2014, 22:14 UTC
Message-ID
<xmqqiojmxpsh.fsf@gitster.dls.corp.google.com>
In-Reply-To
<CAEBDL5V_Mzxwc4fnybg9=fmeotGV91XerzTccHMWLV79bE+mVA@mail.gmail.com>
John Szakmeister <john@szakmeister.net> writes:
Show 25 quoted lines
> On Tue, Oct 14, 2014 at 2:29 PM, Junio C Hamano <gitster@pobox.com> 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.
Previous: John Szakmeister
Message 5 of 5 in “[kernel] completion: silence "fatal: Not a git repository" error”
  1. [kernel] completion: silence "fatal: Not a git repository" errorJohn Szakmeister, Oct 14, 2014
  2. John SzakmeisterOct 14, 2014
  3. Junio C HamanoOct 14, 2014
  4. John SzakmeisterOct 14, 2014
  5. Junio C HamanoOct 14, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.