git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-submodule.sh: avoid "test <cond> -a/-o <cond>"

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jun 10, 2014, 19:47 UTC
Message-ID
<CAPig+cTTOCe0-U_bMbzo6fp3PFsN+8eJHi9iTxoE9d3UHyRMhg@mail.gmail.com>
In-Reply-To
<1402418594-1377-1-git-send-email-gitter.spiros@gmail.com>
On Tue, Jun 10, 2014 at 12:43 PM, Elia Pinto <gitter.spiros@gmail.com> wrote:
Show 33 quoted lines
> The construct is error-prone; "test" being built-in in most modern
> shells, the reason to avoid "test <cond> && test <cond>" spawning
> one extra process by using a single "test <cond> -a <cond>" no
> longer exists.
>
> Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
> ---
> This is the fifth revision.
>
> Change based on Junio bugfix and better rewrite of the case condition
> http://permalink.gmane.org/gmane.comp.version-control.git/251198
>
> I dropped also the echo -> printf replacement for doing
> it in another patch.
>
> Pass all the t/*submodule* tests. Finally ! :=)
>
> Thank you all very much and sorry for the mess.
>
>  git-submodule.sh |   32 ++++++++++++++++++++------------
>  1 file changed, 20 insertions(+), 12 deletions(-)
>
> diff --git a/git-submodule.sh b/git-submodule.sh
> index e146b83..e128a4a 100755
> --- a/git-submodule.sh
> +++ b/git-submodule.sh
>                 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
> +                       if test "$status" = D || test "$status" = T
> +                        then
> +                               echo "$sm_path" &&
Unnecessary &&.
Show 12 quoted lines
> +                               continue
> +                       fi
>                         # Respect the ignore setting for --for-status.
>                         if test -n "$for_status"
>                         then
>                                 name=$(module_name "$sm_path")
>                                 ignore_config=$(get_submodule_config "$name" ignore none)
> -                               test $status != A -a $ignore_config = all && continue
> +                               test $status != A && test $ignore_config = all && continue
>                         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 &&
Previous: Junio C Hamano
Message 4 of 4 in “git-submodule.sh: avoid "test <cond> -a/-o <cond>"”
  1. git-submodule.sh: avoid "test <cond> -a/-o <cond>"Elia Pinto, Jun 10, 2014
  2. Junio C HamanoJun 10, 2014
  3. Junio C HamanoJun 10, 2014
  4. Eric SunshineJun 10, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.