From: Junio C Hamano <gitster@pobox.com>
To: Elia Pinto <gitter.spiros@gmail.com>
Cc: git@vger.kernel.org, jrnieder@gmail.com
Subject: Re: [PATCH] git-submodule.sh: avoid "test <cond> -a/-o <cond>"
Date: Tue, 10 Jun 2014 10:03:08 -0700 [thread overview]
Message-ID: <xmqqd2egae9f.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1402418594-1377-1-git-send-email-gitter.spiros@gmail.com> (Elia Pinto's message of "Tue, 10 Jun 2014 09:43:14 -0700")
Elia Pinto <gitter.spiros@gmail.com> writes:
> @@ -832,7 +832,7 @@ Maybe you want to use 'update --init'?")"
> continue
> fi
>
> - if ! test -d "$sm_path"/.git -o -f "$sm_path"/.git
> + if ! test -d "$sm_path"/.git && test -f "$sm_path"/.git
Hmmmm. Is the above correct?
$ if ! false && true; then echo true; else echo false; fi
true
In other words, "! cmd1 && cmd2" parses not as "! (cmd1 && cmd2)"
but as "(! cmd1) && cmd2".
It almost makes me wonder if the code may become simpler if we did
it the way in the attached. That is, "if $sm_path/.git is there
(whether as an embedded repository, or a file pointing to a
repository elsewhere), then grab its HEAD, otherwise $sm_path is a
submodule that hasn't been run 'submodule init' on, so run the whole
nine yards starting from module_clone".
Such a rewrite is not within the scope of this series, so
if ! test -d "$sm_path/.git" && ! test -f "$sm_path/.git"
may be the closest to the original intent, 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 e146b83..018f1bb 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -832,15 +832,15 @@ Maybe you want to use 'update --init'?")"
continue
fi
- if ! test -d "$sm_path"/.git -o -f "$sm_path"/.git
+ if test -e "$sm_path/.git"
then
- module_clone "$sm_path" "$name" "$url" "$reference" "$depth" || exit
- cloned_modules="$cloned_modules;$name"
- subsha1=
- else
subsha1=$(clear_local_git_env; cd "$sm_path" &&
git rev-parse --verify HEAD) ||
die "$(eval_gettext "Unable to find current revision in submodule path '\$displaypath'")"
+ else
+ module_clone "$sm_path" "$name" "$url" "$reference" "$depth" || exit
+ cloned_modules="$cloned_modules;$name"
+ subsha1=
fi
if test -n "$remote"
next prev parent reply other threads:[~2014-06-10 17:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-10 16:43 [PATCH] git-submodule.sh: avoid "test <cond> -a/-o <cond>" Elia Pinto
2014-06-10 17:02 ` Junio C Hamano
2014-06-10 17:03 ` Junio C Hamano [this message]
2014-06-10 19:47 ` Eric Sunshine
-- strict thread matches above, loose matches on Subject: below --
2014-06-10 12:28 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
2014-06-10 14:55 ` Junio C Hamano
2014-06-10 15:20 ` Johannes Sixt
2014-06-10 15:36 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqd2egae9f.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitter.spiros@gmail.com \
--cc=jrnieder@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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.