git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Vasco Almeida <vascomalmeida@sapo.pt>
Cc: git@vger.kernel.org, "Jiang Xin" <worldhello.net@gmail.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Eric Sunshine" <sunshine@sunshineco.com>
Subject: Re: [PATCH v2 14/22] i18n: rebase-interactive: mark strings for translation
Date: Fri, 27 May 2016 09:58:04 -0700	[thread overview]
Message-ID: <xmqqk2ifsajn.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <57481CA0.5080801@sapo.pt> (Vasco Almeida's message of "Fri, 27 May 2016 10:08:32 +0000")

Vasco Almeida <vascomalmeida@sapo.pt> writes:

>>>  is_empty_commit() {
>>> -	tree=$(git rev-parse -q --verify "$1"^{tree} 2>/dev/null ||
>>> -		die "$1: not a commit that can be picked")
>>> -	ptree=$(git rev-parse -q --verify "$1"^^{tree} 2>/dev/null ||
>>> +	sha1=$1
>>> +	tree=$(git rev-parse -q --verify "$sha1"^{tree} 2>/dev/null ||
>>> +		die "$(eval_gettext "\$sha1: not a commit that can be picked")")
>>> +	ptree=$(git rev-parse -q --verify "$sha1"^^{tree} 2>/dev/null ||
>>>  		ptree=4b825dc642cb6eb9a060e54bf8d69288fbee4904)
>>>  	test "$tree" = "$ptree"
>>>  }
>> 
>> Both of the two callsites of this function use the variable $sha1,
>> and at least one of them uses that variable after this function
>> returns, but they pass it as the first parameter to this function,
>> so the assignment added by this patch does not break them, which is
>> good.
>> 
> I didn't know that. I can change sha1=$1 to local_sha1=$1 or _sha1=$1 (I
> don't know what is the convention here) if that is safer, avoiding using
> the bash-ism "local" keyword, and preventing future distractions.

I do not think it is necessary to do any of the changes for this
one, which is only used locally in this file.  They just need to be
careful when they add or modify the callers.

Even if it is renamed $local_sha1, they will still need to be
careful anyway, because the only way they _can_ break or be broken
by your patch is when they somehow decide to pass something that is
not called $sha1 to this function, i.e. they would be changing the
callsite---which they must be doing for a reason and would also
involve change to the code what happens after this function returns.
If they start using $local_sha1 there, they would be broken if you
renamed it today, and if they use $sha1 there, they would be broken
if you didn't---so they have to be careful and check what this one
clobbers _anyway_.  

IOW, a solution that clobbers _some_ variable cannot be made safer
by renaming.  The callers always have to be careful not to be
affected.

You could do something like this, though.  I _think_ the original
that calls "die" inside $() is broken anyway, so it probably is a
good change regardless.

 git-rebase--interactive.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 9d2bfb7..b5113d6 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -222,8 +222,10 @@ has_action () {
 }
 
 is_empty_commit() {
-	tree=$(git rev-parse -q --verify "$1"^{tree} 2>/dev/null ||
-		die "$1: not a commit that can be picked")
+	tree=$(git rev-parse -q --verify "$1"^{tree} 2>/dev/null) || {
+		sha1=$1
+		die "$(eval_gettext "\$sha1: not a commit that can be picked")"
+	}
 	ptree=$(git rev-parse -q --verify "$1"^^{tree} 2>/dev/null ||
 		ptree=4b825dc642cb6eb9a060e54bf8d69288fbee4904)
 	test "$tree" = "$ptree"

  reply	other threads:[~2016-05-27 16:58 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-23 19:27 [PATCH v2 00/22] i18n and test updates Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 01/22] i18n: builtin/remote.c: fix mark for translation Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 02/22] i18n: advice: mark string about detached head " Vasco Almeida
2016-05-30 11:03   ` Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 03/22] i18n: advice: internationalize message for conflicts Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 04/22] i18n: transport: mark strings for translation Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 05/22] i18n: sequencer: mark entire sentences " Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 06/22] i18n: sequencer: mark string " Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 07/22] i18n: merge-octopus: mark messages " Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 08/22] merge-octupus: use die shell function from git-sh-setup.sh Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 09/22] i18n: rebase: fix marked string to use eval_gettext variant Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 10/22] i18n: rebase: mark placeholder for translation Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 11/22] i18n: bisect: simplify error message for i18n Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 12/22] t6030: update to use test_i18ncmp Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 13/22] i18n: git-sh-setup.sh: mark strings for translation Vasco Almeida
2016-05-26 22:46   ` Junio C Hamano
2016-05-27 10:17     ` Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 14/22] i18n: rebase-interactive: " Vasco Almeida
2016-05-26 22:36   ` Junio C Hamano
2016-05-27 10:08     ` Vasco Almeida
2016-05-27 16:58       ` Junio C Hamano [this message]
2016-05-23 19:27 ` [PATCH v2 15/22] i18n: rebase-interactive: mark here-doc " Vasco Almeida
2016-05-25 13:13   ` Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 16/22] i18n: rebase-interactive: mark comments of squash " Vasco Almeida
2016-05-26 22:35   ` Junio C Hamano
2016-05-27 10:36     ` Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 17/22] i18n: setup: mark strings " Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 18/22] tests: use test_i18n* functions to suppress false positives Vasco Almeida
2016-05-27 17:08   ` Junio C Hamano
2016-05-27 19:34     ` Vasco Almeida
2016-05-27 19:51       ` Junio C Hamano
2016-05-23 19:27 ` [PATCH v2 19/22] tests: unpack-trees: update to use test_i18n* functions Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 20/22] t9003: become resilient to GETTEXT_POISON Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 21/22] t4153: fix negated test_i18ngrep call Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 22/22] t5523: use test_i18ngrep for negation Vasco Almeida
2016-05-27 17:11 ` [PATCH v2 00/22] i18n and test updates Junio C Hamano
2016-05-28  8:18   ` Vasco Almeida
2016-05-30  0:03     ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqk2ifsajn.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=sunshine@sunshineco.com \
    --cc=vascomalmeida@sapo.pt \
    --cc=worldhello.net@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).