summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b9fc6ea)
raw | patch | inline | side by side (parent: b9fc6ea)
author | David Kastrup <dak@gnu.org> | |
Sun, 23 Sep 2007 20:42:08 +0000 (22:42 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 23 Sep 2007 23:12:00 +0000 (16:12 -0700) |
A lot of shell scripts contained stuff starting with
while case "$#" in 0) break ;; esac
and similar. I consider breaking out of the condition instead of the
body od the loop ugly, and the implied "true" value of the
non-matching case is not really obvious to humans at first glance. It
happens not to be obvious to some BSD shells, either, but that's
because they are not POSIX-compliant. In most cases, this has been
replaced by a straight condition using "test". "case" has the
advantage of being faster than "test" on vintage shells where "test"
is not a builtin. Since none of them is likely to run the git
scripts, anyway, the added readability should be worth the change.
A few loops have had their termination condition expressed
differently.
Signed-off-by: David Kastrup <dak@gnu.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
while case "$#" in 0) break ;; esac
and similar. I consider breaking out of the condition instead of the
body od the loop ugly, and the implied "true" value of the
non-matching case is not really obvious to humans at first glance. It
happens not to be obvious to some BSD shells, either, but that's
because they are not POSIX-compliant. In most cases, this has been
replaced by a straight condition using "test". "case" has the
advantage of being faster than "test" on vintage shells where "test"
is not a builtin. Since none of them is likely to run the git
scripts, anyway, the added readability should be worth the change.
A few loops have had their termination condition expressed
differently.
Signed-off-by: David Kastrup <dak@gnu.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
19 files changed:
index 2ae235b081ea9829a51758bba5a0d0d64111d32c..1597e9f33f5e001995085639a448f1214010b561 100755 (executable)
. git-sh-setup
no_prune=:
-while case $# in 0) break ;; esac
+while test $# != 0
do
case "$1" in
--prune)
index 5ee3f50a3c083aa0685ad696fd1bc39b3ffbe607..ae7c5316664ce3aa14c567ddd9866499a5714eb7 100755 (executable)
list=
verify=
LINES=0
-while case "$#" in 0) break ;; esac
+while test $# != 0
do
case "$1" in
-a)
index 37b0023b270928cd80e0a6456c3d34d8173c975b..0902a5c21adc4123e36856f73acc1409e17eb0ac 100755 (executable)
. git-sh-setup
verbose=
-while case $# in 0) break;; esac
+while test $# != 0
do
case "$1" in
-v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
diff --git a/git-am.sh b/git-am.sh
index 6809aa07f60165855ebc0192750e85569f9685ff..b66173c0cd8e7908c1ac9ffc9c9a6a91160849a0 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
resolvemsg= resume=
git_apply_opt=
-while case "$#" in 0) break;; esac
+while test $# != 0
do
case "$1" in
-d=*|--d=*|--do=*|--dot=*|--dote=*|--dotes=*|--dotest=*)
diff --git a/git-clean.sh b/git-clean.sh
index a5cfd9f07a48b97ceebfe54e88fdcc519c3e0015..44917381863e27de6bedc91fa742eb0f8211a492 100755 (executable)
--- a/git-clean.sh
+++ b/git-clean.sh
rm_refuse="echo Not removing"
echo1="echo"
-while case "$#" in 0) break ;; esac
+while test $# != 0
do
case "$1" in
-d)
diff --git a/git-commit.sh b/git-commit.sh
index bb113e858b73945a1c637024277415cc5ad8f436..7a7a2cb4b47c62d4826aabd9d90a7af26427f980 100755 (executable)
--- a/git-commit.sh
+++ b/git-commit.sh
only_include_assumed=
untracked_files=
templatefile="`git config commit.template`"
-while case "$#" in 0) break;; esac
+while test $# != 0
do
case "$1" in
-F|--F|-f|--f|--fi|--fil|--file)
diff --git a/git-fetch.sh b/git-fetch.sh
index c3a200120df636fe8db0f02902d92c351c6c5e2e..e44af2c86d8e7e44bc79aafcc8ccef3806804720 100755 (executable)
--- a/git-fetch.sh
+++ b/git-fetch.sh
no_progress=
test -t 1 || no_progress=--no-progress
quiet=
-while case "$#" in 0) break ;; esac
+while test $# != 0
do
case "$1" in
-a|--a|--ap|--app|--appe|--appen|--append)
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index a4b6577bd496819232754c1275b7c1e798b0470c..a12f6c2d4c7ad3c4f69a783f7255b3010224d0c3 100755 (executable)
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
filter_subdir=
orig_namespace=refs/original/
force=
-while case "$#" in 0) usage;; esac
+while :
do
+ test $# = 0 && usage
case "$1" in
--)
shift
diff --git a/git-instaweb.sh b/git-instaweb.sh
index b79c6b6a42069168daf4e4ff191d08835f96e40f..f5629e7439955666b1755177135ac7ac198bad54 100755 (executable)
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
test -f "$fqgitdir/pid" && kill `cat "$fqgitdir/pid"`
}
-while case "$#" in 0) break ;; esac
+while test $# != 0
do
case "$1" in
--stop|stop)
diff --git a/git-ls-remote.sh b/git-ls-remote.sh
index b7e5d0458470248e65da0893b8b9bb4ced9152da..d56cf92ebfa685fd724a47e1ca753f0735dbd5bd 100755 (executable)
--- a/git-ls-remote.sh
+++ b/git-ls-remote.sh
}
exec=
-while case "$#" in 0) break;; esac
+while test $# != 0
do
case "$1" in
-h|--h|--he|--hea|--head|--heads)
diff --git a/git-merge.sh b/git-merge.sh
index 3a01db0d751e272541efd0f27177a9ca5cb63bbe..cde09d4d602811b610e0d744f4e8ede6f9fb0a39 100755 (executable)
--- a/git-merge.sh
+++ b/git-merge.sh
case "$#" in 0) usage ;; esac
have_message=
-while case "$#" in 0) break ;; esac
+while test $# != 0
do
case "$1" in
-n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 47a80553ad3283c49cae0fbffcf444b93c8e34b7..a0e44f71c4acd5d995bf823913ba63e119ed2e68 100755 (executable)
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
cleanup_temp_files
}
-while case $# in 0) break ;; esac
+while test $# != 0
do
case "$1" in
-t|--tool*)
diff --git a/git-pull.sh b/git-pull.sh
index 5e96d1f228da506b11452abec70e7c50d8907733..c3f05f56de300ad48d940def184698fb37c40028 100755 (executable)
--- a/git-pull.sh
+++ b/git-pull.sh
die "You are in the middle of a conflicted merge."
strategy_args= no_summary= no_commit= squash=
-while case "$#,$1" in 0) break ;; *,-*) ;; *) break ;; esac
+while :
do
case "$1" in
-n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\
-h|--h|--he|--hel|--help)
usage
;;
- -*)
- # Pass thru anything that is meant for fetch.
+ *)
+ # Pass thru anything that may be meant for fetch.
break
;;
esac
diff --git a/git-quiltimport.sh b/git-quiltimport.sh
index 9de54d19fbc96c18ad52b1fe6b1126432d40f17a..74a54d5d08f86ebbd6a4b3af1f6950dbfd91c743 100755 (executable)
--- a/git-quiltimport.sh
+++ b/git-quiltimport.sh
dry_run=""
quilt_author=""
-while case "$#" in 0) break;; esac
+while test $# != 0
do
case "$1" in
--au=*|--aut=*|--auth=*|--autho=*|--author=*)
index abc2b1c3e06bf1904ed92a691e917e8718e9e299..2fa53fdaeb3a24495f023e1f1f79da23e7e34f7c 100755 (executable)
done
}
-while case $# in 0) break ;; esac
+while test $# != 0
do
case "$1" in
--continue)
diff --git a/git-rebase.sh b/git-rebase.sh
index 3bd66b0a04bac05a3447d68112d4d933480eaf04..058fcacb7eea33128436fa04c0412370562e9ff0 100755 (executable)
--- a/git-rebase.sh
+++ b/git-rebase.sh
is_interactive () {
test -f "$dotest"/interactive ||
- while case $#,"$1" in 0,|*,-i|*,--interactive) break ;; esac
- do
+ while :; do case $#,"$1" in 0,|*,-i|*,--interactive) break ;; esac
shift
done && test -n "$1"
}
is_interactive "$@" && exec git-rebase--interactive "$@"
-while case "$#" in 0) break ;; esac
+while test $# != 0
do
case "$1" in
--continue)
diff --git a/git-repack.sh b/git-repack.sh
index 156c5e8f4aa2f6c04e33af323ef43356fd336adb..0aae1a3ed5571a010f80438f8e8a0fc7eb0dc285 100755 (executable)
--- a/git-repack.sh
+++ b/git-repack.sh
no_update_info= all_into_one= remove_redundant=
local= quiet= no_reuse= extra=
-while case "$#" in 0) break ;; esac
+while test $# != 0
do
case "$1" in
-n) no_update_info=t ;;
diff --git a/git-reset.sh b/git-reset.sh
index 1dc606fbd3fd29f5f4c9928a2518df46109ef449..bafeb52cd113ad8a07ffd1912191f2bc17a7ef7a 100755 (executable)
--- a/git-reset.sh
+++ b/git-reset.sh
update= reset_type=--mixed
unset rev
-while case $# in 0) break ;; esac
+while test $# != 0
do
case "$1" in
--mixed | --soft | --hard)
diff --git a/git-submodule.sh b/git-submodule.sh
index 3320998c76ba72094755ec60369a6266751889ff..673aa27a452b11af62d89986bf21c8a4f10e0c41 100755 (executable)
--- a/git-submodule.sh
+++ b/git-submodule.sh
done
}
-while case "$#" in 0) break ;; esac
+while test $# != 0
do
case "$1" in
add)