Felipe Contreras <felipe.contreras@xxxxxxxxx> writes: >> I did not see anything like these. > > Nor is it needed *right now*. You could release v1.7.11 without any of > these, and then v1.7.11.1 or even v1.7.12 with a solution; I bet > __gitdir() would not have changed by that point. And by that time on whom are you placing the burden of making sure they do not diverge? Don't you still realize that you are being irresponsible? In any case, I am tired of your arguing without being constructive, so let's try again. This is the third option I suggested to you. Notice in the post context lines that they are already subtly different; one pays attention to $GIT_DIR, and the other does not. Shouldn't they be not just kept in sync, but start out in sync in the first place? Aren't there other functions or variables that need to be kept in sync between these, by the way? -- >8 -- Subject: 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@xxxxxxxxx> --- contrib/completion/git-completion.bash | 2 ++ contrib/completion/git-prompt.sh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index abf8215..efcd875 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -33,12 +33,14 @@ case "$COMP_WORDBREAKS" in esac # __gitdir accepts 0 or 1 arguments (i.e., location) # 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" elif [ -d .git ]; then echo .git else diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh index 8e2e9f3..29b1ec9 100644 --- a/contrib/completion/git-prompt.sh +++ b/contrib/completion/git-prompt.sh @@ -50,12 +50,14 @@ # setting the bash.showUpstream config variable. # __gitdir accepts 0 or 1 arguments (i.e., location) # 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" elif [ -n "${GIT_DIR-}" ]; then test -d "${GIT_DIR-}" || return 1 echo "$GIT_DIR" -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html