-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ph/submodule-rebase' (early part)
* 'ph/submodule-rebase' (early part): Rename submodule.<name>.rebase to submodule.<name>.update git-submodule: add support for --rebase. Conflicts: Documentation/git-submodule.txt git-submodule.sh
- Loading branch information
Showing
4 changed files
with
192 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 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 |