{"thread":{"id":"13382","subject":"[PATCH v2 1/5] git-submodule.sh: Add Long Usage instead of simple usage","startedAt":"2008-05-05T09:09:38Z","lastAt":"2008-05-19T03:48:43Z","messageCount":13,"participants":["imyousuf@gmail.com","Junio C Hamano","Imran M Yousuf","Johan Herland","Sverre Rabbelier","Johannes Schindelin"],"isPatch":true,"patchVersion":2,"patchTotal":5},"messages":[{"id":"76099","messageId":"1209978582-5785-1-git-send-email-imyousuf@gmail.com","threadId":"13382","inReplyTo":null,"subject":"[PATCH v2 1/5] git-submodule.sh: Add Long Usage instead of simple usage","fromName":"","fromEmail":"imyousuf@gmail.com","sentAt":"2008-05-05T09:09:38Z","receivedAt":"2008-05-05T09:09:38Z","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":"76100","messageId":"1209978582-5785-2-git-send-email-imyousuf@gmail.com","threadId":"13382","inReplyTo":"1209978582-5785-1-git-send-email-imyousuf@gmail.com","subject":"[PATCH v2 2/5] git-submodule.sh: Add recurse subcommand with basic options","fromName":"","fromEmail":"imyousuf@gmail.com","sentAt":"2008-05-05T09:09:39Z","receivedAt":"2008-05-05T09:09:39Z","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":"76102","messageId":"1209978582-5785-3-git-send-email-imyousuf@gmail.com","threadId":"13382","inReplyTo":"1209978582-5785-2-git-send-email-imyousuf@gmail.com","subject":"[PATCH v2 3/5] git-submodule.sh: Add Custom argument input support to git submodule recurse subcommand","fromName":"","fromEmail":"imyousuf@gmail.com","sentAt":"2008-05-05T09:09:40Z","receivedAt":"2008-05-05T09:09:40Z","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":"76101","messageId":"1209978582-5785-4-git-send-email-imyousuf@gmail.com","threadId":"13382","inReplyTo":"1209978582-5785-3-git-send-email-imyousuf@gmail.com","subject":"[PATCH v2 4/5] git-submodule.sh: Add pre command argument to git submodule recurse subcommand","fromName":"","fromEmail":"imyousuf@gmail.com","sentAt":"2008-05-05T09:09:41Z","receivedAt":"2008-05-05T09:09:41Z","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":"76103","messageId":"1209978582-5785-5-git-send-email-imyousuf@gmail.com","threadId":"13382","inReplyTo":"1209978582-5785-4-git-send-email-imyousuf@gmail.com","subject":"[PATCH v2 5/5] Documentation/git-submodule.txt: Add documentation for the recurse subcommand","fromName":"","fromEmail":"imyousuf@gmail.com","sentAt":"2008-05-05T09:09:42Z","receivedAt":"2008-05-05T09:09:42Z","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":"76670","messageId":"7vprrs1fns.fsf@gitster.siamese.dyndns.org","threadId":"13382","inReplyTo":"1209978582-5785-2-git-send-email-imyousuf@gmail.com","subject":"Re: [PATCH v2 2/5] git-submodule.sh: Add recurse subcommand with basic options","fromName":"Junio C Hamano","fromEmail":"junio@pobox.com","sentAt":"2008-05-12T01:20:55Z","receivedAt":"2008-05-12T01:20:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"imyousuf@gmail.com writes:\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> \tgit-submodule recurse [-q|--quiet] [-e|--exit-after-error]\n> \t[-d|--depth <recursion depth>] [-b|--breadth-first]\n> \t<git command> [<arguments> ...]\n\nIs there a reason to limit the command that can be run per submodule to\nonly \"git\" commands?  To me, this \"recurse\" looks like a glorified \"find\"\ncommand that can trigger its action only to submodule directories, but\nlimits what can be given to its -exec option to \"git\" commands.  While it\nwould not make sense to give certain git command to recurse (e.g. neither\n\"git show 65ea3b8\" nor \"git clone $there\" would make any sense), it would\nbe handy if we can give certain non-git commands to it (e.g. \"du -sh\").\n\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\nEverybody else seems to spell \"<do-something>_submodule\"; should this be\nany different?\n\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\nMicronit; s/Returns/Return/.  A sentence that begins with a capitalized\nverb in comments is almost always in imperative mood, not third-person\nsingular present.\n\n> +\telif test -d \"$1\"/.git\n> +\tthen\n> +\t\treturn 0\n> +\tfi\n> +}\n\nOtherwise, what does it return?  Do you need elif there, or just \"else\"?\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\nThis makes me wonder if you should be iterating over .gitmodules, or\nperhaps you may want to iterate over output of git-ls-files (picking\nentries of gitlink type).  How should a local change that adds a new\nsubmodule or removes an existing submodule, or moves an existing submodule\ninteract with \"submodule recurse\"? \n\nAlso the same micronits (s/Incrementing/Increment/; s/Decremented/Decrement/).\n\nEven if iterating over .gitmodules entries is a good idea, I suspect that\nsed script is too fragile.  Doesn't .gitmodules use the same format as git\nconfiguration files, allowing spaces around values, value quoting and\ntrailing comments on the same line?\n\n> +# This actually traverses a submodule; checks whether the its initialized\n> +# or not, does nothing if not initialized.\n\ns/the //;?\n\n> +traverse_module()\n> +{\n> +\t# Will work in the submodule if and only if its initialized\n> +\tinitialize_sub_module \"$1\" &&\n\n\"initialize_sub_module\" does not sound like a function that checks if it\nis initialized, but more like a function to, eh, initialize the submodule.\nPerhaps the function should be renamed to make it clearer that it is a\npredicate?\n\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\ns/than/then/;?\n\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\nDying before doing further damage to the repository tree may be a good\nidea, but I did not see the calling loop in traverse_submodules pay\nattention to the exit code from here.\n\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\nIs \"git-clone\" a good example to give here?  What would that mean to\nrecurse into each submodule directories in a superproject to run \"clone\"?\n\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\nHuh?\n\n\t$ a='1 2 3'\n        $ expr $a : '[1-9]'\n\texpr: syntax error\n\t$ expr \"$a\" : '[1-9]'\n        1\n        $ z=$(expr $a : '[1-9]')\n\texpr: syntax error\n\t$ z=$(expr \"$a\" : '[1-9]')\n        $ echo $z\n        1\n        $ echo \"$(expr $a : '[1-9]')\"\n\texpr: syntax error\n        $ echo \"$(expr \"$a\" : '[1-9]')\"\n        1\n\nIf you want to make sure that $(( ... )) would not choke with given \"$1\",\nyou can check by attempting to do a simple $(( ... )) to see if it errors\nout, which would be simpler.\n\n\tif test -z \"$1\"\n        then\n        \t...\n\telif ! echo $(( \"$1\" + 0 )) >/dev/null\n        then\n        \tdie \"$1 is not an integer\"\n\t...\n"},{"id":"76804","messageId":"7v7idzxhwp.fsf@gitster.siamese.dyndns.org","threadId":"13382","inReplyTo":"1209978582-5785-3-git-send-email-imyousuf@gmail.com","subject":"Re: [PATCH v2 3/5] git-submodule.sh: Add Custom argument input support to git submodule recurse subcommand","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-05-12T22:43:34Z","receivedAt":"2008-05-12T22:43:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"imyousuf@gmail.com writes:\n\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> \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\nIs it only me who finds this UI (and the one 4/5 further introduces)\nsomewhat clumsy and extremely ugly?\n\nI am almost tempted to suggest going to the extreme and spawn interactive\nshell in each repository directory, like this:\n\n    toplevel$ git submodule recurse -a\n    (info) Submodule b is not initialized and skipped\n    (info) git submodule recurse 'a'\n    (info) we now give you a shell in that directory.  Do whatever you\n    (info) like and type cntl-D (or \"exit\") once you are done.\n    toplevel/a$ git checkout\n    toplevel/a$ exit\n    (info) Submodule d is not initialized and skipped\n    (info) git submodule recurse '.'\n    (info) we now give you a shell in that directory.  Do whatever you\n    (info) like and type cntl-D (or \"exit\") once you are done.\n    toplevel/.$ git checkout\n    toplevel/.$ exit\n    (info) git submodule recurse recursion ended.\n    toplevel$\n\nso that the users can do whatever they want there.\n\nIf we want a useful and flexible \"recurse\", perhaps the only thing we need\nto do is a command that lists a submodule directory path, one path at a\ntime, in optionally different traversal order and depth cutoff, so that\nthe user can feed it to xargs and do whatever they want to run in there.\n"},{"id":"76836","messageId":"7bfdc29a0805122340t7edef1fdl837392b0c480e1@mail.gmail.com","threadId":"13382","inReplyTo":"7vprrs1fns.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH v2 2/5] git-submodule.sh: Add recurse subcommand with basic options","fromName":"Imran M Yousuf","fromEmail":"imyousuf@gmail.com","sentAt":"2008-05-13T06:40:25Z","receivedAt":"2008-05-13T06:40:25Z","isPatch":true,"sender":{"key":"imyousuf@gmail.com","avatar":"https://gravatar.com/avatar/fda3c870262849d03c7b9c4d288842e128d6d80769fa7bc2d22731b7597928be?d=mp&s=160"},"body":"On Mon, May 12, 2008 at 7:20 AM, Junio C Hamano <junio@pobox.com> wrote:\n> imyousuf@gmail.com writes:\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>  Is there a reason to limit the command that can be run per submodule to\n>  only \"git\" commands?  To me, this \"recurse\" looks like a glorified \"find\"\n>  command that can trigger its action only to submodule directories, but\n>  limits what can be given to its -exec option to \"git\" commands.  While it\n>  would not make sense to give certain git command to recurse (e.g. neither\n>  \"git show 65ea3b8\" nor \"git clone $there\" would make any sense), it would\n>  be handy if we can give certain non-git commands to it (e.g. \"du -sh\").\n\nI do agree how the recurse command looks, but considering that it is a\n'git submodule' subcommand I thought having a general command might\nhave faced a greater criticism from the community. Similarly about not\nallowing certain git commands is also in my list for the later version\nas it would require a bigger discussion in the community.\n\n>\n>\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>  Everybody else seems to spell \"<do-something>_submodule\"; should this be\n>  any different?\n>\n>\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>\n>  Micronit; s/Returns/Return/.  A sentence that begins with a capitalized\n>  verb in comments is almost always in imperative mood, not third-person\n>  singular present.\n>\n\nGot it, thanks for the correction.\n\n>\n>  > +     elif test -d \"$1\"/.git\n>  > +     then\n>  > +             return 0\n>  > +     fi\n>  > +}\n>\n>  Otherwise, what does it return?  Do you need elif there, or just \"else\"?\n>\n\nYup, else would be sufficient. Sorry for the mistake\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 makes me wonder if you should be iterating over .gitmodules, or\n>  perhaps you may want to iterate over output of git-ls-files (picking\n>  entries of gitlink type).  How should a local change that adds a new\n>  submodule or removes an existing submodule, or moves an existing submodule\n>  interact with \"submodule recurse\"?\n\nActually once I am done with the recurse command I was planning to add\nsubmodule mv and rm subcommands :). About the git-ls-files command yes\nthat is also an option, but in case of move it would require editing\n.gitmodules and .git/config. AFAIK user need to currently manually\nedit them for updating, hoping to write a shell script to get it done.\n\nAbout it interacting with these changes, as long as the .gitmodules\nfile is updated correctly it should not be a problem, but if it\nbecomes inconsistent then it will chokes. In this regard, I checked\nhow 'git submodule update' works and it uses git-ls-fiiles --stage\nwith grep to find the gitlinks path and then search them through\n.git/config, but it also faces the same problem if move is done\nmanually without changing the files. Also to be noted is the status\ncommand also uses git-ls-files.\n\nThe reason why I did .gitsubmodule is I want to introduce auto-init\nand update as an option, and plan to do it once the basic recurse\npatches are accepted :). Then reading the .gitmodules would have been\nnecessary.\n\nAbout the sed script another option would be to use -\n\ngit config -f ./.gitmodules --get-regexp '^submodule\\..*\\.path$' |\nsed -n -e 's|^submodule\\.\\(.*\\)\\.path \\(.*\\)$|\\2|p'\n\nWill using this be preferable? I think so :).\n\n>\n>  Also the same micronits (s/Incrementing/Increment/; s/Decremented/Decrement/).\n>\n>  Even if iterating over .gitmodules entries is a good idea, I suspect that\n>  sed script is too fragile.  Doesn't .gitmodules use the same format as git\n>  configuration files, allowing spaces around values, value quoting and\n>  trailing comments on the same line?\n\nI agree on the fragile point and I think I will replace it with the\none I mentioned above.\n\n>\n>\n>  > +# This actually traverses a submodule; checks whether the its initialized\n>  > +# or not, does nothing if not initialized.\n>\n>  s/the //;?\n>\n>\n>  > +traverse_module()\n>  > +{\n>  > +     # Will work in the submodule if and only if its initialized\n>  > +     initialize_sub_module \"$1\" &&\n>\n>  \"initialize_sub_module\" does not sound like a function that checks if it\n>  is initialized, but more like a function to, eh, initialize the submodule.\n>  Perhaps the function should be renamed to make it clearer that it is a\n>  predicate?\n\nI thought of renaming it but I was a bit lazy as I am writing another\npatch for auto initialize :).\n\n>\n>\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>\n>  s/than/then/;?\n>\n>\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>\n>  Dying before doing further damage to the repository tree may be a good\n>  idea, but I did not see the calling loop in traverse_submodules pay\n>  attention to the exit code from here.\n\nThanks for pointing out this bug, will fix it in the next version.\n\n>\n>\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>\n>  Is \"git-clone\" a good example to give here?  What would that mean to\n>  recurse into each submodule directories in a superproject to run \"clone\"?\n>\n\nI agree that git-clone is infact a bad example, will remove it :).\n\n>\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>\n>  Huh?\n>\n>         $ a='1 2 3'\n>         $ expr $a : '[1-9]'\n>         expr: syntax error\n>         $ expr \"$a\" : '[1-9]'\n>         1\n>         $ z=$(expr $a : '[1-9]')\n>         expr: syntax error\n>         $ z=$(expr \"$a\" : '[1-9]')\n>         $ echo $z\n>         1\n>         $ echo \"$(expr $a : '[1-9]')\"\n>         expr: syntax error\n>         $ echo \"$(expr \"$a\" : '[1-9]')\"\n>         1\n>\n>  If you want to make sure that $(( ... )) would not choke with given \"$1\",\n>  you can check by attempting to do a simple $(( ... )) to see if it errors\n>  out, which would be simpler.\n>\n>\n>         if test -z \"$1\"\n>         then\n>                 ...\n>         elif ! echo $(( \"$1\" + 0 )) >/dev/null\n>         then\n>                 die \"$1 is not an integer\"\n>         ...\n\nThis was what I was looking for a simpler and cleaner way :), thanks a\nlot Junio.\n\nBTW: its nice to see your emails once again :).\n\nBest regards,\n\nImran\n\n>\n>\n\n\n\n-- \nImran M Yousuf\nEmail: imran@smartitengineering.com\nMobile: +880-1711402557\n"},{"id":"77226","messageId":"200805181527.50983.johan@herland.net","threadId":"13382","inReplyTo":"7v7idzxhwp.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH v2 3/5] git-submodule.sh: Add Custom argument input support to git submodule recurse subcommand","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2008-05-18T13:27:50Z","receivedAt":"2008-05-18T13:27:50Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"On Tuesday 13 May 2008, Junio C Hamano wrote:\n> If we want a useful and flexible \"recurse\", perhaps the only thing we need\n> to do is a command that lists a submodule directory path, one path at a\n> time, in optionally different traversal order and depth cutoff, so that\n> the user can feed it to xargs and do whatever they want to run in there.\n\nYes! As more and more porcelains on top of the git submodule plumbing is\ncreated, this is definitely something that is (or will be) sorely needed.\n\n\n...Johan\n\n-- \nJohan Herland, <johan@herland.net>\nwww.herland.net\n"},{"id":"77227","messageId":"bd6139dc0805180636o4c5141c5vee559290832a4f03@mail.gmail.com","threadId":"13382","inReplyTo":"7v7idzxhwp.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH v2 3/5] git-submodule.sh: Add Custom argument input support to git submodule recurse subcommand","fromName":"Sverre Rabbelier","fromEmail":"alturin@gmail.com","sentAt":"2008-05-18T13:36:10Z","receivedAt":"2008-05-18T13:36:10Z","isPatch":true,"sender":{"key":"alturin@gmail.com","avatar":null},"body":"On Tue, May 13, 2008 at 12:43 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> If we want a useful and flexible \"recurse\", perhaps the only thing we need\n> to do is a command that lists a submodule directory path, one path at a\n> time, in optionally different traversal order and depth cutoff, so that\n> the user can feed it to xargs and do whatever they want to run in there.\n\nHow about Windows? Do we want to depend on something like\nhttp://gnuwin32.sourceforge.net/packages/findutils.htm or does msysgit\nship with xargs? (Or do we not intend to build internal commands upon\nthis system and leave using the output of \"recurse\" to the user?)\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"77231","messageId":"alpine.DEB.1.00.0805181627320.30431@racer","threadId":"13382","inReplyTo":"bd6139dc0805180636o4c5141c5vee559290832a4f03@mail.gmail.com","subject":"Re: [PATCH v2 3/5] git-submodule.sh: Add Custom argument input support to git submodule recurse subcommand","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-05-18T15:32:10Z","receivedAt":"2008-05-18T15:32:10Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 18 May 2008, Sverre Rabbelier wrote:\n\n> On Tue, May 13, 2008 at 12:43 AM, Junio C Hamano <gitster@pobox.com> \n> wrote:\n>\n> > If we want a useful and flexible \"recurse\", perhaps the only thing we \n> > need to do is a command that lists a submodule directory path, one \n> > path at a time, in optionally different traversal order and depth \n> > cutoff, so that the user can feed it to xargs and do whatever they \n> > want to run in there.\n> \n> How about Windows? Do we want to depend on something like \n> http://gnuwin32.sourceforge.net/packages/findutils.htm or does msysgit \n> ship with xargs? (Or do we not intend to build internal commands upon \n> this system and leave using the output of \"recurse\" to the user?)\n\ngit-repack already relies on \"find\", and if you have no silly naming \nscheme *1*, you do not need \"xargs\".  Besides, we do ship xargs.exe.\n\nCiao,\nDscho\n\n*1* Oops, this is Windows, right?\n"},{"id":"77232","messageId":"bd6139dc0805180834q57e1d4a0ieef2683ff82a9b54@mail.gmail.com","threadId":"13382","inReplyTo":"alpine.DEB.1.00.0805181627320.30431@racer","subject":"Re: [PATCH v2 3/5] git-submodule.sh: Add Custom argument input support to git submodule recurse subcommand","fromName":"Sverre Rabbelier","fromEmail":"alturin@gmail.com","sentAt":"2008-05-18T15:34:31Z","receivedAt":"2008-05-18T15:34:31Z","isPatch":true,"sender":{"key":"alturin@gmail.com","avatar":null},"body":"On Sun, May 18, 2008 at 5:32 PM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n> git-repack already relies on \"find\", and if you have no silly naming\n> scheme *1*, you do not need \"xargs\".  Besides, we do ship xargs.exe.\n\nOk, awesome, sounds like a good solution to me then.\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"77250","messageId":"7bfdc29a0805182048i1d7a06saf0fda0e0582fcae@mail.gmail.com","threadId":"13382","inReplyTo":"7v7idzxhwp.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH v2 3/5] git-submodule.sh: Add Custom argument input support to git submodule recurse subcommand","fromName":"Imran M Yousuf","fromEmail":"imyousuf@gmail.com","sentAt":"2008-05-19T03:48:43Z","receivedAt":"2008-05-19T03:48:43Z","isPatch":true,"sender":{"key":"imyousuf@gmail.com","avatar":"https://gravatar.com/avatar/fda3c870262849d03c7b9c4d288842e128d6d80769fa7bc2d22731b7597928be?d=mp&s=160"},"body":"On Tue, May 13, 2008 at 4:43 AM, Junio C Hamano <gitster@pobox.com> wrote:\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>.......\n> If we want a useful and flexible \"recurse\", perhaps the only thing we need\n> to do is a command that lists a submodule directory path, one path at a\n> time, in optionally different traversal order and depth cutoff, so that\n> the user can feed it to xargs and do whatever they want to run in there.\n>\nI am not sure whether I understand it correctly or not, we could\nsimply provide the shell window by invoking 'sh', right? If we do that\nthen is there need to use xargs? I am not particularly experienced\nwith xargs, I was thinking of something as follows:\n\n#!/bin/sh\necho \"Submodule a\"\n(\nPS1=\"module/submodule$\" sh\n)\necho \"\" #In case of ctrl+D to ensure that there is a blank line\necho \"Submodule a ends\"\n\nI do agree that it would be powerful enough to serve all the necessary\npurpose for traversing git submodules. If my assumption is right in\nwhat we want then I will resubmit the patch with required changes.\n\n-- \nImran M Yousuf\n"}]}