{"thread":{"id":"17072","subject":"[PATCH v4] submodule: add --no-fetch parameter to update command","startedAt":"2009-01-10T02:10:06Z","lastAt":"2009-01-11T01:34:31Z","messageCount":9,"participants":["Fabian Franz","Johannes Schindelin","Nanako Shiraishi","Junio C Hamano"],"isPatch":true,"patchVersion":4,"patchTotal":null},"messages":[{"id":"99844","messageId":"1231553410-7541-1-git-send-email-git@fabian-franz.de","threadId":"17072","inReplyTo":null,"subject":"[PATCH v4] submodule: allow tracking of the newest revision of a branch in a submodule","fromName":"Fabian Franz","fromEmail":"git@fabian-franz.de","sentAt":"2009-01-10T02:10:06Z","receivedAt":"2009-01-10T02:10:06Z","isPatch":true,"sender":{"key":"git@fabian-franz.de","avatar":null},"body":"Submodules currently only allow tracking a specific revision\nand each update in a submodule leads to a new commit in the\nmaster repository. However some users may want to always track\nthe newest revision of a specific (named) tag or branch or HEAD.\nFor example the user might want to track a staging branch in all\nsubmodules.\n\nTo allow this the \"--track|-t <branch>\" parameter was added to\ngit-submodule.sh, which is added to .gitmodules config file as\nwell as \"track\" parameter.\n\nSigned-off-by: Fabian Franz <git@fabian-franz.de>\n---\n\nThis patch now uses the --assume-unchanged approach to be able to track any\nrevision in the submodule.\n\nIt adresses the issues that were in the comments for the previous patches.\n\nAnd it does even more, it consists of 5 patches:\n\n(1) allow tracking of the newest revision of a branch in a submodule\n----------------------------------------------------------------\n\nIs just handling tracked submodules the same way as if the sha1 sum\nwas directly in the index (i.e. detached head, checkout by sha1 id)\nonly that the information comes from the track parameter.\nHere one can either track local branches like master or remote branches\nvia track = origin/master or anything else that is a pathspec. \n(like: refs/remotes/origin/master)\n\n(2) add --no-fetch parameter to update command\n----------------------------------------------\n \nJunio commented that it was bad that the submodule update needed a\nonline connection to update. This was true even before the \"tracking\"\npatch and for normal operation can update --no-fetch be useful as well.\nThis was implemented by first fetching and then checking out instead\nof doing it in one step.\n\n(3) add --use-gitmodules parameter to update command \n----------------------------------------------------\n\nLars correctly commented that the track parameter should be read from\n.git/config and also added when init is used.\n\nHowever there _are_ uses for directly reading .gitmodules and such\nnot using .git/config for the track parameter.\n\nExample: I want to quickly change my tree to staging mode to test something:\n\n$ git checkout staging\n$ git submodule update -u\n\nNow it can be that: submodule one is at master, submodule 2 at staging and\nsubmodule3 at tagXYZ and all this was recorded in .gitmodules, which is more powerful than git submodule foreach \"git checkout staging\".\n\n(4) add +<branch> syntax for track to allow automatic pulling.\n--------------------------------------------------------------\n\nAs I inititially already tried, I want some branches that are automatically\npulling when I update the submodules, so I can use the submodule mechanism\nto update my tree with updates, but still keep my head attached to my branch.\n\nSyntax for the track parameter is here: +<branchname>\n\nAnd it does checkout or create branch based on the origin and then do a\ngit-pull.\n\nOf course conflicts arising need to be fixed manually like normal, but that\nis okay, as the person adding that to .git/config or .gitmodules knows what\nhe/she is doing.\n\n(5) add --recursive parameter to update command\n-----------------------------------------------\n\nI just need it. We have a fairly complex setup in the company I work for\nand now that we are migrating to git, we find that we have a complex software\ninside already one git repository.\n\nAnd this software is going to use git submodules as well for tracking vendor\ndependencies, but this can't (policy) be added to master repository as its\nan component by itself.\n\nAnyway recursive operation is lots of fun :).\n\nExample:\n\n$ git submodule update -r audio/\nEntering submodule path 'audio/software/'\nSubmodule path 'dependencies/vendor1': checked out \n'8b3b8ebca95d5a7e09760916ae38e4fe494ad2a2'\nLeaving submodule path 'audio/software/'\n\nAnd we have more software (X11) that can have submodules\ninside of submodules.\n\nSo, that is all and it works perfect for me and is suited to our\nneeds.\n\nLet me know, what you think.\n\nBest Wishes,\n\nFabian\n        \n Documentation/git-submodule.txt |   10 +++++-\n git-submodule.sh                |   64 +++++++++++++++++++++++++++++++++++---\n 2 files changed, 68 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\nindex 2f207fb..232697d 100644\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -9,7 +9,7 @@ git-submodule - Initialize, update or inspect submodules\n SYNOPSIS\n --------\n [verse]\n-'git submodule' [--quiet] add [-b branch] [--] <repository> <path>\n+'git submodule' [--quiet] add [-b branch] [-t|--track <branch>] [--] <repository> <path>\n 'git submodule' [--quiet] status [--cached] [--] [<path>...]\n 'git submodule' [--quiet] init [--] [<path>...]\n 'git submodule' [--quiet] update [--init] [--] [<path>...]\n@@ -118,6 +118,10 @@ update::\n If the submodule is not yet initialized, and you just want to use the\n setting as stored in .gitmodules, you can automatically initialize the\n submodule with the --init option.\n++\n+If you used --track or set the \"track\" option this will automatically checkout\n+the newest available revision instead of the commit specified in the index of\n+the containing repository.\n \n summary::\n \tShow commit summary between the given commit (defaults to HEAD) and\n@@ -159,6 +163,10 @@ OPTIONS\n --branch::\n \tBranch of repository to add as submodule.\n \n+-t::\n+--track::\n+\tBranch/Tag/HEAD (pathspec) of repository to track in a submodule.\n+\n --cached::\n \tThis option is only valid for status and summary commands.  These\n \tcommands typically use the commit found in the submodule HEAD, but\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 2f47e06..6af3d96 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -5,7 +5,7 @@\n # Copyright (c) 2007 Lars Hjemli\n \n USAGE=\"[--quiet] [--cached] \\\n-[add <repo> [-b branch] <path>]|[status|init|update [-i|--init]|summary [-n|--summary-limit <n>] [<commit>]] \\\n+[add <repo> [-b branch] [--track|-t <branch>] <path>]|[status|init|update [-i|--init]|summary [-n|--summary-limit <n>] [<commit>]] \\\n [--] [<path>...]|[foreach <command>]|[sync [--] [<path>...]]\"\n OPTIONS_SPEC=\n . git-sh-setup\n@@ -16,6 +16,7 @@ command=\n branch=\n quiet=\n cached=\n+track=\n \n #\n # print stuff on stdout unless -q was specified\n@@ -130,6 +131,11 @@ cmd_add()\n \t\t-q|--quiet)\n \t\t\tquiet=1\n \t\t\t;;\n+\t\t-t|--track)\n+\t\t\tcase \"$2\" in '') usage ;; esac\n+\t\t\ttrack=$2\n+\t\t\tshift\n+\t\t\t;;\n \t\t--)\n \t\t\tshift\n \t\t\tbreak\n@@ -201,8 +207,11 @@ cmd_add()\n \tgit add \"$path\" ||\n \tdie \"Failed to add submodule '$path'\"\n \n+\ttest -n \"$track\" && git-update-index --assume-unchanged \"$path\"\n+\n \tgit config -f .gitmodules submodule.\"$path\".path \"$path\" &&\n \tgit config -f .gitmodules submodule.\"$path\".url \"$repo\" &&\n+\tgit config -f .gitmodules submodule.\"$path\".track \"$track\" &&\n \tgit add .gitmodules ||\n \tdie \"Failed to register submodule '$path'\"\n }\n@@ -277,6 +286,10 @@ cmd_init()\n \t\tgit config submodule.\"$name\".url \"$url\" ||\n \t\tdie \"Failed to register url for submodule path '$path'\"\n \n+\t\ttrack=$(git config -f .gitmodules submodule.\"$name\".track)\n+\t\tgit config submodule.\"$name\".track \"$track\" ||\n+\t\tdie \"Failed to register track for submodule path '$path'\"\n+\n \t\tsay \"Submodule '$name' ($url) registered for path '$path'\"\n \tdone\n }\n@@ -328,6 +341,15 @@ cmd_update()\n \t\t\tcontinue\n \t\tfi\n \n+\t\ttrack=$(git config submodule.\"$name\".track)\n+\t\tif test -n \"$track\"\n+\t\tthen\n+\t\t\tgit-update-index --assume-unchanged \"$path\"\n+\t\t\tsha1=\"NULL\"\n+\t\telse\n+\t\t\tgit-update-index --no-assume-unchanged \"$path\"\n+\t\tfi\n+\n \t\tif ! test -d \"$path\"/.git -o -f \"$path\"/.git\n \t\tthen\n \t\t\tmodule_clone \"$path\" \"$url\" || exit\n@@ -345,11 +367,42 @@ cmd_update()\n \t\t\tthen\n \t\t\t\tforce=\"-f\"\n \t\t\tfi\n-\t\t\t(unset GIT_DIR; cd \"$path\" && git-fetch &&\n-\t\t\t\tgit-checkout $force -q \"$sha1\") ||\n+\n+\t\t\t# First fetch ...\n+\n+\t\t\t(unset GIT_DIR; cd \"$path\" &&\n+\t\t\t\tgit-fetch) ||\n+\t\t\tdie \"Unable to fetch in submodule path '$path'\"\n+\n+\t\t\tif test \"$sha1\" = \"NULL\"\n+\t\t\tthen\n+\t\t\t\t: ${track:=\"HEAD\"}\n+\n+\t\t\t\tsha1=$(unset GIT_DIR; cd \"$path\" &&\n+\t\t\t\t\tgit-rev-parse --verify --quiet \"$track\")\n+\n+\t\t\t\t# Only use $origin/$track path if the user\n+\t\t\t\t# supplied path does not work\n+\t\t\t\tif test -z \"$sha1\"\n+\t\t\t\tthen\n+\t\t\t\t\torigin=$(unset GIT_DIR; cd \"$path\" &&\n+\t\t\t\t\t\tget_default_remote) ||\n+\t\t\t\t\tdie \"Unable to get default remote destination in submodule path '$path'.\"\n+\t\t\t\t\ttrack=\"$origin/$track\"\n+\n+\t\t\t\t\tsha1=$(unset GIT_DIR; cd \"$path\" &&\n+\t\t\t\t\t\tgit-rev-parse --verify \"$track\") ||\n+\t\t\t\t\tdie \"Unable to find newest revision of '$track' in submodule path '$path'.\"\n+\t\t\t\tfi\n+\t\t\tfi\n+\n+\t\t\t# ... then checkout\n+\n+\t\t\t(unset GIT_DIR; cd \"$path\" &&\n+\t\t\t\t  git-checkout $force -q \"$sha1\") ||\n \t\t\tdie \"Unable to checkout '$sha1' in submodule path '$path'\"\n \n-\t\t\tsay \"Submodule path '$path': checked out '$sha1'\"\n+\t\t\tsay \"Submodule path '$path': checked out '$sha1'${track:+ ($track)}\"\n \t\tfi\n \tdone\n }\n@@ -596,7 +649,8 @@ cmd_status()\n \t\tset_name_rev \"$path\" \"$sha1\"\n \t\tif git diff-files --quiet -- \"$path\"\n \t\tthen\n-\t\t\tsay \" $sha1 $path$revname\"\n+\t\t\ttrack=$(git config submodule.\"$name\".track)\n+\t\t\tsay \" $sha1 $path$revname${track:+ (tracking \"$track\")}\"\n \t\telse\n \t\t\tif test -z \"$cached\"\n \t\t\tthen\n-- \n1.5.3.6\n"},{"id":"99843","messageId":"1231553410-7541-2-git-send-email-git@fabian-franz.de","threadId":"17072","inReplyTo":"1231553410-7541-1-git-send-email-git@fabian-franz.de","subject":"[PATCH v4] submodule: add --no-fetch parameter to update command","fromName":"Fabian Franz","fromEmail":"git@fabian-franz.de","sentAt":"2009-01-10T02:10:07Z","receivedAt":"2009-01-10T02:10:07Z","isPatch":true,"sender":{"key":"git@fabian-franz.de","avatar":null},"body":"git submodule update --no-fetch makes it possible to use git submodule\nupdate in complete offline mode by not fetching new revisions.\n\nSigned-off-by: Fabian Franz <git@fabian-franz.de>\n---\n Documentation/git-submodule.txt |    7 ++++++-\n git-submodule.sh                |   16 ++++++++++++----\n 2 files changed, 18 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\nindex 232697d..14c1d5c 100644\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -12,7 +12,7 @@ SYNOPSIS\n 'git submodule' [--quiet] add [-b branch] [-t|--track <branch>] [--] <repository> <path>\n 'git submodule' [--quiet] status [--cached] [--] [<path>...]\n 'git submodule' [--quiet] init [--] [<path>...]\n-'git submodule' [--quiet] update [--init] [--] [<path>...]\n+'git submodule' [--quiet] update [--init] [-N|--no-fetch] [--] [<path>...]\n 'git submodule' [--quiet] summary [--summary-limit <n>] [commit] [--] [<path>...]\n 'git submodule' [--quiet] foreach <command>\n 'git submodule' [--quiet] sync [--] [<path>...]\n@@ -180,6 +180,11 @@ OPTIONS\n \t(the default). This limit only applies to modified submodules. The\n \tsize is always limited to 1 for added/deleted/typechanged submodules.\n \n+-N::\n+--no-fetch::\n+\tThis option is only valid for the update command.\n+\tDon't fetch new objects from the remote site.\n+\n <path>...::\n \tPaths to submodule(s). When specified this will restrict the command\n \tto only operate on the submodules found at the specified paths.\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 6af3d96..f66622b 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -5,7 +5,7 @@\n # Copyright (c) 2007 Lars Hjemli\n \n USAGE=\"[--quiet] [--cached] \\\n-[add <repo> [-b branch] [--track|-t <branch>] <path>]|[status|init|update [-i|--init]|summary [-n|--summary-limit <n>] [<commit>]] \\\n+[add <repo> [-b branch] [--track|-t <branch>] <path>]|[status|init|update [-i|--init] [-N|--no-fetch]|summary [-n|--summary-limit <n>] [<commit>]] \\\n [--] [<path>...]|[foreach <command>]|[sync [--] [<path>...]]\"\n OPTIONS_SPEC=\n . git-sh-setup\n@@ -17,6 +17,7 @@ branch=\n quiet=\n cached=\n track=\n+nofetch=\n \n #\n # print stuff on stdout unless -q was specified\n@@ -313,6 +314,10 @@ cmd_update()\n \t\t\tshift\n \t\t\tcmd_init \"$@\" || return\n \t\t\t;;\n+\t\t-N|--no-fetch)\n+\t\t\tshift\n+\t\t\tnofetch=1\n+\t\t\t;;\n \t\t--)\n \t\t\tshift\n \t\t\tbreak\n@@ -370,9 +375,12 @@ cmd_update()\n \n \t\t\t# First fetch ...\n \n-\t\t\t(unset GIT_DIR; cd \"$path\" &&\n-\t\t\t\tgit-fetch) ||\n-\t\t\tdie \"Unable to fetch in submodule path '$path'\"\n+\t\t\tif test -z \"$nofetch\"\n+\t\t\tthen\n+\t\t\t\t(unset GIT_DIR; cd \"$path\" &&\n+\t\t\t\t\tgit-fetch) ||\n+\t\t\t\tdie \"Unable to fetch in submodule path '$path'\"\n+\t\t\tfi\n \n \t\t\tif test \"$sha1\" = \"NULL\"\n \t\t\tthen\n-- \n1.5.3.6\n"},{"id":"99847","messageId":"1231553410-7541-3-git-send-email-git@fabian-franz.de","threadId":"17072","inReplyTo":"1231553410-7541-2-git-send-email-git@fabian-franz.de","subject":"[PATCH v4] submodule: add --use-gitmodules parameter to update command","fromName":"Fabian Franz","fromEmail":"git@fabian-franz.de","sentAt":"2009-01-10T02:10:08Z","receivedAt":"2009-01-10T02:10:08Z","isPatch":true,"sender":{"key":"git@fabian-franz.de","avatar":null},"body":"When -u|--use-gitmodules is given the update command uses the .gitmodules\nconfig file instead of the .git/config file to obtain the track parameter.\nThis makes it for example possible to change branches for all submodules\nat the same time without having to sync up .git/config first.\n\nSigned-off-by: Fabian Franz <git@fabian-franz.de>\n---\n Documentation/git-submodule.txt |    8 +++++++-\n git-submodule.sh                |    9 ++++++++-\n 2 files changed, 15 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\nindex 14c1d5c..175b4b5 100644\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -12,7 +12,7 @@ SYNOPSIS\n 'git submodule' [--quiet] add [-b branch] [-t|--track <branch>] [--] <repository> <path>\n 'git submodule' [--quiet] status [--cached] [--] [<path>...]\n 'git submodule' [--quiet] init [--] [<path>...]\n-'git submodule' [--quiet] update [--init] [-N|--no-fetch] [--] [<path>...]\n+'git submodule' [--quiet] update [--init] [-N|--no-fetch] [-u|--use-gitmodules] [--] [<path>...]\n 'git submodule' [--quiet] summary [--summary-limit <n>] [commit] [--] [<path>...]\n 'git submodule' [--quiet] foreach <command>\n 'git submodule' [--quiet] sync [--] [<path>...]\n@@ -185,6 +185,12 @@ OPTIONS\n \tThis option is only valid for the update command.\n \tDon't fetch new objects from the remote site.\n \n+-u::\n+--use-gitmodules::\n+\tThis option is only valid for the update command.\n+\tUse the tracking information found in .gitmodules\n+\t(track) and ignore .git/config.\n+\n <path>...::\n \tPaths to submodule(s). When specified this will restrict the command\n \tto only operate on the submodules found at the specified paths.\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex f66622b..81b96dd 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -5,7 +5,7 @@\n # Copyright (c) 2007 Lars Hjemli\n \n USAGE=\"[--quiet] [--cached] \\\n-[add <repo> [-b branch] [--track|-t <branch>] <path>]|[status|init|update [-i|--init] [-N|--no-fetch]|summary [-n|--summary-limit <n>] [<commit>]] \\\n+[add <repo> [-b branch] [--track|-t <branch>] <path>]|[status|init|update [-i|--init] [-N|--no-fetch] [-u|--use-gitmodules]|summary [-n|--summary-limit <n>] [<commit>]] \\\n [--] [<path>...]|[foreach <command>]|[sync [--] [<path>...]]\"\n OPTIONS_SPEC=\n . git-sh-setup\n@@ -18,6 +18,7 @@ quiet=\n cached=\n track=\n nofetch=\n+usegitmodules=\n \n #\n # print stuff on stdout unless -q was specified\n@@ -318,6 +319,10 @@ cmd_update()\n \t\t\tshift\n \t\t\tnofetch=1\n \t\t\t;;\n+\t\t-u|--use-gitmodules)\n+\t\t\tshift\n+\t\t\tusegitmodules=1\n+\t\t\t;;\n \t\t--)\n \t\t\tshift\n \t\t\tbreak\n@@ -347,6 +352,8 @@ cmd_update()\n \t\tfi\n \n \t\ttrack=$(git config submodule.\"$name\".track)\n+\t\ttest -n \"$usegitmodules\" &&\n+\t\t\ttrack=$(git config -f .gitmodules submodule.\"$name\".track)\n \t\tif test -n \"$track\"\n \t\tthen\n \t\t\tgit-update-index --assume-unchanged \"$path\"\n-- \n1.5.3.6\n"},{"id":"99845","messageId":"1231553410-7541-4-git-send-email-git@fabian-franz.de","threadId":"17072","inReplyTo":"1231553410-7541-3-git-send-email-git@fabian-franz.de","subject":"[PATCH v4] submodule: add +<branch> syntax for track to allow automatic pulling.","fromName":"Fabian Franz","fromEmail":"git@fabian-franz.de","sentAt":"2009-01-10T02:10:09Z","receivedAt":"2009-01-10T02:10:09Z","isPatch":true,"sender":{"key":"git@fabian-franz.de","avatar":null},"body":"When the track parameter is set to +<branch>, on update command a\nnew branch is created tracking the remote branch (if it does not\nyet exist). Then the branch is checked out and git-pull is run.\n\nSigned-off-by: Fabian Franz <git@fabian-franz.de>\n---\n Documentation/git-submodule.txt |    3 +++\n git-submodule.sh                |   26 ++++++++++++++++++++++++++\n 2 files changed, 29 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\nindex 175b4b5..fbb18ee 100644\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -166,6 +166,9 @@ OPTIONS\n -t::\n --track::\n \tBranch/Tag/HEAD (pathspec) of repository to track in a submodule.\n+\tIf you give +<branch> as parameter, a new branch will be created and\n+\tsetup to track the remote branch. Then on update git-pull is used to\n+\tupdate the branch.\n \n --cached::\n \tThis option is only valid for status and summary commands.  These\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 81b96dd..54b59b2 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -372,6 +372,32 @@ cmd_update()\n \t\t\tdie \"Unable to find current revision in submodule path '$path'\"\n \t\tfi\n \n+\t\tpull=\n+\t\tcase \"$track\" in\n+\t\t\t\"+\"*)\n+\t\t\t\tpull=1\n+\t\t\t\ttrack=${track#+}\n+\t\t\t;;\n+\t\tesac\n+\n+\t\tif test -n \"$pull\"\n+\t\tthen\n+\t\t\tsay \"Pulling updates for branch '$track' for submodule path '$path'\"\n+\t\t\torigin=$(unset GIT_DIR; cd \"$path\" &&\n+\t\t\t\tget_default_remote) ||\n+\t\t\tdie \"Unable to get default remote destination in submodule path '$path'.\"\n+\t\t\t(unset GIT_DIR; cd \"$path\" &&\n+\t\t\t\tgit-rev-parse --verify --quiet \"refs/heads/$track\" >/dev/null || \n+\t\t\t\tgit-branch --track \"$track\" \"$origin/$track\") || \n+\t\t\tdie \"Unable to create branch '$track' in submodule path '$path'\"\n+\n+\t\t\t(unset GIT_DIR; cd \"$path\" &&\n+\t\t\t\tgit-checkout -q \"$track\" &&\n+\t\t\t\tgit-pull ${quiet:+-q}) ||\n+\t\t\tdie \"Unable to pull for branch '$track' in submodule path '$path'\"\n+\t\t\tsha1=\"$track\"\n+\t\tfi\n+\n \t\tif test \"$subsha1\" != \"$sha1\"\n \t\tthen\n \t\t\tforce=\n-- \n1.5.3.6\n"},{"id":"99846","messageId":"1231553410-7541-5-git-send-email-git@fabian-franz.de","threadId":"17072","inReplyTo":"1231553410-7541-4-git-send-email-git@fabian-franz.de","subject":"[PATCH v4] submodule: add --recursive parameter to update command","fromName":"Fabian Franz","fromEmail":"git@fabian-franz.de","sentAt":"2009-01-10T02:10:10Z","receivedAt":"2009-01-10T02:10:10Z","isPatch":true,"sender":{"key":"git@fabian-franz.de","avatar":null},"body":"If --recursive is specified on update, then recursively check for\n.gitmodules in each updated submodule and run init and update commands.\nThe update command is run with the same parameters as the original update\ncommand with the exception of the path.\n\nSigned-off-by: Fabian Franz <git@fabian-franz.de>\n---\n Documentation/git-submodule.txt |    8 ++++++++\n git-submodule.sh                |   17 ++++++++++++++++-\n 2 files changed, 24 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\nindex fbb18ee..c9adc43 100644\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -188,6 +188,14 @@ OPTIONS\n \tThis option is only valid for the update command.\n \tDon't fetch new objects from the remote site.\n \n+-r::\n+--recursive::\n+\tThis option is only valid for the update command.\n+\tRecursively check for .gitmodules in each updated submodule and run\n+\tinit and update commands. The update command is run with the same\n+\tparameters as the original update command with the exception of the\n+\tpath.\n+\n -u::\n --use-gitmodules::\n \tThis option is only valid for the update command.\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 54b59b2..8bb00b7 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -5,7 +5,7 @@\n # Copyright (c) 2007 Lars Hjemli\n \n USAGE=\"[--quiet] [--cached] \\\n-[add <repo> [-b branch] [--track|-t <branch>] <path>]|[status|init|update [-i|--init] [-N|--no-fetch] [-u|--use-gitmodules]|summary [-n|--summary-limit <n>] [<commit>]] \\\n+[add <repo> [-b branch] [--track|-t <branch>] <path>]|[status|init|update [-i|--init] [-N|--no-fetch] [-r|--recursive] [-u|--use-gitmodules]|summary [-n|--summary-limit <n>] [<commit>]] \\\n [--] [<path>...]|[foreach <command>]|[sync [--] [<path>...]]\"\n OPTIONS_SPEC=\n . git-sh-setup\n@@ -19,6 +19,7 @@ cached=\n track=\n nofetch=\n usegitmodules=\n+recursive=\n \n #\n # print stuff on stdout unless -q was specified\n@@ -319,6 +320,10 @@ cmd_update()\n \t\t\tshift\n \t\t\tnofetch=1\n \t\t\t;;\n+\t\t-r|--recursive)\n+\t\t\tshift\n+\t\t\trecursive=1\n+\t\t\t;;\n \t\t-u|--use-gitmodules)\n \t\t\tshift\n \t\t\tusegitmodules=1\n@@ -445,6 +450,16 @@ cmd_update()\n \n \t\t\tsay \"Submodule path '$path': checked out '$sha1'${track:+ ($track)}\"\n \t\tfi\n+\t\tif test -n \"$recursive\" -a -f \"$path/.gitmodules\"\n+\t\tthen\n+\t\t\tPARAMS=\"${quiet:+-q} ${nofetch:+--no-fetch} ${recursive:+-r} ${usegitmodules:+-u}\"\n+\t\t\tsay \"Entering submodule path '$path'\"\n+\t\t\t(unset GIT_DIR; cd \"$path\" &&\n+\t\t\t\t  git-submodule init &&\n+\t\t\t\t  git-submodule update $PARAMS) ||\n+\t\t\tdie \"Unable to run 'git-submodule update $PARAMS' in submodule path '$path'\"\n+\t\t\tsay \"Leaving submodule path '$path'\"\n+\t\tfi\n \tdone\n }\n \n-- \n1.5.3.6\n"},{"id":"99892","messageId":"alpine.DEB.1.00.0901101522560.30769@pacific.mpi-cbg.de","threadId":"17072","inReplyTo":"1231553410-7541-1-git-send-email-git@fabian-franz.de","subject":"Re: [PATCH v4] submodule: allow tracking of the newest revision of a branch in a submodule","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-01-10T14:23:48Z","receivedAt":"2009-01-10T14:23:48Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 10 Jan 2009, Fabian Franz wrote:\n\n> Submodules currently only allow tracking a specific revision and each \n> update in a submodule leads to a new commit in the master repository. \n> However some users may want to always track the newest revision of a \n> specific (named) tag or branch or HEAD. For example the user might want \n> to track a staging branch in all submodules.\n\nI wonder how you want to deal with \"git bisect\".  Or for that matter, with \n\"git checkout HEAD^500\".\n\nCiao,\nDscho\n"},{"id":"99927","messageId":"20090111103158.6117@nanako3.lavabit.com","threadId":"17072","inReplyTo":"1231553410-7541-2-git-send-email-git@fabian-franz.de","subject":"Re: [PATCH v4] submodule: add --no-fetch parameter to update command","fromName":"Nanako Shiraishi","fromEmail":"nanako3@lavabit.com","sentAt":"2009-01-11T01:31:58Z","receivedAt":"2009-01-11T01:31:58Z","isPatch":true,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"Quoting Fabian Franz <git@fabian-franz.de> writes:\n\n> git submodule update --no-fetch makes it possible to use git submodule\n> update in complete offline mode by not fetching new revisions.\n\nI may be confused, but does it make any sense to update without fetching?\n\n-- \nNanako Shiraishi\nhttp://ivory.ap.teacup.com/nanako3/\n"},{"id":"99928","messageId":"20090111103208.6117@nanako3.lavabit.com","threadId":"17072","inReplyTo":"1231553410-7541-2-git-send-email-git@fabian-franz.de","subject":"Re: [PATCH v4] submodule: add --no-fetch parameter to update command","fromName":"Nanako Shiraishi","fromEmail":"nanako3@lavabit.com","sentAt":"2009-01-11T01:32:08Z","receivedAt":"2009-01-11T01:32:08Z","isPatch":true,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"Quoting Fabian Franz <git@fabian-franz.de> writes:\n\n> When -u|--use-gitmodules is given the update command uses the .gitmodules\n> config file instead of the .git/config file to obtain the track parameter.\n> This makes it for example possible to change branches for all submodules\n> at the same time without having to sync up .git/config first.\n>\n> Signed-off-by: Fabian Franz <git@fabian-franz.de>\n\nOnce you start doing that, doesn't it force you to always bypass .git/config, making the current mechanism even less useful?  If you find that \"having to sync up .git/config first\" is inconvenient, wouldn't it be more useful for your patch if it made it easier and more convenient the procedure \"to sync up .git/config first\", instead of bypassing the current setup?\n\n-- \nNanako Shiraishi\nhttp://ivory.ap.teacup.com/nanako3/\n"},{"id":"99929","messageId":"7vy6xityl4.fsf@gitster.siamese.dyndns.org","threadId":"17072","inReplyTo":"1231553410-7541-4-git-send-email-git@fabian-franz.de","subject":"Re: [PATCH v4] submodule: add +<branch> syntax for track to allow automatic pulling.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-01-11T01:34:31Z","receivedAt":"2009-01-11T01:34:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Fabian Franz <git@fabian-franz.de> writes:\n\n> When the track parameter is set to +<branch>, on update command a\n> new branch is created tracking the remote branch (if it does not\n> yet exist). Then the branch is checked out and git-pull is run.\n\nUsually a \"+\" in front of a refspec means \"allow forcing non-ff update\",\nbut here it means completely different thing.  The syntax is confusing.\n\nBut that aside, I do not know if the semantics of this patch makes sense\nto begin with.\n\nShould this really be a persistent property of a submodule?  With your\npatch, this is always triggered for modules you did \"--track +branch\" when\nyou added them, but (1) not for others you did not say \"+\" when you added,\nand (2) you cannot disable the auto-pull for the ones you did even if you\nwanted to.  It feels it might be better to make it a property of one\nparticular invocation of \"update\" action, and more generally, the entire\nseries feels like a very specific hack that is meant to cover/impose your\nparticular workflow (and not others').\n\nDon't get me wrong.  I do not see any problem in supporing it well, if\nthat particular workflow is a good workflow and a generally applicable\none.\n\nBut I do not think it is documented well enough.  \"--track creates one\nconfiguration in the .git/config file\" and \"update always checks out the\ntip of the named branch if such configuration is set\" may be fine\ndescriptions of what each piece does.  The readers will be left puzzled\nwithout an explanation of the bigger picture to understand why it is\n(sometimes) a good idea to make these pieces do what they do.\n"}]}