From: Junio C Hamano <gitster@pobox•com>
To: Elia Pinto <gitter.spiros@gmail•com>
Cc: "Torsten Bögershausen" <tboegi@web•de>,
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:32:57 -0700 [thread overview]
Message-ID: <xmqqy4x4aifq.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <xmqq38fcbxf8.fsf@gitster.dls.corp.google.com> (Junio C. Hamano's message of "Tue, 10 Jun 2014 08:23:55 -0700")
Junio C Hamano <gitster@pobox•com> writes:
> 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.
> ...
> 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.
... which may look like this (after removing s/echo/printf/ in that
hunk from this "test -a/-o" patch).
git-submodule.sh | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index d0d9b58..9245abf 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -235,7 +235,7 @@ module_name()
sed -n -e 's|^submodule\.\(.*\)\.path '"$re"'$|\1|p' )
test -z "$name" &&
die "$(eval_gettext "No submodule mapping found in .gitmodules for path '\$sm_path'")"
- echo "$name"
+ printf '%s\n' "$name"
}
#
@@ -305,10 +305,10 @@ module_clone()
b=${b%/}
# Turn each leading "*/" component into "../"
- rel=$(echo $b | sed -e 's|[^/][^/]*|..|g')
- echo "gitdir: $rel/$a" >"$sm_path/.git"
+ rel=$(printf '%s\n' "$b" | sed -e 's|[^/][^/]*|..|g')
+ printf '%s\n' "gitdir: $rel/$a" >"$sm_path/.git"
- rel=$(echo $a | sed -e 's|[^/][^/]*|..|g')
+ rel=$(printf '%s\n' "$a" | sed -e 's|[^/][^/]*|..|g')
(clear_local_git_env; cd "$sm_path" && GIT_WORK_TREE=. git config core.worktree "$rel/$b")
}
@@ -389,7 +389,7 @@ cmd_add()
sm_path=$2
if test -z "$sm_path"; then
- sm_path=$(echo "$repo" |
+ sm_path=$(printf '%s\n' "$repo" |
sed -e 's|/$||' -e 's|:*/*\.git$||' -e 's|.*[/:]||g')
fi
@@ -1058,7 +1058,7 @@ cmd_summary() {
# Always show modules deleted or type-changed (blob<->module)
if test "$status" = D || test "$status" = T
then
- echo "$sm_path"
+ printf '%s\n' "$sm_path"
continue
fi
# Respect the ignore setting for --for-status.
@@ -1070,7 +1070,7 @@ cmd_summary() {
fi
# Also show added or modified modules which are checked out
GIT_DIR="$sm_path/.git" git-rev-parse --git-dir >/dev/null 2>&1 &&
- echo "$sm_path"
+ printf '%s\n' "$sm_path"
done
)
@@ -1311,7 +1311,7 @@ cmd_sync()
./*|../*)
# rewrite foo/bar as ../.. to find path from
# submodule work tree to superproject work tree
- up_path="$(echo "$sm_path" | sed "s/[^/][^/]*/../g")" &&
+ up_path="$(printf '%s\n' "$sm_path" | sed "s/[^/][^/]*/../g")" &&
# guarantee a trailing /
up_path=${up_path%/}/ &&
# path from submodule work tree to submodule origin repo
next prev parent reply other threads:[~2014-06-10 15:33 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
2014-06-10 15:32 ` Junio C Hamano [this message]
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=xmqqy4x4aifq.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