2009-04-24 03:06:38 +04:00
|
|
|
#!/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
|
2009-06-03 02:59:12 +04:00
|
|
|
submodule and "git submodule update --rebase/--merge" does not detach the HEAD.
|
2009-04-24 03:06:38 +04:00
|
|
|
'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
|
|
|
|
compare_head()
|
|
|
|
{
|
2009-11-28 21:38:55 +03:00
|
|
|
sha_master=`git rev-list --max-count=1 master`
|
|
|
|
sha_head=`git rev-list --max-count=1 HEAD`
|
2009-04-24 03:06:38 +04:00
|
|
|
|
|
|
|
test "$sha_master" = "$sha_head"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
test_expect_success 'setup a submodule tree' '
|
|
|
|
echo file > file &&
|
|
|
|
git add file &&
|
|
|
|
test_tick &&
|
2010-09-02 01:28:27 +04:00
|
|
|
git commit -m upstream &&
|
2009-04-24 03:06:38 +04:00
|
|
|
git clone . super &&
|
|
|
|
git clone super submodule &&
|
2010-03-05 11:20:38 +03:00
|
|
|
git clone super rebasing &&
|
|
|
|
git clone super merging &&
|
2009-04-24 03:06:38 +04:00
|
|
|
(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"
|
2010-03-05 11:20:38 +03:00
|
|
|
) &&
|
|
|
|
(cd super &&
|
|
|
|
git submodule add ../rebasing rebasing &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m "rebasing"
|
|
|
|
) &&
|
|
|
|
(cd super &&
|
|
|
|
git submodule add ../merging merging &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m "rebasing"
|
2009-04-24 03:06:38 +04:00
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
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
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2011-03-07 01:13:36 +03:00
|
|
|
apos="'";
|
|
|
|
test_expect_success 'submodule update does not fetch already present commits' '
|
|
|
|
(cd submodule &&
|
|
|
|
echo line3 >> file &&
|
|
|
|
git add file &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m "upstream line3"
|
|
|
|
) &&
|
|
|
|
(cd super/submodule &&
|
|
|
|
head=$(git rev-parse --verify HEAD) &&
|
|
|
|
echo "Submodule path ${apos}submodule$apos: checked out $apos$head$apos" > ../../expected &&
|
|
|
|
git reset --hard HEAD~1
|
|
|
|
) &&
|
|
|
|
(cd super &&
|
|
|
|
git submodule update > ../actual 2> ../actual.err
|
|
|
|
) &&
|
|
|
|
test_cmp expected actual &&
|
|
|
|
! test -s actual.err
|
|
|
|
'
|
|
|
|
|
2011-04-01 13:42:03 +04:00
|
|
|
test_expect_success 'submodule update should fail due to local changes' '
|
|
|
|
(cd super/submodule &&
|
|
|
|
git reset --hard HEAD~1 &&
|
|
|
|
echo "local change" > file
|
|
|
|
) &&
|
|
|
|
(cd super &&
|
|
|
|
(cd submodule &&
|
|
|
|
compare_head
|
|
|
|
) &&
|
|
|
|
test_must_fail git submodule update submodule
|
|
|
|
)
|
|
|
|
'
|
|
|
|
test_expect_success 'submodule update should throw away changes with --force ' '
|
|
|
|
(cd super &&
|
|
|
|
(cd submodule &&
|
|
|
|
compare_head
|
|
|
|
) &&
|
|
|
|
git submodule update --force submodule &&
|
|
|
|
cd submodule &&
|
|
|
|
! compare_head
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2009-04-24 03:06:38 +04:00
|
|
|
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
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2009-06-03 02:59:12 +04:00
|
|
|
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
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
Rename submodule.<name>.rebase to submodule.<name>.update
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>
2009-06-03 10:27:06 +04:00
|
|
|
test_expect_success 'submodule update - rebase in .git/config' '
|
2009-04-24 03:06:38 +04:00
|
|
|
(cd super &&
|
Rename submodule.<name>.rebase to submodule.<name>.update
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>
2009-06-03 10:27:06 +04:00
|
|
|
git config submodule.submodule.update rebase
|
2009-04-24 03:06:38 +04:00
|
|
|
) &&
|
|
|
|
(cd super/submodule &&
|
|
|
|
git reset --hard HEAD~1
|
|
|
|
) &&
|
|
|
|
(cd super &&
|
|
|
|
(cd submodule &&
|
|
|
|
compare_head
|
|
|
|
) &&
|
|
|
|
git submodule update submodule &&
|
|
|
|
cd submodule &&
|
|
|
|
compare_head
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
Rename submodule.<name>.rebase to submodule.<name>.update
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>
2009-06-03 10:27:06 +04:00
|
|
|
test_expect_success 'submodule update - checkout in .git/config but --rebase given' '
|
2009-04-24 03:06:38 +04:00
|
|
|
(cd super &&
|
Rename submodule.<name>.rebase to submodule.<name>.update
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>
2009-06-03 10:27:06 +04:00
|
|
|
git config submodule.submodule.update checkout
|
2009-04-24 03:06:38 +04:00
|
|
|
) &&
|
|
|
|
(cd super/submodule &&
|
|
|
|
git reset --hard HEAD~1
|
|
|
|
) &&
|
|
|
|
(cd super &&
|
|
|
|
(cd submodule &&
|
|
|
|
compare_head
|
|
|
|
) &&
|
|
|
|
git submodule update --rebase submodule &&
|
|
|
|
cd submodule &&
|
|
|
|
compare_head
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2009-06-03 02:59:12 +04:00
|
|
|
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
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
Rename submodule.<name>.rebase to submodule.<name>.update
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>
2009-06-03 10:27:06 +04:00
|
|
|
test_expect_success 'submodule update - checkout in .git/config' '
|
2009-04-24 03:06:38 +04:00
|
|
|
(cd super &&
|
Rename submodule.<name>.rebase to submodule.<name>.update
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>
2009-06-03 10:27:06 +04:00
|
|
|
git config submodule.submodule.update checkout
|
2009-04-24 03:06:38 +04:00
|
|
|
) &&
|
|
|
|
(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 &&
|
2010-03-05 11:20:38 +03:00
|
|
|
git config -f .gitmodules submodule.rebasing.update rebase &&
|
2009-04-24 03:06:38 +04:00
|
|
|
git submodule init rebasing &&
|
2010-03-05 11:20:38 +03:00
|
|
|
test "rebase" = "$(git config submodule.rebasing.update)"
|
2009-04-24 03:06:38 +04:00
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2009-06-03 02:59:12 +04:00
|
|
|
test_expect_success 'submodule init picks up merge' '
|
|
|
|
(cd super &&
|
2010-03-05 11:20:38 +03:00
|
|
|
git config -f .gitmodules submodule.merging.update merge &&
|
2009-06-03 02:59:12 +04:00
|
|
|
git submodule init merging &&
|
2010-03-05 11:20:38 +03:00
|
|
|
test "merge" = "$(git config submodule.merging.update)"
|
2009-06-03 02:59:12 +04:00
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2011-02-17 19:18:46 +03:00
|
|
|
test_expect_success 'submodule update --merge - ignores --merge for new submodules' '
|
|
|
|
(cd super &&
|
|
|
|
rm -rf submodule &&
|
|
|
|
git submodule update submodule &&
|
|
|
|
git status -s submodule >expect &&
|
|
|
|
rm -rf submodule &&
|
|
|
|
git submodule update --merge submodule &&
|
|
|
|
git status -s submodule >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submodule update --rebase - ignores --rebase for new submodules' '
|
|
|
|
(cd super &&
|
|
|
|
rm -rf submodule &&
|
|
|
|
git submodule update submodule &&
|
|
|
|
git status -s submodule >expect &&
|
|
|
|
rm -rf submodule &&
|
|
|
|
git submodule update --rebase submodule &&
|
|
|
|
git status -s submodule >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submodule update ignores update=merge config for new submodules' '
|
|
|
|
(cd super &&
|
|
|
|
rm -rf submodule &&
|
|
|
|
git submodule update submodule &&
|
|
|
|
git status -s submodule >expect &&
|
|
|
|
rm -rf submodule &&
|
|
|
|
git config submodule.submodule.update merge &&
|
|
|
|
git submodule update submodule &&
|
|
|
|
git status -s submodule >actual &&
|
|
|
|
git config --unset submodule.submodule.update &&
|
|
|
|
test_cmp expect actual
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submodule update ignores update=rebase config for new submodules' '
|
|
|
|
(cd super &&
|
|
|
|
rm -rf submodule &&
|
|
|
|
git submodule update submodule &&
|
|
|
|
git status -s submodule >expect &&
|
|
|
|
rm -rf submodule &&
|
|
|
|
git config submodule.submodule.update rebase &&
|
|
|
|
git submodule update submodule &&
|
|
|
|
git status -s submodule >actual &&
|
|
|
|
git config --unset submodule.submodule.update &&
|
|
|
|
test_cmp expect actual
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2009-04-24 03:06:38 +04:00
|
|
|
test_done
|