Merge branch 'ph/submodule-rebase'
* ph/submodule-rebase: git-submodule: add support for --merge. Conflicts: Documentation/git-submodule.txt git-submodule.sh
This commit is contained in:
commit
a49eb197d8
@ -115,8 +115,9 @@ init::
|
|||||||
update::
|
update::
|
||||||
Update the registered submodules, i.e. clone missing submodules and
|
Update the registered submodules, i.e. clone missing submodules and
|
||||||
checkout the commit specified in the index of the containing repository.
|
checkout the commit specified in the index of the containing repository.
|
||||||
This will make the submodules HEAD be detached unless '--rebase' is
|
This will make the submodules HEAD be detached unless '--rebase' or
|
||||||
specified or the key `submodule.$name.update` is set to `rebase`.
|
'--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
|
If the submodule is not yet initialized, and you just want to use the
|
||||||
setting as stored in .gitmodules, you can automatically initialize the
|
setting as stored in .gitmodules, you can automatically initialize the
|
||||||
@ -180,6 +181,16 @@ OPTIONS
|
|||||||
This option is only valid for the update command.
|
This option is only valid for the update command.
|
||||||
Don't fetch new objects from the remote site.
|
Don't fetch new objects from the remote site.
|
||||||
|
|
||||||
|
--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::
|
--rebase::
|
||||||
This option is only valid for the update command.
|
This option is only valid for the update command.
|
||||||
Rebase the current branch onto the commit recorded in the
|
Rebase the current branch onto the commit recorded in the
|
||||||
|
@ -35,9 +35,11 @@ submodule.<name>.update::
|
|||||||
If 'checkout' (the default), the new commit specified in the
|
If 'checkout' (the default), the new commit specified in the
|
||||||
superproject will be checked out in the submodule on a detached HEAD.
|
superproject will be checked out in the submodule on a detached HEAD.
|
||||||
If 'rebase', the current branch of the submodule will be rebased onto
|
If 'rebase', the current branch of the submodule will be rebased onto
|
||||||
the commit specified in the superproject.
|
the commit specified in the superproject. If 'merge', the commit
|
||||||
|
specified in the superproject will be merged into the current branch
|
||||||
|
in the submodule.
|
||||||
This config option is overridden if 'git submodule update' is given
|
This config option is overridden if 'git submodule update' is given
|
||||||
the '--rebase' option.
|
the '--merge' or '--rebase' options.
|
||||||
|
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
# Copyright (c) 2007 Lars Hjemli
|
# Copyright (c) 2007 Lars Hjemli
|
||||||
|
|
||||||
USAGE="[--quiet] [--cached] \
|
USAGE="[--quiet] [--cached] \
|
||||||
[add [-b branch] <repo> <path>]|[status|init|update [-i|--init] [-N|--no-fetch]|summary [-n|--summary-limit <n>] [<commit>]] \
|
[add [-b branch] <repo> <path>]|[status|init|update [-i|--init] [-N|--no-fetch] [--rebase|--merge]|summary [-n|--summary-limit <n>] [<commit>]] \
|
||||||
[--] [<path>...]|[foreach <command>]|[sync [--] [<path>...]]"
|
[--] [<path>...]|[foreach <command>]|[sync [--] [<path>...]]"
|
||||||
OPTIONS_SPEC=
|
OPTIONS_SPEC=
|
||||||
. git-sh-setup
|
. git-sh-setup
|
||||||
@ -356,6 +356,10 @@ cmd_update()
|
|||||||
reference="$1"
|
reference="$1"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
-m|--merge)
|
||||||
|
shift
|
||||||
|
update="merge"
|
||||||
|
;;
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
@ -426,6 +430,11 @@ cmd_update()
|
|||||||
action="rebase"
|
action="rebase"
|
||||||
msg="rebased onto"
|
msg="rebased onto"
|
||||||
;;
|
;;
|
||||||
|
merge)
|
||||||
|
command="git merge"
|
||||||
|
action="merge"
|
||||||
|
msg="merged in"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
command="git checkout $force -q"
|
command="git checkout $force -q"
|
||||||
action="checkout"
|
action="checkout"
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
test_description='Test updating submodules
|
test_description='Test updating submodules
|
||||||
|
|
||||||
This test verifies that "git submodule update" detaches the HEAD of the
|
This test verifies that "git submodule update" detaches the HEAD of the
|
||||||
submodule and "git submodule update --rebase" does not detach the HEAD.
|
submodule and "git submodule update --rebase/--merge" does not detach the HEAD.
|
||||||
'
|
'
|
||||||
|
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
@ -76,6 +76,20 @@ test_expect_success 'submodule update --rebase staying on master' '
|
|||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'submodule update --merge staying on master' '
|
||||||
|
(cd super/submodule &&
|
||||||
|
git reset --hard HEAD~1
|
||||||
|
) &&
|
||||||
|
(cd super &&
|
||||||
|
(cd submodule &&
|
||||||
|
compare_head
|
||||||
|
) &&
|
||||||
|
git submodule update --merge submodule &&
|
||||||
|
cd submodule &&
|
||||||
|
compare_head
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'submodule update - rebase in .git/config' '
|
test_expect_success 'submodule update - rebase in .git/config' '
|
||||||
(cd super &&
|
(cd super &&
|
||||||
git config submodule.submodule.update rebase
|
git config submodule.submodule.update rebase
|
||||||
@ -110,6 +124,40 @@ test_expect_success 'submodule update - checkout in .git/config but --rebase giv
|
|||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'submodule update - merge in .git/config' '
|
||||||
|
(cd super &&
|
||||||
|
git config submodule.submodule.update merge
|
||||||
|
) &&
|
||||||
|
(cd super/submodule &&
|
||||||
|
git reset --hard HEAD~1
|
||||||
|
) &&
|
||||||
|
(cd super &&
|
||||||
|
(cd submodule &&
|
||||||
|
compare_head
|
||||||
|
) &&
|
||||||
|
git submodule update submodule &&
|
||||||
|
cd submodule &&
|
||||||
|
compare_head
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'submodule update - checkout in .git/config but --merge given' '
|
||||||
|
(cd super &&
|
||||||
|
git config submodule.submodule.update checkout
|
||||||
|
) &&
|
||||||
|
(cd super/submodule &&
|
||||||
|
git reset --hard HEAD~1
|
||||||
|
) &&
|
||||||
|
(cd super &&
|
||||||
|
(cd submodule &&
|
||||||
|
compare_head
|
||||||
|
) &&
|
||||||
|
git submodule update --merge submodule &&
|
||||||
|
cd submodule &&
|
||||||
|
compare_head
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'submodule update - checkout in .git/config' '
|
test_expect_success 'submodule update - checkout in .git/config' '
|
||||||
(cd super &&
|
(cd super &&
|
||||||
git config submodule.submodule.update checkout
|
git config submodule.submodule.update checkout
|
||||||
@ -137,4 +185,14 @@ test_expect_success 'submodule init picks up rebase' '
|
|||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'submodule init picks up merge' '
|
||||||
|
(cd super &&
|
||||||
|
git config submodule.merging.url git://non-existing/git &&
|
||||||
|
git config submodule.merging.path does-not-matter &&
|
||||||
|
git config submodule.merging.update merge &&
|
||||||
|
git submodule init merging &&
|
||||||
|
test "merge" = $(git config submodule.merging.update)
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Loading…
Reference in New Issue
Block a user