When the track parameter is set to +<branch>, on update command a new branch is created tracking the remote branch (if it does not yet exist). Then the branch is checked out and git-pull is run. Signed-off-by: Fabian Franz <git@xxxxxxxxxxxxxxx> --- Documentation/git-submodule.txt | 3 +++ git-submodule.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 0 deletions(-) diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt index 175b4b5..fbb18ee 100644 --- a/Documentation/git-submodule.txt +++ b/Documentation/git-submodule.txt @@ -166,6 +166,9 @@ OPTIONS -t:: --track:: Branch/Tag/HEAD (pathspec) of repository to track in a submodule. + If you give +<branch> as parameter, a new branch will be created and + setup to track the remote branch. Then on update git-pull is used to + update the branch. --cached:: This option is only valid for status and summary commands. These diff --git a/git-submodule.sh b/git-submodule.sh index 81b96dd..54b59b2 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -372,6 +372,32 @@ cmd_update() die "Unable to find current revision in submodule path '$path'" fi + pull= + case "$track" in + "+"*) + pull=1 + track=${track#+} + ;; + esac + + if test -n "$pull" + then + say "Pulling updates for branch '$track' for submodule path '$path'" + origin=$(unset GIT_DIR; cd "$path" && + get_default_remote) || + die "Unable to get default remote destination in submodule path '$path'." + (unset GIT_DIR; cd "$path" && + git-rev-parse --verify --quiet "refs/heads/$track" >/dev/null || + git-branch --track "$track" "$origin/$track") || + die "Unable to create branch '$track' in submodule path '$path'" + + (unset GIT_DIR; cd "$path" && + git-checkout -q "$track" && + git-pull ${quiet:+-q}) || + die "Unable to pull for branch '$track' in submodule path '$path'" + sha1="$track" + fi + if test "$subsha1" != "$sha1" then force= -- 1.5.3.6 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html