3 # Copyright (c) 2009 Red Hat, Inc.
6 test_description
='Test updating submodules
8 This test verifies that "git submodule update" detaches the HEAD of the
9 submodule and "git submodule update --rebase" does not detach the HEAD.
17 sha_master
=`git-rev-list --max-count=1 master`
18 sha_head
=`git-rev-list --max-count=1 HEAD`
20 test "$sha_master" = "$sha_head"
24 test_expect_success
'setup a submodule tree' '
28 git commit -m upstream
30 git clone super submodule &&
32 git submodule add ../submodule submodule &&
34 git commit -m "submodule" &&
35 git submodule init submodule
38 echo "line2" > file &&
40 git commit -m "Commit 2"
44 git pull --rebase origin
47 git commit -m "submodule update"
51 test_expect_success
'submodule update detaching the HEAD ' '
52 (cd super/submodule &&
53 git reset --hard HEAD~1
59 git submodule update submodule &&
65 test_expect_success
'submodule update --rebase staying on master' '
66 (cd super/submodule &&
73 git submodule update --rebase submodule &&
79 test_expect_success
'submodule update - rebase in .git/config' '
81 git config submodule.submodule.update rebase
83 (cd super/submodule &&
84 git reset --hard HEAD~1
90 git submodule update submodule &&
96 test_expect_success
'submodule update - checkout in .git/config but --rebase given' '
98 git config submodule.submodule.update checkout
100 (cd super/submodule &&
101 git reset --hard HEAD~1
107 git submodule update --rebase submodule &&
113 test_expect_success
'submodule update - checkout in .git/config' '
115 git config submodule.submodule.update checkout
117 (cd super/submodule &&
118 git reset --hard HEAD^
124 git submodule update submodule &&
130 test_expect_success
'submodule init picks up rebase' '
132 git config submodule.rebasing.url git://non-existing/git &&
133 git config submodule.rebasing.path does-not-matter &&
134 git config submodule.rebasing.update rebase &&
135 git submodule init rebasing &&
136 test "rebase" = $(git config submodule.rebasing.update)