completion: warn people about duplicated function

The __gitdir function is duplicated between completion and prompt
scripts, and these definitions should not diverge; otherwise one of
them can be subtly broken depending on the order the user's shell
dot-sources them.

Leave a note to people who may want to touch one copy to make sure
they update the other one in sync.  Hopefully this line would also
appear in the context of the patch to allow reviewers to notice a
patch that attempts to update only one of them.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano 2012-06-10 00:26:35 -07:00
parent af31a456b4
commit ac3eb1c384
2 changed files with 4 additions and 0 deletions

View file

@ -36,6 +36,8 @@ esac
# returns location of .git repo
__gitdir ()
{
# Note: this function is duplicated in git-prompt.sh
# When updating it, make sure you update the other one to match.
if [ -z "${1-}" ]; then
if [ -n "${__git_dir-}" ]; then
echo "$__git_dir"

View file

@ -53,6 +53,8 @@
# returns location of .git repo
__gitdir ()
{
# Note: this function is duplicated in git-completion.bash
# When updating it, make sure you update the other one to match.
if [ -z "${1-}" ]; then
if [ -n "${__git_dir-}" ]; then
echo "$__git_dir"