mirror of
https://github.com/git/git.git
synced 2024-11-17 22:44:49 +01:00
329484256e
The addition of "submodule.<name>.rebase" demonstrates the usefulness of alternatives to the default behaviour of "git submodule update". However, by naming the config variable "submodule.<name>.rebase", and making it a boolean choice, we are artificially constraining future git versions that may want to add _more_ alternatives than just "rebase". Therefore, while "submodule.<name>.rebase" is not yet in a stable git release, future-proof it, by changing it from submodule.<name>.rebase = true/false to submodule.<name>.update = rebase/checkout where "checkout" specifies the default behaviour of "git submodule update" (checking out the new commit to a detached HEAD), and "rebase" specifies the --rebase behaviour (where the current local branch in the submodule is rebase onto the new commit). Thus .update == checkout is equivalent to .rebase == false, and .update == rebase is equivalent to .rebase == true. Finally, leaving .update unset is equivalent to leaving .rebase unset. In future git versions, other alternatives to "git submodule update" behaviour can be included by adding them to the list of allowable values for the submodule.<name>.update variable. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
140 lines
2.7 KiB
Bash
Executable file
140 lines
2.7 KiB
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# Copyright (c) 2009 Red Hat, Inc.
|
|
#
|
|
|
|
test_description='Test updating submodules
|
|
|
|
This test verifies that "git submodule update" detaches the HEAD of the
|
|
submodule and "git submodule update --rebase" does not detach the HEAD.
|
|
'
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
compare_head()
|
|
{
|
|
sha_master=`git-rev-list --max-count=1 master`
|
|
sha_head=`git-rev-list --max-count=1 HEAD`
|
|
|
|
test "$sha_master" = "$sha_head"
|
|
}
|
|
|
|
|
|
test_expect_success 'setup a submodule tree' '
|
|
echo file > file &&
|
|
git add file &&
|
|
test_tick &&
|
|
git commit -m upstream
|
|
git clone . super &&
|
|
git clone super submodule &&
|
|
(cd super &&
|
|
git submodule add ../submodule submodule &&
|
|
test_tick &&
|
|
git commit -m "submodule" &&
|
|
git submodule init submodule
|
|
) &&
|
|
(cd submodule &&
|
|
echo "line2" > file &&
|
|
git add file &&
|
|
git commit -m "Commit 2"
|
|
) &&
|
|
(cd super &&
|
|
(cd submodule &&
|
|
git pull --rebase origin
|
|
) &&
|
|
git add submodule &&
|
|
git commit -m "submodule update"
|
|
)
|
|
'
|
|
|
|
test_expect_success 'submodule update detaching the HEAD ' '
|
|
(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 --rebase staying on master' '
|
|
(cd super/submodule &&
|
|
git checkout master
|
|
) &&
|
|
(cd super &&
|
|
(cd submodule &&
|
|
compare_head
|
|
) &&
|
|
git submodule update --rebase submodule &&
|
|
cd submodule &&
|
|
compare_head
|
|
)
|
|
'
|
|
|
|
test_expect_success 'submodule update - rebase in .git/config' '
|
|
(cd super &&
|
|
git config submodule.submodule.update rebase
|
|
) &&
|
|
(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 --rebase 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 --rebase submodule &&
|
|
cd submodule &&
|
|
compare_head
|
|
)
|
|
'
|
|
|
|
test_expect_success 'submodule update - checkout in .git/config' '
|
|
(cd super &&
|
|
git config submodule.submodule.update checkout
|
|
) &&
|
|
(cd super/submodule &&
|
|
git reset --hard HEAD^
|
|
) &&
|
|
(cd super &&
|
|
(cd submodule &&
|
|
compare_head
|
|
) &&
|
|
git submodule update submodule &&
|
|
cd submodule &&
|
|
! compare_head
|
|
)
|
|
'
|
|
|
|
test_expect_success 'submodule init picks up rebase' '
|
|
(cd super &&
|
|
git config submodule.rebasing.url git://non-existing/git &&
|
|
git config submodule.rebasing.path does-not-matter &&
|
|
git config submodule.rebasing.update rebase &&
|
|
git submodule init rebasing &&
|
|
test "rebase" = $(git config submodule.rebasing.update)
|
|
)
|
|
'
|
|
|
|
test_done
|