git-codereview: disable Gerrit-specific hook behavior if Gerrit is not in use
Every time I accidentally type 'git pending' in a non-Gerrit repository,
that command installs hooks, and then I have to zero the hook files
to keep working.
First, don't install the hooks if this looks like a non-Gerrit git repo.
That seems like it will play well with others.
But, people might also want to use the non-Gerrit parts of the tool,
so if people do say 'git codereview hooks', let that install them.
And then if the hooks are invoked in a non-Gerrit repo, selectively
disable the Gerrit-specific parts. For example, if it's not a Gerrit repo
we might still want to check and fix 'Fixes #N' lines if directed by the
config, but we don't want to add Change-Id lines.
Now that things are a bit better behaved, also leave the hooks on
in detached head mode. I've found that it's quite frustrating not
to have the hooks on when working midway through git rebase -i.
If we find reasons that the hooks were off we can try to figure out
how to split the difference.
Reviewed-by: Josh Bleecher Snyder <firstname.lastname@example.org>
Reviewed-by: Austin Clements <email@example.com>
7 files changed