{"thread":{"id":"13381","subject":"[PATCH] git-submodule.sh: Add Long Usage instead of simple usage","startedAt":"2008-05-05T08:44:07Z","lastAt":"2008-05-05T09:08:12Z","messageCount":10,"participants":["imyousuf@gmail.com","Imran M Yousuf"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"76088","messageId":"1209977051-25896-1-git-send-email-imyousuf@gmail.com","threadId":"13381","inReplyTo":null,"subject":"[PATCH] git-submodule.sh: Add Long Usage instead of simple usage","fromName":"","fromEmail":"imyousuf@gmail.com","sentAt":"2008-05-05T08:44:07Z","receivedAt":"2008-05-05T08:44:07Z","isPatch":true,"sender":{"key":"imyousuf@gmail.com","avatar":"https://gravatar.com/avatar/fda3c870262849d03c7b9c4d288842e128d6d80769fa7bc2d22731b7597928be?d=mp&s=160"},"body":"From: Imran M Yousuf <imyousuf@smartitengineering.com>\n\nWith the already available commands the synopsis is quite hard to\nread; thus converted it to Long usage instead. In process also\nupdated the file comment.\n\nSigned-off-by: Imran M Yousuf <imyousuf@smartitengineering.com>\n---\n git-submodule.sh |   13 +++++++++----\n 1 files changed, 9 insertions(+), 4 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex ce0f00c..a5ee2e5 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -1,12 +1,17 @@\n #!/bin/sh\n #\n-# git-submodules.sh: add, init, update or list git submodules\n+# git-submodules.sh: add, init, update, summary or status git submodules\n #\n # Copyright (c) 2007 Lars Hjemli\n \n-USAGE=\"[--quiet] [--cached] \\\n-[add <repo> [-b branch]|status|init|update|summary [-n|--summary-limit <n>] [<commit>]] \\\n-[--] [<path>...]\"\n+USAGE=\"<command> <options>\n+Use $0 -h for more details\"\n+# Did not use '\\' at the end of the lines to ensure that each synopsis\n+# are in a separate line\n+LONG_USAGE=\"$0 add [-q|--quiet] [-b|--branch branch] <repository> [<path>]\n+$0 [status] [-q|--quiet] [-c|--cached] [--] [<path>...]\n+$0 init|update [-q|--quiet] [--] [<path>...]\n+$0 summary [--cached] [-n|--summary-limit <n>] [<commit>]\"\n OPTIONS_SPEC=\n . git-sh-setup\n require_work_tree\n-- \n1.5.4.2\n"},{"id":"76089","messageId":"1209977051-25896-2-git-send-email-imyousuf@gmail.com","threadId":"13381","inReplyTo":"1209977051-25896-1-git-send-email-imyousuf@gmail.com","subject":"[PATCH] git-submodule.sh: Add recurse subcommand with basic options","fromName":"","fromEmail":"imyousuf@gmail.com","sentAt":"2008-05-05T08:44:08Z","receivedAt":"2008-05-05T08:44:08Z","isPatch":true,"sender":{"key":"imyousuf@gmail.com","avatar":"https://gravatar.com/avatar/fda3c870262849d03c7b9c4d288842e128d6d80769fa7bc2d22731b7597928be?d=mp&s=160"},"body":"From: Imran M Yousuf <imyousuf@smartitengineering.com>\n\nThe purpose of the recurse command in the git submodule is to recurse\na command in its submodule. For example if one wants to do a diff on its\nproject with submodules at once, one can simply do\n\tgit-submodule recurse diff HEAD\nand would see the diff for all the modules it contains.\n\nThe recurse commands behavior can be customized with several arguments\nthat it accepts. The synopsis for the recurse command is:\n\n\tgit-submodule recurse [-q|--quiet] [-e|--exit-after-error]\n\t[-d|--depth <recursion depth>] [-b|--breadth-first]\n\t<git command> [<arguments> ...]\n\nThere are commands that can fail for a certain submodule but succeed for\nothers; if one wants to stop execution once the top level module's execution\nfails, one can specify [-e|--exit-after-error]. It will ensure that once\nexecution of git <command> fails in the top level module it will not recurse\ninto its submodules.\n\nIf the project has submodule hierarchy upto n depth and we want to restrict\nrecursion to (n-p) depth; we can use the [-d|--depth <recursion depth>] option.\nValue has to be greater than 0 and command will at least recurse into the first\ndepth. If depth is specified to p than all depths <= p will be recursed over.\n\nWhile discussion on the recurse command one thing which was put forward\nin several occassions is that there might be scenario where a command should be\nexecuted over the child module before the parent module.\n\n\tFor such scenario [-b|--breadth-first] option can be used; one use case\nin particular presented as an example is git commit; where almost everybody\nmentioned that they prefer to commit the child module before the parent and\ndefault will enable just that.\n\n\tE.g. p -> a, b, c, e; a ->d is a module structure. If the following command is\nused,\n\n\tgit submodule recurse commit -a\n\nit will execute git commit -a in the following sequence - d, a, b, c, e, p.\n\n\tNow if one want to instead go in a breadth first manner then one can\nspecify -b option. E.g. if the above command is -\n\n\tgit submodule recurse -b commit -a\n\nit will execute git commit -a in the following sequence - p, a, d, b, c, e.\n\nSigned-off-by: Imran M Yousuf <imyousuf@smartitengineering.com>\n---\n git-submodule.sh |  132 +++++++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 files changed, 130 insertions(+), 2 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex a5ee2e5..8161d51 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -11,7 +11,8 @@ Use $0 -h for more details\"\n LONG_USAGE=\"$0 add [-q|--quiet] [-b|--branch branch] <repository> [<path>]\n $0 [status] [-q|--quiet] [-c|--cached] [--] [<path>...]\n $0 init|update [-q|--quiet] [--] [<path>...]\n-$0 summary [--cached] [-n|--summary-limit <n>] [<commit>]\"\n+$0 summary [--cached] [-n|--summary-limit <n>] [<commit>]\n+$0 recurse [-q|--quiet] [-e|--exit-after-error] [-d|--depth <recursion depth>] [-b|--breadth-first] <git command> [<args> ...]\"\n OPTIONS_SPEC=\n . git-sh-setup\n require_work_tree\n@@ -20,6 +21,10 @@ command=\n branch=\n quiet=\n cached=\n+depth=0\n+current_depth=0\n+depth_first=1\n+on_error=\n \n #\n # print stuff on stdout unless -q was specified\n@@ -580,6 +585,129 @@ cmd_status()\n \tdone\n }\n \n+# Check whether the submodule is initialized or not\n+initialize_sub_module()\n+{\n+\tif test ! -d \"$1\"/.git\n+\tthen\n+\t\tsay \"Submodule $1 is not initialized and skipped\"\n+\t\treturn 1\n+\t# Returns true if submodule is already initialized\n+\telif test -d \"$1\"/.git\n+\tthen\n+\t\treturn 0\n+\tfi\n+}\n+\n+# This function simply checks whether the depth is traverseable in terms of\n+# depth and if so then it sequentially traverses its submodules\n+traverse_submodules()\n+{\n+\t# If current depth is the range specified than it will continue\n+\t# else return with success\n+\tif test \"$depth\" -gt 0 &&\n+\t\ttest \"$current_depth\" -ge \"$depth\"\n+\tthen\n+\t\treturn 0;\n+\tfi\n+\t# If submodules exists than it will traverse over them\n+\tif test -f .gitmodules\n+\tthen\n+\t\t# Incrementing the depth for the next level of submodules\n+\t\tcurrent_depth=$(($current_depth + 1))\n+                for mod_path in `sed -n -e 's/path = //p' .gitmodules`; do\n+                        traverse_module \"$mod_path\" \"$@\"\n+                done\n+\t\t# Decremented the depth to bring it back to the depth of\n+\t\t# the current submodule\n+\t\tcurrent_depth=$(($current_depth - 1))\n+\tfi\n+}\n+\n+# This actually traverses a submodule; checks whether the its initialized\n+# or not, does nothing if not initialized.\n+traverse_module()\n+{\n+\t# Will work in the submodule if and only if its initialized\n+\tinitialize_sub_module \"$1\" &&\n+\t(\n+\t\tsubmod_path=\"$1\"\n+\t\tshift\n+\t\tcd \"$submod_path\"\n+\t\t# If depth-first is specified in that case submodules are\n+\t\t# are traversed before executing the command on this submodule\n+\t\ttest -n \"$depth_first\" && traverse_submodules \"$@\"\n+\t\t# pwd is mentioned in order to enable the ser to distinguish\n+\t\t# between same name modules, e.g. a/lib and b/lib.\n+\t\tsay \"git submodule recurse $submod_path $*\"\n+\t\tgit \"$@\"\n+\t\t# if exit on error is specifed than script will exit if any\n+\t\t# command fails. As there is no transaction there will be\n+\t\t# no rollback either\n+\t\t# TODO - If possible facilitate transaction\n+\t\tif test \"$?\" -ne 0 && test -n \"$on_error\"\n+\t\tthen\n+\t\t\tdie \"FAILED: git submodule $submod_path $*\"\n+\t\tfi\n+\t\t# If depth-first is not specified in that case submodules are\n+\t\t# are traversed after executing the command on this submodule\n+\t\ttest -z \"$depth_first\" && traverse_submodules \"$@\"\n+\t)\n+}\n+\n+# Propagates or recurses over all the submodules at any depth with any\n+# git command, e.g. git-clone, git-status, git-commit etc., with the\n+# arguments supplied exactly as it would have been supplied to the command\n+# otherwise. This actually starts the recursive propagation.\n+cmd_recurse() {\n+\twhile :\n+\tdo\n+\t\tcase \"$1\" in\n+\t\t-q|--quiet)\n+\t\t\tquiet=1\n+\t\t\t;;\n+\t\t-d|--depth)\n+\t\t\tshift\n+\t\t\tif test -z \"$1\"\n+\t\t\tthen\n+\t\t\t\techo \"No <recursion depth> specified\"\n+\t\t\t\tusage\n+\t\t\t# Arithmatic operation will give an error if depth is not number\n+\t\t\t# thus chose to check intergerness with regular expression.\n+\t\t\t# $1 is underquoted becuase the expr is in quotation\n+\t\t\telif test \"$(expr $1 : '[1-9][0-9]*')\" -eq \"$(expr $1 : '.*')\"\n+\t\t\tthen\n+\t\t\t\tdepth=\"$1\"\n+\t\t\telse\n+\t\t\t\techo \"<recursion depth> not an integer\"\n+\t\t\t\tusage\n+\t\t\tfi\n+\t\t\t;;\n+\t\t-b|--breadth-first)\n+\t\t\tdepth_first=\n+\t\t\t;;\n+\t\t-e|--exit-after-error)\n+\t\t\ton_error=1\n+\t\t\t;;\n+\t\t-*)\n+\t\t\tusage\n+\t\t\t;;\n+\t\t*)\n+\t\t\tbreak\n+\t\t\t;;\n+\t\tesac\n+\t\tshift\n+\tdone\n+\ttest \"$#\" -le 0 && die \"No git command specified\"\n+\tproject_home=\"$(pwd)\"\n+\tif test -d \"$project_home\"/.git/\n+\tthen\n+\t\ttraverse_module . \"$@\"\n+\telse\n+\t\tdie \"$project_home not a git repo thus exiting\"\n+\tfi\n+}\n+\n # This loop parses the command line arguments to find the\n # subcommand name to dispatch.  Parsing of the subcommand specific\n # options are primarily done by the subcommand implementations.\n@@ -589,7 +717,7 @@ cmd_status()\n while test $# != 0 && test -z \"$command\"\n do\n \tcase \"$1\" in\n-\tadd | init | update | status | summary)\n+\tadd | init | update | status | summary |recurse)\n \t\tcommand=$1\n \t\t;;\n \t-q|--quiet)\n-- \n1.5.4.2\n"},{"id":"76090","messageId":"1209977051-25896-3-git-send-email-imyousuf@gmail.com","threadId":"13381","inReplyTo":"1209977051-25896-2-git-send-email-imyousuf@gmail.com","subject":"[PATCH] git-submodule.sh: Add Custom argument input support to git submodule recurse subcommand","fromName":"","fromEmail":"imyousuf@gmail.com","sentAt":"2008-05-05T08:44:09Z","receivedAt":"2008-05-05T08:44:09Z","isPatch":true,"sender":{"key":"imyousuf@gmail.com","avatar":"https://gravatar.com/avatar/fda3c870262849d03c7b9c4d288842e128d6d80769fa7bc2d22731b7597928be?d=mp&s=160"},"body":"From: Imran M Yousuf <imyousuf@smartitengineering.com>\n\nThere is a scenario which has been put forward several times in\ndiscussion over the recurse subcommand and it is that commands chould have\ndifferent arguments for different modules.\n\nFor example, one module could want to checkout 'master', while another might want\nto checkout 'work'. The [-a|--customized-argument] argument provides platform\njust for that. Consider the following command and its followup for further info:\n\n\tgit submodule recurse -a checkout\n\n\tSubmodule b is not initialized and skipped\n\tgit submodule recurse a checkout\n\tPlease provide an argument: master\n\tPress y to provide another arg...\n\tgit checkout master\n\tAlready on branch \"master\"\n\tSubmodule d is not initialized and skipped\n\tgit submodule recurse . checkout\n\tPlease provide an argument: master\n\tPress y to provide another arg...\n\tgit checkout master\n\tAlready on branch \"master\"\n\nThis command would also come in handy for diffs and other commands.\n\nSigned-off-by: Imran M Yousuf <imyousuf@smartitengineering.com>\n---\n git-submodule.sh |   53 +++++++++++++++++++++++++++++++++++++++++++++++++----\n 1 files changed, 49 insertions(+), 4 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 8161d51..314652d 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -12,7 +12,7 @@ LONG_USAGE=\"$0 add [-q|--quiet] [-b|--branch branch] <repository> [<path>]\n $0 [status] [-q|--quiet] [-c|--cached] [--] [<path>...]\n $0 init|update [-q|--quiet] [--] [<path>...]\n $0 summary [--cached] [-n|--summary-limit <n>] [<commit>]\n-$0 recurse [-q|--quiet] [-e|--exit-after-error] [-d|--depth <recursion depth>] [-b|--breadth-first] <git command> [<args> ...]\"\n+$0 recurse [-q|--quiet] [-e|--exit-after-error] [-d|--depth <recursion depth>] [-b|--breadth-first] [-a|--customized-argument] <git command> [<args> ...]\"\n OPTIONS_SPEC=\n . git-sh-setup\n require_work_tree\n@@ -25,6 +25,8 @@ depth=0\n current_depth=0\n depth_first=1\n on_error=\n+use_custom_args=\n+custom_args=\n \n #\n # print stuff on stdout unless -q was specified\n@@ -585,6 +587,40 @@ cmd_status()\n \tdone\n }\n \n+# Take arguments from user to pass as custom arguments and execute the command\n+exec_with_custom_args()\n+{\n+\tinput=\n+\targ_index=0\n+\teval_str=\"set \"\n+\twhile test $# -gt 0\n+\tdo\n+\t\targ_index=$(($arg_index + 1))\n+\t\tvar='$'\"$arg_index\"\n+\t\tinput=\"$1\"\n+\t\teval_str=\"$eval_str $var \\\"$input\\\"\"\n+\t\tshift\n+\tdone\n+\twhile :\n+\tdo\n+\t\targ_index=$(($arg_index + 1))\n+\t\tprintf \"Please provide an argument: \"\n+\t\tread input\n+\t\tvar='$'\"$arg_index\"\n+\t\teval_str=\"$eval_str $var \\\"$input\\\"\"\n+\t\tprintf \"Press y to provide another arg... \"\n+\t\tread keypress\n+\t\tif test \"$keypress\" != \"y\" &&\n+\t\t\ttest \"$keypress\" != \"Y\"\n+\t\tthen\n+\t\t\tbreak\n+\t\tfi\n+\tdone\n+\teval $eval_str\n+\tsay \"$*\"\n+\t\"$@\"\n+}\n+\n # Check whether the submodule is initialized or not\n initialize_sub_module()\n {\n@@ -637,10 +673,16 @@ traverse_module()\n \t\t# If depth-first is specified in that case submodules are\n \t\t# are traversed before executing the command on this submodule\n \t\ttest -n \"$depth_first\" && traverse_submodules \"$@\"\n-\t\t# pwd is mentioned in order to enable the ser to distinguish\n-\t\t# between same name modules, e.g. a/lib and b/lib.\n \t\tsay \"git submodule recurse $submod_path $*\"\n-\t\tgit \"$@\"\n+\t\tif test -n \"$use_custom_args\"\n+\t\tthen\n+\t\t\t# Execute the commands after taking the arguments\n+\t\t\t# Please note that one input is for one argument\n+\t\t\t# only.\n+\t\t\texec_with_custom_args git \"$@\"\n+\t\telse\n+\t\t\tgit \"$@\"\n+\t\tfi\n \t\t# if exit on error is specifed than script will exit if any\n \t\t# command fails. As there is no transaction there will be\n \t\t# no rollback either\n@@ -689,6 +731,9 @@ cmd_recurse() {\n \t\t-e|--exit-after-error)\n \t\t\ton_error=1\n \t\t\t;;\n+\t\t-a|--customized-argument)\n+\t\t\tuse_custom_args=1\n+\t\t\t;;\n \t\t-*)\n \t\t\tusage\n \t\t\t;;\n-- \n1.5.4.2\n"},{"id":"76091","messageId":"1209977051-25896-4-git-send-email-imyousuf@gmail.com","threadId":"13381","inReplyTo":"1209977051-25896-3-git-send-email-imyousuf@gmail.com","subject":"[PATCH] git-submodule.sh: Add pre command argument to git submodule recurse subcommand","fromName":"","fromEmail":"imyousuf@gmail.com","sentAt":"2008-05-05T08:44:10Z","receivedAt":"2008-05-05T08:44:10Z","isPatch":true,"sender":{"key":"imyousuf@gmail.com","avatar":"https://gravatar.com/avatar/fda3c870262849d03c7b9c4d288842e128d6d80769fa7bc2d22731b7597928be?d=mp&s=160"},"body":"From: Imran M Yousuf <imyousuf@smartitengineering.com>\n\nI usually feel that when typing a command, being able to see some options\ncome in handy. For example if I can see the available branches before checking\nout a branch that would be useful, IOW, if I could do 'git branch' before git\ncheckout it would be helpful.\n\nIt is now possible using the [-p|--pre-command] option. Using this\nsubcommand command argument one can actually execute another command before\nspecifying the arguments or the original command getting executed.\n\n\tgit submodule recurse -a -p checkout\n\nit will prompt the user for the pre command until one is satisfied and later\nthe original command with the custom argument will get executed.\n\nSigned-off-by: Imran M Yousuf <imyousuf@smartitengineering.com>\n---\n git-submodule.sh |   29 ++++++++++++++++++++++++++++-\n 1 files changed, 28 insertions(+), 1 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 314652d..dd80850 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -12,7 +12,7 @@ LONG_USAGE=\"$0 add [-q|--quiet] [-b|--branch branch] <repository> [<path>]\n $0 [status] [-q|--quiet] [-c|--cached] [--] [<path>...]\n $0 init|update [-q|--quiet] [--] [<path>...]\n $0 summary [--cached] [-n|--summary-limit <n>] [<commit>]\n-$0 recurse [-q|--quiet] [-e|--exit-after-error] [-d|--depth <recursion depth>] [-b|--breadth-first] [-a|--customized-argument] <git command> [<args> ...]\"\n+$0 recurse [-q|--quiet] [-e|--exit-after-error] [-d|--depth <recursion depth>] [-b|--breadth-first] [-a|--customized-argument] [-p|--pre-command] <git command> [<args> ...]\"\n OPTIONS_SPEC=\n . git-sh-setup\n require_work_tree\n@@ -27,6 +27,7 @@ depth_first=1\n on_error=\n use_custom_args=\n custom_args=\n+pre_cmd=\n \n #\n # print stuff on stdout unless -q was specified\n@@ -587,6 +588,28 @@ cmd_status()\n \tdone\n }\n \n+# Take command from user and execute it until user wants to discontinue\n+do_pre_command()\n+{\n+\tsay \"Starting pre-comamnd execution!\"\n+\twhile :\n+\tdo\n+\t\t(\n+\t\t\tprintf \"Please provide a command: \"\n+\t\t\tread pre_command\n+\t\t\ttest -z \"$pre_command\" ||\n+\t\t\teval \"$pre_command\"\n+\t\t)\n+\t\tprintf \"Press y to continue with another shell command... \"\n+\t\tread keypress\n+\t\tif test \"$keypress\" != \"y\" &&\n+\t\t\ttest \"$keypress\" != \"Y\"\n+\t\tthen\n+\t\t\tbreak\n+\t\tfi\n+\tdone\n+}\n+\n # Take arguments from user to pass as custom arguments and execute the command\n exec_with_custom_args()\n {\n@@ -673,6 +696,7 @@ traverse_module()\n \t\t# If depth-first is specified in that case submodules are\n \t\t# are traversed before executing the command on this submodule\n \t\ttest -n \"$depth_first\" && traverse_submodules \"$@\"\n+\t\ttest -n \"$pre_cmd\" && do_pre_command\n \t\tsay \"git submodule recurse $submod_path $*\"\n \t\tif test -n \"$use_custom_args\"\n \t\tthen\n@@ -734,6 +758,9 @@ cmd_recurse() {\n \t\t-a|--customized-argument)\n \t\t\tuse_custom_args=1\n \t\t\t;;\n+\t\t-p|--pre-command)\n+\t\t\tpre_cmd=1\n+\t\t\t;;\n \t\t-*)\n \t\t\tusage\n \t\t\t;;\n-- \n1.5.4.2\n"},{"id":"76092","messageId":"1209977051-25896-5-git-send-email-imyousuf@gmail.com","threadId":"13381","inReplyTo":"1209977051-25896-4-git-send-email-imyousuf@gmail.com","subject":"[PATCH] Documentation/git-submodule.txt: Add documentation for the recurse subcommand","fromName":"","fromEmail":"imyousuf@gmail.com","sentAt":"2008-05-05T08:44:11Z","receivedAt":"2008-05-05T08:44:11Z","isPatch":true,"sender":{"key":"imyousuf@gmail.com","avatar":"https://gravatar.com/avatar/fda3c870262849d03c7b9c4d288842e128d6d80769fa7bc2d22731b7597928be?d=mp&s=160"},"body":"From: Imran M Yousuf <imyousuf@smartitengineering.com>\n\nDocumentation with brief description is added for the recurse\nsucommand along with its arguments and their nature.\n\nSigned-off-by: Imran M Yousuf <imyousuf@smartitengineering.com>\n---\n Documentation/git-submodule.txt |   35 +++++++++++++++++++++++++++++++++++\n 1 files changed, 35 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\nindex 6ffd896..9a95522 100644\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -13,6 +13,10 @@ SYNOPSIS\n 'git-submodule' [--quiet] status [--cached] [--] [<path>...]\n 'git-submodule' [--quiet] [init|update] [--] [<path>...]\n 'git-submodule' [--quiet] summary [--summary-limit <n>] [commit] [--] [<path>...]\n+'git-submodule' recurse [-q|--quiet] [-e|--exit-after-error]\n+\t\t[-d|--depth <recursion depth>] [-b|--breadth-first]\n+\t\t[-a|--customized-argument] [-p|--pre-command]\n+\t\t<git command> [<arg> ...]\"\n \n \n COMMANDS\n@@ -54,6 +58,10 @@ summary::\n \tin the submodule between the given super project commit and the\n \tindex or working tree (switched by --cached) are shown.\n \n+recurse::\n+\tRecurse, IOW propagate, command to its submodules if they are\n+\tinitialized.\n+\n OPTIONS\n -------\n -q, --quiet::\n@@ -78,6 +86,33 @@ OPTIONS\n \tPath to submodule(s). When specified this will restrict the command\n \tto only operate on the submodules found at the specified paths.\n \n+-e, --exit-after-error::\n+\tThis option is only valid for the recurse command. If its provided then\n+\tthen command will not be recursed into any other module once a command\n+\thas failed\n+-d, --depth <recursion depth>::\n+\tThis option is only valid for the recurse command. If its provided then\n+\tthen the command will be recursed upto <recursion depth> only.\n+-b, --breadth-first::\n+\tThis option is only valid for the recurse command. If its provided then\n+\tthe command will execute in the current node before traversing to its\n+\tchild, else it will first traverse the children before executing in the\n+\tcurrent node.\n+-a, --customized-argument::\n+\tThis option is only valid for the recurse command. If its provided then\n+\tuser will be prompted for an argument for the <git command> specified.\n+\tIts particularly useful when one wants to supply different arguments\n+\tfor the same <git command> for different submodules; for example,\n+\tchecking out a branch, one might want branch to differ from submodule\n+\tto submodule\n+-p, --pre-command::\n+\tThis option is only valid for the recurse command. If its provided then\n+\tuser will be prompted for a shell command, e.g. 'ls -al', 'pwd' etc.\n+<git command> [<arg>...]::\n+\tAny git command and their argument. For example, to get the status use\n+\t'status' as <git command> and '-s' or '-o' or any other 'git status'\n+\targuments as <arg>\n+\n FILES\n -----\n When initializing submodules, a .gitmodules file in the top-level directory\n-- \n1.5.4.2\n"},{"id":"76094","messageId":"7bfdc29a0805050207l3ef55648u9a8cbd6e57711e0c@mail.gmail.com","threadId":"13381","inReplyTo":"1209977051-25896-1-git-send-email-imyousuf@gmail.com","subject":"Re: [PATCH] git-submodule.sh: Add Long Usage instead of simple usage","fromName":"Imran M Yousuf","fromEmail":"imyousuf@gmail.com","sentAt":"2008-05-05T09:07:08Z","receivedAt":"2008-05-05T09:07:08Z","isPatch":true,"sender":{"key":"imyousuf@gmail.com","avatar":"https://gravatar.com/avatar/fda3c870262849d03c7b9c4d288842e128d6d80769fa7bc2d22731b7597928be?d=mp&s=160"},"body":"Sorry for the inconvenience, but please ignore this patch as it was\nnot generated with -n and version number :(.\n\n- best regards,\n\nImran\n\nOn Mon, May 5, 2008 at 2:44 PM,  <imyousuf@gmail.com> wrote:\n> From: Imran M Yousuf <imyousuf@smartitengineering.com>\n>\n>  With the already available commands the synopsis is quite hard to\n>  read; thus converted it to Long usage instead. In process also\n>  updated the file comment.\n>\n>  Signed-off-by: Imran M Yousuf <imyousuf@smartitengineering.com>\n>  ---\n>   git-submodule.sh |   13 +++++++++----\n>   1 files changed, 9 insertions(+), 4 deletions(-)\n>\n>  diff --git a/git-submodule.sh b/git-submodule.sh\n>  index ce0f00c..a5ee2e5 100755\n>  --- a/git-submodule.sh\n>  +++ b/git-submodule.sh\n>  @@ -1,12 +1,17 @@\n>   #!/bin/sh\n>   #\n>  -# git-submodules.sh: add, init, update or list git submodules\n>  +# git-submodules.sh: add, init, update, summary or status git submodules\n>   #\n>   # Copyright (c) 2007 Lars Hjemli\n>\n>  -USAGE=\"[--quiet] [--cached] \\\n>  -[add <repo> [-b branch]|status|init|update|summary [-n|--summary-limit <n>] [<commit>]] \\\n>  -[--] [<path>...]\"\n>  +USAGE=\"<command> <options>\n>  +Use $0 -h for more details\"\n>  +# Did not use '\\' at the end of the lines to ensure that each synopsis\n>  +# are in a separate line\n>  +LONG_USAGE=\"$0 add [-q|--quiet] [-b|--branch branch] <repository> [<path>]\n>  +$0 [status] [-q|--quiet] [-c|--cached] [--] [<path>...]\n>  +$0 init|update [-q|--quiet] [--] [<path>...]\n>  +$0 summary [--cached] [-n|--summary-limit <n>] [<commit>]\"\n>   OPTIONS_SPEC=\n>   . git-sh-setup\n>   require_work_tree\n>  --\n>  1.5.4.2\n>\n>\n"},{"id":"76095","messageId":"7bfdc29a0805050207s69f533e8ib78e6acdf7576ef6@mail.gmail.com","threadId":"13381","inReplyTo":"1209977051-25896-5-git-send-email-imyousuf@gmail.com","subject":"Re: [PATCH] Documentation/git-submodule.txt: Add documentation for the recurse subcommand","fromName":"Imran M Yousuf","fromEmail":"imyousuf@gmail.com","sentAt":"2008-05-05T09:07:26Z","receivedAt":"2008-05-05T09:07:26Z","isPatch":true,"sender":{"key":"imyousuf@gmail.com","avatar":"https://gravatar.com/avatar/fda3c870262849d03c7b9c4d288842e128d6d80769fa7bc2d22731b7597928be?d=mp&s=160"},"body":"Sorry for the inconvenience, but please ignore this patch as it was\nnot generated with -n and version number :(.\n\n- best regards,\n\nImran\n\n\nOn Mon, May 5, 2008 at 2:44 PM,  <imyousuf@gmail.com> wrote:\n> From: Imran M Yousuf <imyousuf@smartitengineering.com>\n>\n>  Documentation with brief description is added for the recurse\n>  sucommand along with its arguments and their nature.\n>\n>  Signed-off-by: Imran M Yousuf <imyousuf@smartitengineering.com>\n>  ---\n>   Documentation/git-submodule.txt |   35 +++++++++++++++++++++++++++++++++++\n>   1 files changed, 35 insertions(+), 0 deletions(-)\n>\n>  diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\n>  index 6ffd896..9a95522 100644\n>  --- a/Documentation/git-submodule.txt\n>  +++ b/Documentation/git-submodule.txt\n>  @@ -13,6 +13,10 @@ SYNOPSIS\n>   'git-submodule' [--quiet] status [--cached] [--] [<path>...]\n>   'git-submodule' [--quiet] [init|update] [--] [<path>...]\n>   'git-submodule' [--quiet] summary [--summary-limit <n>] [commit] [--] [<path>...]\n>  +'git-submodule' recurse [-q|--quiet] [-e|--exit-after-error]\n>  +               [-d|--depth <recursion depth>] [-b|--breadth-first]\n>  +               [-a|--customized-argument] [-p|--pre-command]\n>  +               <git command> [<arg> ...]\"\n>\n>\n>   COMMANDS\n>  @@ -54,6 +58,10 @@ summary::\n>         in the submodule between the given super project commit and the\n>         index or working tree (switched by --cached) are shown.\n>\n>  +recurse::\n>  +       Recurse, IOW propagate, command to its submodules if they are\n>  +       initialized.\n>  +\n>   OPTIONS\n>   -------\n>   -q, --quiet::\n>  @@ -78,6 +86,33 @@ OPTIONS\n>         Path to submodule(s). When specified this will restrict the command\n>         to only operate on the submodules found at the specified paths.\n>\n>  +-e, --exit-after-error::\n>  +       This option is only valid for the recurse command. If its provided then\n>  +       then command will not be recursed into any other module once a command\n>  +       has failed\n>  +-d, --depth <recursion depth>::\n>  +       This option is only valid for the recurse command. If its provided then\n>  +       then the command will be recursed upto <recursion depth> only.\n>  +-b, --breadth-first::\n>  +       This option is only valid for the recurse command. If its provided then\n>  +       the command will execute in the current node before traversing to its\n>  +       child, else it will first traverse the children before executing in the\n>  +       current node.\n>  +-a, --customized-argument::\n>  +       This option is only valid for the recurse command. If its provided then\n>  +       user will be prompted for an argument for the <git command> specified.\n>  +       Its particularly useful when one wants to supply different arguments\n>  +       for the same <git command> for different submodules; for example,\n>  +       checking out a branch, one might want branch to differ from submodule\n>  +       to submodule\n>  +-p, --pre-command::\n>  +       This option is only valid for the recurse command. If its provided then\n>  +       user will be prompted for a shell command, e.g. 'ls -al', 'pwd' etc.\n>  +<git command> [<arg>...]::\n>  +       Any git command and their argument. For example, to get the status use\n>  +       'status' as <git command> and '-s' or '-o' or any other 'git status'\n>  +       arguments as <arg>\n>  +\n>   FILES\n>   -----\n>   When initializing submodules, a .gitmodules file in the top-level directory\n>  --\n>  1.5.4.2\n>\n>\n\n\n\n-- \nImran M Yousuf\nEntrepreneur & Software Engineer\nSmart IT Engineering\nDhaka, Bangladesh\nEmail: imran@smartitengineering.com\nMobile: +880-1711402557\n"},{"id":"76096","messageId":"7bfdc29a0805050207n6d2f8122kbb58d8e5389d90eb@mail.gmail.com","threadId":"13381","inReplyTo":"1209977051-25896-4-git-send-email-imyousuf@gmail.com","subject":"Re: [PATCH] git-submodule.sh: Add pre command argument to git submodule recurse subcommand","fromName":"Imran M Yousuf","fromEmail":"imyousuf@gmail.com","sentAt":"2008-05-05T09:07:42Z","receivedAt":"2008-05-05T09:07:42Z","isPatch":true,"sender":{"key":"imyousuf@gmail.com","avatar":"https://gravatar.com/avatar/fda3c870262849d03c7b9c4d288842e128d6d80769fa7bc2d22731b7597928be?d=mp&s=160"},"body":"Sorry for the inconvenience, but please ignore this patch as it was\nnot generated with -n and version number :(.\n\n- best regards,\n\nImran\n\n\nOn Mon, May 5, 2008 at 2:44 PM,  <imyousuf@gmail.com> wrote:\n> From: Imran M Yousuf <imyousuf@smartitengineering.com>\n>\n>  I usually feel that when typing a command, being able to see some options\n>  come in handy. For example if I can see the available branches before checking\n>  out a branch that would be useful, IOW, if I could do 'git branch' before git\n>  checkout it would be helpful.\n>\n>  It is now possible using the [-p|--pre-command] option. Using this\n>  subcommand command argument one can actually execute another command before\n>  specifying the arguments or the original command getting executed.\n>\n>         git submodule recurse -a -p checkout\n>\n>  it will prompt the user for the pre command until one is satisfied and later\n>  the original command with the custom argument will get executed.\n>\n>  Signed-off-by: Imran M Yousuf <imyousuf@smartitengineering.com>\n>  ---\n>   git-submodule.sh |   29 ++++++++++++++++++++++++++++-\n>   1 files changed, 28 insertions(+), 1 deletions(-)\n>\n>  diff --git a/git-submodule.sh b/git-submodule.sh\n>  index 314652d..dd80850 100755\n>  --- a/git-submodule.sh\n>  +++ b/git-submodule.sh\n>  @@ -12,7 +12,7 @@ LONG_USAGE=\"$0 add [-q|--quiet] [-b|--branch branch] <repository> [<path>]\n>   $0 [status] [-q|--quiet] [-c|--cached] [--] [<path>...]\n>   $0 init|update [-q|--quiet] [--] [<path>...]\n>   $0 summary [--cached] [-n|--summary-limit <n>] [<commit>]\n>  -$0 recurse [-q|--quiet] [-e|--exit-after-error] [-d|--depth <recursion depth>] [-b|--breadth-first] [-a|--customized-argument] <git command> [<args> ...]\"\n>  +$0 recurse [-q|--quiet] [-e|--exit-after-error] [-d|--depth <recursion depth>] [-b|--breadth-first] [-a|--customized-argument] [-p|--pre-command] <git command> [<args> ...]\"\n>   OPTIONS_SPEC=\n>   . git-sh-setup\n>   require_work_tree\n>  @@ -27,6 +27,7 @@ depth_first=1\n>   on_error=\n>   use_custom_args=\n>   custom_args=\n>  +pre_cmd=\n>\n>   #\n>   # print stuff on stdout unless -q was specified\n>  @@ -587,6 +588,28 @@ cmd_status()\n>         done\n>   }\n>\n>  +# Take command from user and execute it until user wants to discontinue\n>  +do_pre_command()\n>  +{\n>  +       say \"Starting pre-comamnd execution!\"\n>  +       while :\n>  +       do\n>  +               (\n>  +                       printf \"Please provide a command: \"\n>  +                       read pre_command\n>  +                       test -z \"$pre_command\" ||\n>  +                       eval \"$pre_command\"\n>  +               )\n>  +               printf \"Press y to continue with another shell command... \"\n>  +               read keypress\n>  +               if test \"$keypress\" != \"y\" &&\n>  +                       test \"$keypress\" != \"Y\"\n>  +               then\n>  +                       break\n>  +               fi\n>  +       done\n>  +}\n>  +\n>   # Take arguments from user to pass as custom arguments and execute the command\n>   exec_with_custom_args()\n>   {\n>  @@ -673,6 +696,7 @@ traverse_module()\n>                 # If depth-first is specified in that case submodules are\n>                 # are traversed before executing the command on this submodule\n>                 test -n \"$depth_first\" && traverse_submodules \"$@\"\n>  +               test -n \"$pre_cmd\" && do_pre_command\n>                 say \"git submodule recurse $submod_path $*\"\n>                 if test -n \"$use_custom_args\"\n>                 then\n>  @@ -734,6 +758,9 @@ cmd_recurse() {\n>                 -a|--customized-argument)\n>                         use_custom_args=1\n>                         ;;\n>  +               -p|--pre-command)\n>  +                       pre_cmd=1\n>  +                       ;;\n>                 -*)\n>                         usage\n>                         ;;\n>  --\n>  1.5.4.2\n>\n>\n\n\n\n-- \nImran M Yousuf\nEntrepreneur & Software Engineer\nSmart IT Engineering\nDhaka, Bangladesh\nEmail: imran@smartitengineering.com\nMobile: +880-1711402557\n"},{"id":"76097","messageId":"7bfdc29a0805050207i7978043u6084cf328be4bec4@mail.gmail.com","threadId":"13381","inReplyTo":"1209977051-25896-3-git-send-email-imyousuf@gmail.com","subject":"Re: [PATCH] git-submodule.sh: Add Custom argument input support to git submodule recurse subcommand","fromName":"Imran M Yousuf","fromEmail":"imyousuf@gmail.com","sentAt":"2008-05-05T09:07:56Z","receivedAt":"2008-05-05T09:07:56Z","isPatch":true,"sender":{"key":"imyousuf@gmail.com","avatar":"https://gravatar.com/avatar/fda3c870262849d03c7b9c4d288842e128d6d80769fa7bc2d22731b7597928be?d=mp&s=160"},"body":"Sorry for the inconvenience, but please ignore this patch as it was\nnot generated with -n and version number :(.\n\n- best regards,\n\nImran\n\n\nOn Mon, May 5, 2008 at 2:44 PM,  <imyousuf@gmail.com> wrote:\n> From: Imran M Yousuf <imyousuf@smartitengineering.com>\n>\n>  There is a scenario which has been put forward several times in\n>  discussion over the recurse subcommand and it is that commands chould have\n>  different arguments for different modules.\n>\n>  For example, one module could want to checkout 'master', while another might want\n>  to checkout 'work'. The [-a|--customized-argument] argument provides platform\n>  just for that. Consider the following command and its followup for further info:\n>\n>         git submodule recurse -a checkout\n>\n>         Submodule b is not initialized and skipped\n>         git submodule recurse a checkout\n>         Please provide an argument: master\n>         Press y to provide another arg...\n>         git checkout master\n>         Already on branch \"master\"\n>         Submodule d is not initialized and skipped\n>         git submodule recurse . checkout\n>         Please provide an argument: master\n>         Press y to provide another arg...\n>         git checkout master\n>         Already on branch \"master\"\n>\n>  This command would also come in handy for diffs and other commands.\n>\n>  Signed-off-by: Imran M Yousuf <imyousuf@smartitengineering.com>\n>  ---\n>   git-submodule.sh |   53 +++++++++++++++++++++++++++++++++++++++++++++++++----\n>   1 files changed, 49 insertions(+), 4 deletions(-)\n>\n>  diff --git a/git-submodule.sh b/git-submodule.sh\n>  index 8161d51..314652d 100755\n>  --- a/git-submodule.sh\n>  +++ b/git-submodule.sh\n>  @@ -12,7 +12,7 @@ LONG_USAGE=\"$0 add [-q|--quiet] [-b|--branch branch] <repository> [<path>]\n>   $0 [status] [-q|--quiet] [-c|--cached] [--] [<path>...]\n>   $0 init|update [-q|--quiet] [--] [<path>...]\n>   $0 summary [--cached] [-n|--summary-limit <n>] [<commit>]\n>  -$0 recurse [-q|--quiet] [-e|--exit-after-error] [-d|--depth <recursion depth>] [-b|--breadth-first] <git command> [<args> ...]\"\n>  +$0 recurse [-q|--quiet] [-e|--exit-after-error] [-d|--depth <recursion depth>] [-b|--breadth-first] [-a|--customized-argument] <git command> [<args> ...]\"\n>   OPTIONS_SPEC=\n>   . git-sh-setup\n>   require_work_tree\n>  @@ -25,6 +25,8 @@ depth=0\n>   current_depth=0\n>   depth_first=1\n>   on_error=\n>  +use_custom_args=\n>  +custom_args=\n>\n>   #\n>   # print stuff on stdout unless -q was specified\n>  @@ -585,6 +587,40 @@ cmd_status()\n>         done\n>   }\n>\n>  +# Take arguments from user to pass as custom arguments and execute the command\n>  +exec_with_custom_args()\n>  +{\n>  +       input=\n>  +       arg_index=0\n>  +       eval_str=\"set \"\n>  +       while test $# -gt 0\n>  +       do\n>  +               arg_index=$(($arg_index + 1))\n>  +               var='$'\"$arg_index\"\n>  +               input=\"$1\"\n>  +               eval_str=\"$eval_str $var \\\"$input\\\"\"\n>  +               shift\n>  +       done\n>  +       while :\n>  +       do\n>  +               arg_index=$(($arg_index + 1))\n>  +               printf \"Please provide an argument: \"\n>  +               read input\n>  +               var='$'\"$arg_index\"\n>  +               eval_str=\"$eval_str $var \\\"$input\\\"\"\n>  +               printf \"Press y to provide another arg... \"\n>  +               read keypress\n>  +               if test \"$keypress\" != \"y\" &&\n>  +                       test \"$keypress\" != \"Y\"\n>  +               then\n>  +                       break\n>  +               fi\n>  +       done\n>  +       eval $eval_str\n>  +       say \"$*\"\n>  +       \"$@\"\n>  +}\n>  +\n>   # Check whether the submodule is initialized or not\n>   initialize_sub_module()\n>   {\n>  @@ -637,10 +673,16 @@ traverse_module()\n>                 # If depth-first is specified in that case submodules are\n>                 # are traversed before executing the command on this submodule\n>                 test -n \"$depth_first\" && traverse_submodules \"$@\"\n>  -               # pwd is mentioned in order to enable the ser to distinguish\n>  -               # between same name modules, e.g. a/lib and b/lib.\n>                 say \"git submodule recurse $submod_path $*\"\n>  -               git \"$@\"\n>  +               if test -n \"$use_custom_args\"\n>  +               then\n>  +                       # Execute the commands after taking the arguments\n>  +                       # Please note that one input is for one argument\n>  +                       # only.\n>  +                       exec_with_custom_args git \"$@\"\n>  +               else\n>  +                       git \"$@\"\n>  +               fi\n>                 # if exit on error is specifed than script will exit if any\n>                 # command fails. As there is no transaction there will be\n>                 # no rollback either\n>  @@ -689,6 +731,9 @@ cmd_recurse() {\n>                 -e|--exit-after-error)\n>                         on_error=1\n>                         ;;\n>  +               -a|--customized-argument)\n>  +                       use_custom_args=1\n>  +                       ;;\n>                 -*)\n>                         usage\n>                         ;;\n>  --\n>  1.5.4.2\n>\n>\n\n\n\n-- \nImran M Yousuf\nEntrepreneur & Software Engineer\nSmart IT Engineering\nDhaka, Bangladesh\nEmail: imran@smartitengineering.com\nMobile: +880-1711402557\n"},{"id":"76098","messageId":"7bfdc29a0805050208s1a460638ib6327453b18b2ec3@mail.gmail.com","threadId":"13381","inReplyTo":"1209977051-25896-2-git-send-email-imyousuf@gmail.com","subject":"Re: [PATCH] git-submodule.sh: Add recurse subcommand with basic options","fromName":"Imran M Yousuf","fromEmail":"imyousuf@gmail.com","sentAt":"2008-05-05T09:08:12Z","receivedAt":"2008-05-05T09:08:12Z","isPatch":true,"sender":{"key":"imyousuf@gmail.com","avatar":"https://gravatar.com/avatar/fda3c870262849d03c7b9c4d288842e128d6d80769fa7bc2d22731b7597928be?d=mp&s=160"},"body":"Sorry for the inconvenience, but please ignore this patch as it was\nnot generated with -n and version number :(.\n\n- best regards,\n\nImran\n\n\nOn Mon, May 5, 2008 at 2:44 PM,  <imyousuf@gmail.com> wrote:\n> From: Imran M Yousuf <imyousuf@smartitengineering.com>\n>\n>  The purpose of the recurse command in the git submodule is to recurse\n>  a command in its submodule. For example if one wants to do a diff on its\n>  project with submodules at once, one can simply do\n>         git-submodule recurse diff HEAD\n>  and would see the diff for all the modules it contains.\n>\n>  The recurse commands behavior can be customized with several arguments\n>  that it accepts. The synopsis for the recurse command is:\n>\n>         git-submodule recurse [-q|--quiet] [-e|--exit-after-error]\n>         [-d|--depth <recursion depth>] [-b|--breadth-first]\n>         <git command> [<arguments> ...]\n>\n>  There are commands that can fail for a certain submodule but succeed for\n>  others; if one wants to stop execution once the top level module's execution\n>  fails, one can specify [-e|--exit-after-error]. It will ensure that once\n>  execution of git <command> fails in the top level module it will not recurse\n>  into its submodules.\n>\n>  If the project has submodule hierarchy upto n depth and we want to restrict\n>  recursion to (n-p) depth; we can use the [-d|--depth <recursion depth>] option.\n>  Value has to be greater than 0 and command will at least recurse into the first\n>  depth. If depth is specified to p than all depths <= p will be recursed over.\n>\n>  While discussion on the recurse command one thing which was put forward\n>  in several occassions is that there might be scenario where a command should be\n>  executed over the child module before the parent module.\n>\n>         For such scenario [-b|--breadth-first] option can be used; one use case\n>  in particular presented as an example is git commit; where almost everybody\n>  mentioned that they prefer to commit the child module before the parent and\n>  default will enable just that.\n>\n>         E.g. p -> a, b, c, e; a ->d is a module structure. If the following command is\n>  used,\n>\n>         git submodule recurse commit -a\n>\n>  it will execute git commit -a in the following sequence - d, a, b, c, e, p.\n>\n>         Now if one want to instead go in a breadth first manner then one can\n>  specify -b option. E.g. if the above command is -\n>\n>         git submodule recurse -b commit -a\n>\n>  it will execute git commit -a in the following sequence - p, a, d, b, c, e.\n>\n>  Signed-off-by: Imran M Yousuf <imyousuf@smartitengineering.com>\n>  ---\n>   git-submodule.sh |  132 +++++++++++++++++++++++++++++++++++++++++++++++++++++-\n>   1 files changed, 130 insertions(+), 2 deletions(-)\n>\n>  diff --git a/git-submodule.sh b/git-submodule.sh\n>  index a5ee2e5..8161d51 100755\n>  --- a/git-submodule.sh\n>  +++ b/git-submodule.sh\n>  @@ -11,7 +11,8 @@ Use $0 -h for more details\"\n>   LONG_USAGE=\"$0 add [-q|--quiet] [-b|--branch branch] <repository> [<path>]\n>   $0 [status] [-q|--quiet] [-c|--cached] [--] [<path>...]\n>   $0 init|update [-q|--quiet] [--] [<path>...]\n>  -$0 summary [--cached] [-n|--summary-limit <n>] [<commit>]\"\n>  +$0 summary [--cached] [-n|--summary-limit <n>] [<commit>]\n>  +$0 recurse [-q|--quiet] [-e|--exit-after-error] [-d|--depth <recursion depth>] [-b|--breadth-first] <git command> [<args> ...]\"\n>   OPTIONS_SPEC=\n>   . git-sh-setup\n>   require_work_tree\n>  @@ -20,6 +21,10 @@ command=\n>   branch=\n>   quiet=\n>   cached=\n>  +depth=0\n>  +current_depth=0\n>  +depth_first=1\n>  +on_error=\n>\n>   #\n>   # print stuff on stdout unless -q was specified\n>  @@ -580,6 +585,129 @@ cmd_status()\n>         done\n>   }\n>\n>  +# Check whether the submodule is initialized or not\n>  +initialize_sub_module()\n>  +{\n>  +       if test ! -d \"$1\"/.git\n>  +       then\n>  +               say \"Submodule $1 is not initialized and skipped\"\n>  +               return 1\n>  +       # Returns true if submodule is already initialized\n>  +       elif test -d \"$1\"/.git\n>  +       then\n>  +               return 0\n>  +       fi\n>  +}\n>  +\n>  +# This function simply checks whether the depth is traverseable in terms of\n>  +# depth and if so then it sequentially traverses its submodules\n>  +traverse_submodules()\n>  +{\n>  +       # If current depth is the range specified than it will continue\n>  +       # else return with success\n>  +       if test \"$depth\" -gt 0 &&\n>  +               test \"$current_depth\" -ge \"$depth\"\n>  +       then\n>  +               return 0;\n>  +       fi\n>  +       # If submodules exists than it will traverse over them\n>  +       if test -f .gitmodules\n>  +       then\n>  +               # Incrementing the depth for the next level of submodules\n>  +               current_depth=$(($current_depth + 1))\n>  +                for mod_path in `sed -n -e 's/path = //p' .gitmodules`; do\n>  +                        traverse_module \"$mod_path\" \"$@\"\n>  +                done\n>  +               # Decremented the depth to bring it back to the depth of\n>  +               # the current submodule\n>  +               current_depth=$(($current_depth - 1))\n>  +       fi\n>  +}\n>  +\n>  +# This actually traverses a submodule; checks whether the its initialized\n>  +# or not, does nothing if not initialized.\n>  +traverse_module()\n>  +{\n>  +       # Will work in the submodule if and only if its initialized\n>  +       initialize_sub_module \"$1\" &&\n>  +       (\n>  +               submod_path=\"$1\"\n>  +               shift\n>  +               cd \"$submod_path\"\n>  +               # If depth-first is specified in that case submodules are\n>  +               # are traversed before executing the command on this submodule\n>  +               test -n \"$depth_first\" && traverse_submodules \"$@\"\n>  +               # pwd is mentioned in order to enable the ser to distinguish\n>  +               # between same name modules, e.g. a/lib and b/lib.\n>  +               say \"git submodule recurse $submod_path $*\"\n>  +               git \"$@\"\n>  +               # if exit on error is specifed than script will exit if any\n>  +               # command fails. As there is no transaction there will be\n>  +               # no rollback either\n>  +               # TODO - If possible facilitate transaction\n>  +               if test \"$?\" -ne 0 && test -n \"$on_error\"\n>  +               then\n>  +                       die \"FAILED: git submodule $submod_path $*\"\n>  +               fi\n>  +               # If depth-first is not specified in that case submodules are\n>  +               # are traversed after executing the command on this submodule\n>  +               test -z \"$depth_first\" && traverse_submodules \"$@\"\n>  +       )\n>  +}\n>  +\n>  +# Propagates or recurses over all the submodules at any depth with any\n>  +# git command, e.g. git-clone, git-status, git-commit etc., with the\n>  +# arguments supplied exactly as it would have been supplied to the command\n>  +# otherwise. This actually starts the recursive propagation.\n>  +cmd_recurse() {\n>  +       while :\n>  +       do\n>  +               case \"$1\" in\n>  +               -q|--quiet)\n>  +                       quiet=1\n>  +                       ;;\n>  +               -d|--depth)\n>  +                       shift\n>  +                       if test -z \"$1\"\n>  +                       then\n>  +                               echo \"No <recursion depth> specified\"\n>  +                               usage\n>  +                       # Arithmatic operation will give an error if depth is not number\n>  +                       # thus chose to check intergerness with regular expression.\n>  +                       # $1 is underquoted becuase the expr is in quotation\n>  +                       elif test \"$(expr $1 : '[1-9][0-9]*')\" -eq \"$(expr $1 : '.*')\"\n>  +                       then\n>  +                               depth=\"$1\"\n>  +                       else\n>  +                               echo \"<recursion depth> not an integer\"\n>  +                               usage\n>  +                       fi\n>  +                       ;;\n>  +               -b|--breadth-first)\n>  +                       depth_first=\n>  +                       ;;\n>  +               -e|--exit-after-error)\n>  +                       on_error=1\n>  +                       ;;\n>  +               -*)\n>  +                       usage\n>  +                       ;;\n>  +               *)\n>  +                       break\n>  +                       ;;\n>  +               esac\n>  +               shift\n>  +       done\n>  +       test \"$#\" -le 0 && die \"No git command specified\"\n>  +       project_home=\"$(pwd)\"\n>  +       if test -d \"$project_home\"/.git/\n>  +       then\n>  +               traverse_module . \"$@\"\n>  +       else\n>  +               die \"$project_home not a git repo thus exiting\"\n>  +       fi\n>  +}\n>  +\n>   # This loop parses the command line arguments to find the\n>   # subcommand name to dispatch.  Parsing of the subcommand specific\n>   # options are primarily done by the subcommand implementations.\n>  @@ -589,7 +717,7 @@ cmd_status()\n>   while test $# != 0 && test -z \"$command\"\n>   do\n>         case \"$1\" in\n>  -       add | init | update | status | summary)\n>  +       add | init | update | status | summary |recurse)\n>                 command=$1\n>                 ;;\n>         -q|--quiet)\n>  --\n>  1.5.4.2\n>\n>\n\n\n\n-- \nImran M Yousuf\nEntrepreneur & Software Engineer\nSmart IT Engineering\nDhaka, Bangladesh\nEmail: imran@smartitengineering.com\nMobile: +880-1711402557\n"}]}