From: Junio C Hamano <gitster@pobox.com>
To: Felipe Contreras <felipe.contreras@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: What's cooking in git.git (Jun 2012, #01; Sun, 3)
Date: Sun, 10 Jun 2012 00:26:35 -0700 [thread overview]
Message-ID: <7vmx4baaqc.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <CAMP44s2VGLj8kRih-95A0VDq86WKWHF3EhLvz0etyHHtP27qLA@mail.gmail.com> (Felipe Contreras's message of "Wed, 6 Jun 2012 20:17:36 +0200")
Felipe Contreras <felipe.contreras@gmail.com> 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@pobox.com>
---
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"
next prev parent reply other threads:[~2012-06-10 7:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-04 0:23 What's cooking in git.git (Jun 2012, #01; Sun, 3) Junio C Hamano
2012-06-06 12:22 ` Felipe Contreras
2012-06-06 17:58 ` Junio C Hamano
2012-06-06 18:17 ` Felipe Contreras
2012-06-10 7:26 ` Junio C Hamano [this message]
2012-06-10 15:09 ` Felipe Contreras
2012-06-11 14:54 ` Junio C Hamano
2012-06-13 14:55 ` Felipe Contreras
2012-06-13 17:19 ` Junio C Hamano
2012-06-13 18:04 ` Felipe Contreras
2012-06-10 17:39 ` René Scharfe
2012-06-11 10:27 ` Felipe Contreras
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vmx4baaqc.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=felipe.contreras@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).