From: Junio C Hamano Date: Sun, 21 Jun 2009 04:51:13 +0000 (-0700) Subject: Merge branch 'ph/submodule-rebase' X-Git-Tag: v1.6.4-rc0~44 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/a49eb197d809d2d7efbd81d935c61e1a0caa983e?hp=-c Merge branch 'ph/submodule-rebase' * ph/submodule-rebase: git-submodule: add support for --merge. Conflicts: Documentation/git-submodule.txt git-submodule.sh --- a49eb197d809d2d7efbd81d935c61e1a0caa983e diff --combined Documentation/git-submodule.txt index cd8e861ce4,2289d11f0e..470bd75ad9 --- a/Documentation/git-submodule.txt +++ b/Documentation/git-submodule.txt @@@ -9,12 -9,10 +9,12 @@@ git-submodule - Initialize, update or i SYNOPSIS -------- [verse] -'git submodule' [--quiet] add [-b branch] [--] +'git submodule' [--quiet] add [-b branch] + [--reference ] [--] 'git submodule' [--quiet] status [--cached] [--] [...] 'git submodule' [--quiet] init [--] [...] -'git submodule' [--quiet] update [--init] [-N|--no-fetch] [--rebase] [--] [...] +'git submodule' [--quiet] update [--init] [-N|--no-fetch] [--rebase] + [--reference ] [--] [...] 'git submodule' [--quiet] summary [--summary-limit ] [commit] [--] [...] 'git submodule' [--quiet] foreach 'git submodule' [--quiet] sync [--] [...] @@@ -115,8 -113,9 +115,9 @@@ 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' is - specified or the key `submodule.$name.update` is set to `rebase`. + This will make the submodules HEAD be detached unless '--rebase' or + '--merge' is specified or the key `submodule.$name.update` is set to + `rebase` or `merge`. + If the submodule is not yet initialized, and you just want to use the setting as stored in .gitmodules, you can automatically initialize the @@@ -180,23 -179,25 +181,33 @@@ OPTION This option is only valid for the update command. Don't fetch new objects from the remote site. ---rebase:: - This option is only valid for the update command. - Rebase the current branch onto the commit recorded in the - superproject. If this option is given, the submodule's HEAD will not - be detached. If a a merge failure prevents this process, you will have - to resolve these failures with linkgit:git-rebase[1]. - If the key `submodule.$name.update` is set to `rebase`, this option is - implicit. - + --merge:: + 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 `merge`, this option is + implicit. + +--rebase:: + This option is only valid for the update command. + Rebase the current branch onto the commit recorded in the + superproject. If this option is given, the submodule's HEAD will not + be detached. If a a merge failure prevents this process, you will have + to resolve these failures with linkgit:git-rebase[1]. + If the key `submodule.$name.update` is set to `rebase`, this option is + implicit. + +--reference :: + This option is only valid for add and update commands. These + commands sometimes need to clone a remote repository. In this case, + this option will be passed to the linkgit:git-clone[1] command. ++ +*NOTE*: Do *not* use this option unless you have read the note +for linkgit:git-clone[1]'s --reference and --shared options carefully. + ...:: Paths to submodule(s). When specified this will restrict the command to only operate on the submodules found at the specified paths. diff --combined git-submodule.sh index 19a3a840fd,3aff37970a..f4f3562671 --- a/git-submodule.sh +++ b/git-submodule.sh @@@ -5,7 -5,7 +5,7 @@@ # Copyright (c) 2007 Lars Hjemli USAGE="[--quiet] [--cached] \ - [add [-b branch] ]|[status|init|update [-i|--init] [-N|--no-fetch]|summary [-n|--summary-limit ] []] \ + [add [-b branch] ]|[status|init|update [-i|--init] [-N|--no-fetch] [--rebase|--merge]|summary [-n|--summary-limit ] []] \ [--] [...]|[foreach ]|[sync [--] [...]]" OPTIONS_SPEC= . git-sh-setup @@@ -15,7 -15,6 +15,7 @@@ require_work_tre command= branch= quiet= +reference= cached= nofetch= update= @@@ -93,7 -92,6 +93,7 @@@ module_clone( { path=$1 url=$2 + reference="$3" # If there already is a directory at the submodule path, # expect it to be empty (since that is the default checkout @@@ -109,12 -107,7 +109,12 @@@ test -e "$path" && die "A file already exist at path '$path'" - git-clone -n "$url" "$path" || + if test -n "$reference" + then + git-clone "$reference" -n "$url" "$path" + else + git-clone -n "$url" "$path" + fi || die "Clone of '$url' into submodule path '$path' failed" } @@@ -139,15 -132,6 +139,15 @@@ cmd_add( -q|--quiet) quiet=1 ;; + --reference) + case "$2" in '') usage ;; esac + reference="--reference=$2" + shift + ;; + --reference=*) + reference="$1" + shift + ;; --) shift break @@@ -220,7 -204,7 +220,7 @@@ git config submodule."$path".url "$url" else - module_clone "$path" "$realrepo" || exit + module_clone "$path" "$realrepo" "$reference" || exit ( unset GIT_DIR cd "$path" && @@@ -336,8 -320,8 +336,8 @@@ cmd_update( quiet=1 ;; -i|--init) + init=1 shift - cmd_init "$@" || return ;; -N|--no-fetch) shift @@@ -347,15 -331,10 +347,19 @@@ shift update="rebase" ;; + --reference) + case "$2" in '') usage ;; esac + reference="--reference=$2" + shift 2 + ;; + --reference=*) + reference="$1" + shift + ;; + -m|--merge) + shift + update="merge" + ;; --) shift break @@@ -369,11 -348,6 +373,11 @@@ esac done + if test -n "$init" + then + cmd_init "--" "$@" || return + fi + module_list "$@" | while read mode sha1 stage path do @@@ -392,7 -366,7 +396,7 @@@ if ! test -d "$path"/.git -o -f "$path"/.git then - module_clone "$path" "$url" || exit + module_clone "$path" "$url" "$reference"|| exit subsha1= else subsha1=$(unset GIT_DIR; cd "$path" && @@@ -426,6 -400,11 +430,11 @@@ action="rebase" msg="rebased onto" ;; + merge) + command="git merge" + action="merge" + msg="merged in" + ;; *) command="git checkout $force -q" action="checkout"