From: W. Trevor King Date: Fri, 23 Nov 2012 18:11:18 +0000 (-0500) Subject: wip X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2033547075014bf393fa1a10dce01352d7eb6d08;p=git.git wip --- diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt index 02ea87b4a..afa12697c 100644 --- a/Documentation/git-submodule.txt +++ b/Documentation/git-submodule.txt @@ -14,7 +14,8 @@ SYNOPSIS 'git submodule' [--quiet] status [--cached] [--recursive] [--] [...] 'git submodule' [--quiet] init [--] [...] 'git submodule' [--quiet] update [--init] [-N|--no-fetch] [--rebase] - [--reference ] [--merge] [--recursive] [--] [...] + [--reference ] [--merge] [--pull] [--recursive] [--] + [...] 'git submodule' [--quiet] summary [--cached|--files] [(-n|--summary-limit) ] [commit] [--] [...] 'git submodule' [--quiet] foreach [--recursive] @@ -136,11 +137,11 @@ init:: update:: Update the registered submodules, i.e. clone missing submodules and - checkout the commit specified in the index of the containing repository. - This will make the submodules HEAD be detached unless `--rebase` or - `--merge` is specified or the key `submodule.$name.update` is set to - `rebase`, `merge` or `none`. `none` can be overridden by specifying - `--checkout`. + checkout the commit specified in the index of the containing + repository. This will make the submodules HEAD be detached unless + `--rebase`, `--merge`, or `--pull` is specified or the key + `submodule.$name.update` is set to `rebase`, `merge`, `pull`, or + `none`. `none` can be overridden by specifying `--checkout`. + If the submodule is not yet initialized, and you just want to use the setting as stored in .gitmodules, you can automatically initialize the @@ -259,6 +260,16 @@ OPTIONS If the key `submodule.$name.update` is set to `merge`, this option is implicit. +--pull:: + This option is only valid for the update command. + Merge the commit recorded in the superproject into the current branch + of the submodule. If this option is given, the submodule's HEAD will + not be detached. If a merge failure prevents this process, you will + have to resolve the resulting conflicts within the submodule with the + usual conflict resolution tools. + If the key `submodule.$name.update` is set to `pull`, this option is + implicit. + --rebase:: This option is only valid for the update command. Rebase the current branch onto the commit recorded in the diff --git a/git-submodule.sh b/git-submodule.sh index 3c3bb3f0e..c5d335325 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -8,7 +8,7 @@ dashless=$(basename "$0" | sed -e 's/-/ /') USAGE="[--quiet] add [-b branch] [--follow-branch[=]] [-f|--force] [--reference ] [--] [] or: $dashless [--quiet] status [--cached] [--recursive] [--] [...] or: $dashless [--quiet] init [--] [...] - or: $dashless [--quiet] update [--init] [-N|--no-fetch] [-f|--force] [--rebase] [--reference ] [--merge] [--recursive] [--] [...] + or: $dashless [--quiet] update [--init] [-N|--no-fetch] [-f|--force] [--rebase] [--reference ] [--merge] [--pull] [--recursive] [--] [...] or: $dashless [--quiet] summary [--cached|--files] [--summary-limit ] [commit] [--] [...] or: $dashless [--quiet] foreach [--recursive] or: $dashless [--quiet] sync [--] [...]" @@ -554,6 +554,9 @@ cmd_update() -m|--merge) update="merge" ;; + -p|--pull) + update="pull" + ;; --recursive) recursive=1 ;; @@ -593,6 +596,7 @@ cmd_update() fi name=$(module_name "$sm_path") || exit url=$(git config submodule."$name".url) + branch=$(git config submodule."$name".branch) if ! test -z "$update" then update_module=$update @@ -653,6 +657,7 @@ Maybe you want to use 'update --init'?")" update_module= ;; esac + res= must_die_on_failure= case "$update_module" in rebase) @@ -667,6 +672,13 @@ Maybe you want to use 'update --init'?")" say_msg="$(eval_gettext "Submodule path '\$sm_path': merged in '\$sha1'")" must_die_on_failure=yes ;; + pull) + die_msg="$(eval_gettext "Unable to merge '\$sha1' in submodule path '\$sm_path'")" + say_msg="$(eval_gettext "Submodule path '\$sm_path': merged in '\$sha1'")" + must_die_on_failure=yes + (clear_local_git_env; cd "$sm_path" && git checkout "$branch" && git pull --ff-only) + res=$? + ;; *) command="git checkout $subforce -q" die_msg="$(eval_gettext "Unable to checkout '\$sha1' in submodule path '\$sm_path'")" @@ -674,7 +686,12 @@ Maybe you want to use 'update --init'?")" ;; esac - if (clear_local_git_env; cd "$sm_path" && $command "$sha1") + if test -z "$res" + then + (clear_local_git_env; cd "$sm_path" && $command "$sha1") + res=$? + fi + if test $res -eq 0 then say "$say_msg" elif test -n "$must_die_on_failure" diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh index 15426530e..460fc4cdb 100755 --- a/t/t7406-submodule-update.sh +++ b/t/t7406-submodule-update.sh @@ -5,8 +5,9 @@ test_description='Test updating submodules -This test verifies that "git submodule update" detaches the HEAD of the -submodule and "git submodule update --rebase/--merge" does not detach the HEAD. +This test verifies that "git submodule update" detaches the HEAD of +the submodule and "git submodule update --rebase/--merge/--pull" does +not detach the HEAD. ' . ./test-lib.sh