From: Junio C Hamano <gitster@pobox•com>
To: "Torsten Bögershausen" <tboegi@web•de>
Cc: Elia Pinto <gitter.spiros@gmail•com>,
git@vger•kernel.org, jrnieder@gmail•com
Subject: Re: [PATCH] git-submodule.sh: avoid "test <cond> -a/-o <cond>"
Date: Tue, 10 Jun 2014 08:23:55 -0700 [thread overview]
Message-ID: <xmqq38fcbxf8.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <53971BBE.8030108@web.de> ("Torsten Bögershausen"'s message of "Tue, 10 Jun 2014 16:52:46 +0200")
Torsten Bögershausen <tboegi@web•de> writes:
> On 2014-06-10 14.28, Elia Pinto wrote:
> []
>> # before the first commit: compare with an empty tree
>> head=$(git hash-object -w -t tree --stdin </dev/null)
>> @@ -1056,13 +1056,17 @@ cmd_summary() {
>> while read mod_src mod_dst sha1_src sha1_dst status sm_path
>> do
>> # Always show modules deleted or type-changed (blob<->module)
>> - test $status = D -o $status = T && echo "$sm_path" && continue
>> + case "$status" in
>> + ([DT])
> Does this look strange? ^
> Should it be
> case "$status" in
> D|T)
Actually POSIX allows matching parentheses for case arm labels
(surprise!).
And some shells misparse
var=$( ... case arm) action ;; esac ... )
as if the ')' after the arm label closes the whole command
substitution.
Having said that, I'd prefer to see the following squashed into that
patch.
The first hunk is purely a bugfix. It used to be
if ! test -d "$sm_path"/.git -o -f "$sm_path"/.git
that is: unless "$sm_path/.git" is directory or file, do this.
And the rewrite broke that logic.
The second hunk is to avoid "case" that confuses without helping
readability that much.
I would also have preferred to see the echo to printf substitution
left out of this patch. There are other places where $sm_path is
echoed and fixing only one of them in an otherwise unrelated patch
feels wrong---it should be a separate follow-up patch, I would
think.
git-submodule.sh | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index d6a1dea..27ca7d5 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -832,7 +832,7 @@ Maybe you want to use 'update --init'?")"
continue
fi
- if ! test -d "$sm_path"/.git || test -f "$sm_path"/.git
+ if ! test -d "$sm_path"/.git && ! test -f "$sm_path"/.git
then
module_clone "$sm_path" "$name" "$url" "$reference" "$depth" || exit
cloned_modules="$cloned_modules;$name"
@@ -1056,11 +1056,11 @@ cmd_summary() {
while read mod_src mod_dst sha1_src sha1_dst status sm_path
do
# Always show modules deleted or type-changed (blob<->module)
- case "$status" in
- ([DT])
- printf '%s\n' "$sm_path" &&
+ if test "$status" = D || test "$status" = T
+ then
+ printf '%s\n' "$sm_path"
continue
- esac
+ fi
# Respect the ignore setting for --for-status.
if test -n "$for_status"
then
next prev parent reply other threads:[~2014-06-10 15:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-10 12:28 [PATCH] git-submodule.sh: avoid "test <cond> -a/-o <cond>" Elia Pinto
2014-06-10 14:42 ` Junio C Hamano
2014-06-10 14:52 ` Torsten Bögershausen
2014-06-10 15:23 ` Junio C Hamano [this message]
2014-06-10 15:32 ` Junio C Hamano
2014-06-10 14:55 ` Junio C Hamano
2014-06-10 15:20 ` Johannes Sixt
2014-06-10 15:36 ` Junio C Hamano
-- strict thread matches above, loose matches on Subject: below --
2014-06-10 16:43 Elia Pinto
2014-06-10 17:02 ` Junio C Hamano
2014-06-10 17:03 ` Junio C Hamano
2014-06-10 19:47 ` Eric Sunshine
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=xmqq38fcbxf8.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=gitter.spiros@gmail$(echo .)com \
--cc=jrnieder@gmail$(echo .)com \
--cc=tboegi@web$(echo .)de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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