Browse Source
'git submodule update --rebase' rebases your local branch on top of what would have been checked out to a detached HEAD otherwise. In some cases, detaching the HEAD when updating a submodule complicates the workflow to commit to this submodule (checkout master, rebase, then commit). For submodules that require frequent updates but infrequent (if any) commits, a rebase can be executed directly by the git-submodule command, ensuring that the submodules stay on their respective branches. git-config key: submodule.$name.rebase (bool) Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
Peter Hutterer
16 years ago
committed by
Junio C Hamano
4 changed files with 184 additions and 6 deletions
@ -0,0 +1,140 @@
@@ -0,0 +1,140 @@
|
||||
#!/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 true in .git/config' ' |
||||
(cd super && |
||||
git config submodule.submodule.rebase true |
||||
) && |
||||
(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 false in .git/config but --rebase given' ' |
||||
(cd super && |
||||
git config submodule.submodule.rebase false |
||||
) && |
||||
(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 - rebase false in .git/config' ' |
||||
(cd super && |
||||
git config submodule.submodule.rebase false |
||||
) && |
||||
(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.rebase true && |
||||
git submodule init rebasing && |
||||
test true = $(git config --bool submodule.rebasing.rebase) |
||||
) |
||||
' |
||||
|
||||
test_done |
Loading…
Reference in new issue