git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Simplified the invocation of command action in submodule
@ 2008-01-09  3:59 imyousuf
  2008-01-09  8:19 ` Junio C Hamano
  2008-01-09  8:59 ` Johannes Sixt
  0 siblings, 2 replies; 12+ messages in thread
From: imyousuf @ 2008-01-09  3:59 UTC (permalink / raw)
  To: git; +Cc: gitster, Imran M Yousuf, Imran M Yousuf

From: Imran M Yousuf <imran@smartitengineering.com>

- Simplified the invocation of action.
- Changed switch case based action invoke rather more direct command
invocation. Previously first switch case was used to go through $@ and
determine the action, i.e. add, init, update etc, and second switch case
just to invoke the action. It is modified to determine the action name in
the first case structure instead and later just invoke it.

Signed-off-by: Imran M Yousuf <imyousuf@smartitengineering.com>
---
 git-submodule.sh |   32 ++++++++++++--------------------
 1 files changed, 12 insertions(+), 20 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index ad9fe62..8a29382 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -16,6 +16,7 @@ update=
 status=
 quiet=
 cached=
+command=
 
 #
 # print stuff on stdout unless -q was specified
@@ -293,20 +294,23 @@ modules_list()
 	done
 }
 
+# command specifies the whole function name since 
+# one of theirs prefix is module not modules
 while test $# != 0
 do
 	case "$1" in
 	add)
 		add=1
+		command="module_$1"
 		;;
 	init)
-		init=1
+		command="modules_$1"
 		;;
 	update)
-		update=1
+		command="modules_$1"
 		;;
 	status)
-		status=1
+		command="modules_list"
 		;;
 	-q|--quiet)
 		quiet=1
@@ -320,7 +324,7 @@ do
 		branch="$2"; shift
 		;;
 	--cached)
-		cached=1
+		command="modules_list"
 		;;
 	--)
 		break
@@ -345,20 +349,8 @@ case "$add,$branch" in
 	;;
 esac
 
-case "$add,$init,$update,$status,$cached" in
-1,,,,)
-	module_add "$@"
-	;;
-,1,,,)
-	modules_init "$@"
-	;;
-,,1,,)
-	modules_update "$@"
-	;;
-,,,*,*)
-	modules_list "$@"
-	;;
-*)
+if [ -z $command ]; then 
 	usage
-	;;
-esac
+else
+	"$command" "$@"
+fi
-- 
1.5.3.7

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2008-01-10  3:05 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-09  3:59 [PATCH] Simplified the invocation of command action in submodule imyousuf
2008-01-09  8:19 ` Junio C Hamano
2008-01-09  8:23   ` Imran M Yousuf
2008-01-09  8:59 ` Johannes Sixt
2008-01-09  9:07   ` Imran M Yousuf
2008-01-09  9:15     ` Johannes Sixt
2008-01-09  9:51   ` Imran M Yousuf
2008-01-09 10:01     ` Johannes Sixt
2008-01-09 10:06       ` Imran M Yousuf
2008-01-09 10:27       ` Junio C Hamano
2008-01-09 10:24     ` Lars Hjemli
2008-01-10  3:05       ` Imran M Yousuf

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).