@@ -235,7 +235,7 @@ module_name()
235235 sed -n -e ' s|^submodule\.\(.*\)\.path ' " $re " ' $|\1|p' )
236236 test -z " $name " &&
237237 die " $( eval_gettext " No submodule mapping found in .gitmodules for path '\$ sm_path'" ) "
238- echo " $name "
238+ printf ' %s\n ' " $name "
239239}
240240
241241#
@@ -305,10 +305,10 @@ module_clone()
305305 b=${b%/ }
306306
307307 # Turn each leading "*/" component into "../"
308- rel=$( echo $b | sed -e ' s|[^/][^/]*|..|g' )
309- echo " gitdir: $rel /$a " > " $sm_path /.git"
308+ rel=$( printf ' %s\n ' " $b " | sed -e ' s|[^/][^/]*|..|g' )
309+ printf ' %s\n ' " gitdir: $rel /$a " > " $sm_path /.git"
310310
311- rel=$( echo $a | sed -e ' s|[^/][^/]*|..|g' )
311+ rel=$( printf ' %s\n ' " $a " | sed -e ' s|[^/][^/]*|..|g' )
312312 (clear_local_git_env; cd " $sm_path " && GIT_WORK_TREE=. git config core.worktree " $rel /$b " )
313313}
314314
@@ -389,11 +389,11 @@ cmd_add()
389389 sm_path=$2
390390
391391 if test -z " $sm_path " ; then
392- sm_path=$( echo " $repo " |
392+ sm_path=$( printf ' %s\n ' " $repo " |
393393 sed -e ' s|/$||' -e ' s|:*/*\.git$||' -e ' s|.*[/:]||g' )
394394 fi
395395
396- if test -z " $repo " -o -z " $sm_path " ; then
396+ if test -z " $repo " || test -z " $sm_path " ; then
397397 usage
398398 fi
399399
@@ -450,7 +450,7 @@ Use -f if you really want to add it." >&2
450450 # perhaps the path exists and is already a git repo, else clone it
451451 if test -e " $sm_path "
452452 then
453- if test -d " $sm_path " /.git -o -f " $sm_path " /.git
453+ if test -d " $sm_path " /.git || test -f " $sm_path " /.git
454454 then
455455 eval_gettextln " Adding existing repo at '\$ sm_path' to the index"
456456 else
@@ -832,7 +832,7 @@ Maybe you want to use 'update --init'?")"
832832 continue
833833 fi
834834
835- if ! test -d " $sm_path " /.git -o -f " $sm_path " /.git
835+ if ! test -d " $sm_path " /.git && ! test -f " $sm_path " /.git
836836 then
837837 module_clone " $sm_path " " $name " " $url " " $reference " " $depth " || exit
838838 cloned_modules=" $cloned_modules ;$name "
@@ -857,11 +857,11 @@ Maybe you want to use 'update --init'?")"
857857 die " $( eval_gettext " Unable to find current ${remote_name} /${branch} revision in submodule path '\$ sm_path'" ) "
858858 fi
859859
860- if test " $subsha1 " ! = " $sha1 " -o -n " $force "
860+ if test " $subsha1 " ! = " $sha1 " || test -n " $force "
861861 then
862862 subforce=$force
863863 # If we don't already have a -f flag and the submodule has never been checked out
864- if test -z " $subsha1 " -a -z " $force "
864+ if test -z " $subsha1 " && test -z " $force "
865865 then
866866 subforce=" -f"
867867 fi
@@ -1031,7 +1031,7 @@ cmd_summary() {
10311031 then
10321032 head=$rev
10331033 test $# = 0 || shift
1034- elif test -z " $1 " -o " $1 " = " HEAD"
1034+ elif test -z " $1 " || test " $1 " = " HEAD"
10351035 then
10361036 # before the first commit: compare with an empty tree
10371037 head=$( git hash-object -w -t tree --stdin < /dev/null)
@@ -1056,17 +1056,21 @@ cmd_summary() {
10561056 while read mod_src mod_dst sha1_src sha1_dst status sm_path
10571057 do
10581058 # Always show modules deleted or type-changed (blob<->module)
1059- test $status = D -o $status = T && echo " $sm_path " && continue
1059+ if test " $status " = D || test " $status " = T
1060+ then
1061+ printf ' %s\n' " $sm_path "
1062+ continue
1063+ fi
10601064 # Respect the ignore setting for --for-status.
10611065 if test -n " $for_status "
10621066 then
10631067 name=$( module_name " $sm_path " )
10641068 ignore_config=$( get_submodule_config " $name " ignore none)
1065- test $status ! = A -a $ignore_config = all && continue
1069+ test $status ! = A && test $ignore_config = all && continue
10661070 fi
10671071 # Also show added or modified modules which are checked out
10681072 GIT_DIR=" $sm_path /.git" git-rev-parse --git-dir > /dev/null 2>&1 &&
1069- echo " $sm_path "
1073+ printf ' %s\n ' " $sm_path "
10701074 done
10711075 )
10721076
@@ -1122,7 +1126,7 @@ cmd_summary() {
11221126 * )
11231127 errmsg=
11241128 total_commits=$(
1125- if test $mod_src = 160000 -a $mod_dst = 160000
1129+ if test $mod_src = 160000 && test $mod_dst = 160000
11261130 then
11271131 range=" $sha1_src ...$sha1_dst "
11281132 elif test $mod_src = 160000
@@ -1159,7 +1163,7 @@ cmd_summary() {
11591163 # i.e. deleted or changed to blob
11601164 test $mod_dst = 160000 && echo " $errmsg "
11611165 else
1162- if test $mod_src = 160000 -a $mod_dst = 160000
1166+ if test $mod_src = 160000 && test $mod_dst = 160000
11631167 then
11641168 limit=
11651169 test $summary_limit -gt 0 && limit=" -$summary_limit "
@@ -1230,7 +1234,11 @@ cmd_status()
12301234 say " U$sha1 $displaypath "
12311235 continue
12321236 fi
1233- if test -z " $url " || ! test -d " $sm_path " /.git -o -f " $sm_path " /.git
1237+ if test -z " $url " ||
1238+ {
1239+ ! test -d " $sm_path " /.git &&
1240+ ! test -f " $sm_path " /.git
1241+ }
12341242 then
12351243 say " -$sha1 $displaypath "
12361244 continue ;
@@ -1303,7 +1311,7 @@ cmd_sync()
13031311 ./* |../* )
13041312 # rewrite foo/bar as ../.. to find path from
13051313 # submodule work tree to superproject work tree
1306- up_path=" $( echo " $sm_path " | sed " s/[^/][^/]*/../g" ) " &&
1314+ up_path=" $( printf ' %s\n ' " $sm_path " | sed " s/[^/][^/]*/../g" ) " &&
13071315 # guarantee a trailing /
13081316 up_path=${up_path%/ } / &&
13091317 # path from submodule work tree to submodule origin repo
@@ -1399,7 +1407,7 @@ then
13991407fi
14001408
14011409# "--cached" is accepted only by "status" and "summary"
1402- if test -n " $cached " && test " $command " ! = status -a " $command " ! = summary
1410+ if test -n " $cached " && test " $command " ! = status && test " $command " ! = summary
14031411then
14041412 usage
14051413fi
0 commit comments