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

From: Junio C Hamano <[email-masked]>
Date: Tue, 14 Oct 2014 11:29:41 -0700

John Szakmeister <[email-masked]> writes:

> It is possible that a user is trying to run a git command and fail to realize
> that they are not in a git repository or working tree.  When trying to complete
> an operation, __git_refs would fall to a degenerate case and attempt to use
> "git for-each-ref", which would emit the error.
>
> Let's fix this by shunting the error message coming from "git for-each-ref".

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?