git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]: Use ARGS, not positional arguments
@ 2005-10-12  5:57 Pavel Roskin
  0 siblings, 0 replies; only message in thread
From: Pavel Roskin @ 2005-10-12  5:57 UTC (permalink / raw)
  To: Petr Baudis, git

Some scripts need to be fixed to use ARGS properly.

Positional arguments are no longer preserved in cg-Xlib, so they may not
be used.  cg-export uses standard option parsing now.

Signed-off-by: Pavel Roskin <proski@gnu.org>

diff --git a/cg-admin-lsobj b/cg-admin-lsobj
index 8899037..bf3413f 100755
--- a/cg-admin-lsobj
+++ b/cg-admin-lsobj
@@ -39,7 +39,7 @@ USAGE="cg-admin-lsobj [OBJECT_TYPE]"
 
 . ${COGITO_LIB}cg-Xlib || exit 1
 
-target=$1
+target=${ARGS[0]}
 
 
 subdir=$_git_objects
diff --git a/cg-branch-add b/cg-branch-add
index eb20598..c5462cf 100755
--- a/cg-branch-add
+++ b/cg-branch-add
@@ -63,8 +63,8 @@ USAGE="cg-branch-add BRANCH_NAME LOCATIO
 
 . ${COGITO_LIB}cg-Xlib || exit 1
 
-name=$1
-location=$2
+name=${ARGS[0]}
+location=${ARGS[1]}
 
 ([ "$name" ] && [ "$location" ]) || usage
 (echo $name | egrep -qv '[^a-zA-Z0-9_.@!:-]') || \
diff --git a/cg-branch-chg b/cg-branch-chg
index 6ac8d15..9c98f6b 100755
--- a/cg-branch-chg
+++ b/cg-branch-chg
@@ -9,8 +9,8 @@ USAGE="cg-branch-chg BRANCH_NAME NEW_LOC
 
 . ${COGITO_LIB}cg-Xlib || exit 1
 
-name=$1
-location=$2
+name=${ARGS[0]}
+location=${ARGS[1]}
 ([ "$name" ] && [ "$location" ]) || usage
 
 [ -s "$_git/branches/$name" ] || die "branch does not exist"
diff --git a/cg-export b/cg-export
index 594e225..ef9e7cc 100755
--- a/cg-export
+++ b/cg-export
@@ -15,17 +15,22 @@ _git_requires_root=1
 
 . ${COGITO_LIB}cg-Xlib || exit 1
 
-if [ "$1" = "-r" ]; then
-	shift
-	# We do not resolve to tree id since git-tar-tree can utilize some commit
-	# information.
-	id="$(cg-object-id -c "$1" 2>/dev/null)" || id="$1"
-	shift
-else
+id=
+while optparse; do
+	if optparse -r=; then
+		# We do not resolve to tree id since git-tar-tree can
+		# utilize some commit information.
+		id="$(cg-object-id -c "$OPTARG" 2>/dev/null)" || id="$OPTARG"
+	else
+		optfail
+	fi
+done
+
+if [ -z "$id" ]; then
 	id="$(cg-object-id -c)"
 fi
 
-dest=$1
+dest=${ARGS[0]}
 
 ([ "$dest" ] && [ "$id" ]) || usage
 
diff --git a/cg-patch b/cg-patch
index 2aecd1a..153376e 100755
--- a/cg-patch
+++ b/cg-patch
@@ -70,7 +70,7 @@ redzone_border()
 
 
 reverse=
-if [ "$1" = "-R" ]; then
+if [ "${ARGS[0]}" = "-R" ]; then
 	reverse=1
 	shift
 fi
diff --git a/cg-reset b/cg-reset
index dbd69c6..38b7361 100755
--- a/cg-reset
+++ b/cg-reset
@@ -20,7 +20,7 @@ _git_requires_root=1
 . ${COGITO_LIB}cg-Xlib || exit 1
 deprecated_alias cg-reset cg-cancel
 
-[ "$1" ] && die "this command takes no parameters; use cg-restore to restore individual files"
+[ "${ARGS[0]}" ] && die "this command takes no parameters; use cg-restore to restore individual files"
 
 if ! [ -s $_git/HEAD ]; then
 	rm -f $_git/HEAD
diff --git a/cg-seek b/cg-seek
index f07b90c..d2aeb0a 100755
--- a/cg-seek
+++ b/cg-seek
@@ -24,7 +24,7 @@ _git_requires_root=1
 
 . ${COGITO_LIB}cg-Xlib || exit 1
 
-dstcommit=$1
+dstcommit=${ARGS[0]}
 
 
 [ -s $_git/blocked ] && grep -vq '^seeked from ' $_git/blocked && die "action blocked: $(cat $_git/blocked)"


-- 
Regards,
Pavel Roskin

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2005-10-12  5:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-12  5:57 [PATCH]: Use ARGS, not positional arguments Pavel Roskin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).