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()
|
|
|
|
{
|
2016-01-08 14:06:20 +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 &&
|
2011-08-11 21:51:46 +04:00
|
|
|
git clone super none &&
|
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"
|
2013-09-15 21:38:21 +04:00
|
|
|
) &&
|
2011-08-11 21:51:46 +04:00
|
|
|
(cd super &&
|
|
|
|
git submodule add ../none none &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m "none"
|
2016-03-30 04:27:42 +03:00
|
|
|
) &&
|
|
|
|
git clone . recursivesuper &&
|
|
|
|
( cd recursivesuper
|
|
|
|
git submodule add ../super super
|
2011-08-11 21:51:46 +04:00
|
|
|
)
|
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 &&
|
2013-06-16 18:18:18 +04:00
|
|
|
! compare_head
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submodule update from subdirectory' '
|
|
|
|
(cd super/submodule &&
|
|
|
|
git reset --hard HEAD~1
|
|
|
|
) &&
|
|
|
|
mkdir super/sub &&
|
|
|
|
(cd super/sub &&
|
|
|
|
(cd ../submodule &&
|
|
|
|
compare_head
|
|
|
|
) &&
|
|
|
|
git submodule update ../submodule &&
|
|
|
|
cd ../submodule &&
|
2009-04-24 03:06:38 +04:00
|
|
|
! compare_head
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2016-03-30 04:27:42 +03:00
|
|
|
supersha1=$(git -C super rev-parse HEAD)
|
|
|
|
mergingsha1=$(git -C super/merging rev-parse HEAD)
|
|
|
|
nonesha1=$(git -C super/none rev-parse HEAD)
|
|
|
|
rebasingsha1=$(git -C super/rebasing rev-parse HEAD)
|
|
|
|
submodulesha1=$(git -C super/submodule rev-parse HEAD)
|
|
|
|
pwd=$(pwd)
|
|
|
|
|
|
|
|
cat <<EOF >expect
|
|
|
|
Submodule path '../super': checked out '$supersha1'
|
|
|
|
Submodule path '../super/merging': checked out '$mergingsha1'
|
|
|
|
Submodule path '../super/none': checked out '$nonesha1'
|
|
|
|
Submodule path '../super/rebasing': checked out '$rebasingsha1'
|
|
|
|
Submodule path '../super/submodule': checked out '$submodulesha1'
|
|
|
|
EOF
|
|
|
|
|
2016-05-03 01:24:04 +03:00
|
|
|
cat <<EOF >expect2
|
|
|
|
Submodule 'merging' ($pwd/merging) registered for path '../super/merging'
|
|
|
|
Submodule 'none' ($pwd/none) registered for path '../super/none'
|
|
|
|
Submodule 'rebasing' ($pwd/rebasing) registered for path '../super/rebasing'
|
|
|
|
Submodule 'submodule' ($pwd/submodule) registered for path '../super/submodule'
|
|
|
|
Cloning into '$pwd/recursivesuper/super/merging'...
|
|
|
|
done.
|
|
|
|
Cloning into '$pwd/recursivesuper/super/none'...
|
|
|
|
done.
|
|
|
|
Cloning into '$pwd/recursivesuper/super/rebasing'...
|
|
|
|
done.
|
|
|
|
Cloning into '$pwd/recursivesuper/super/submodule'...
|
|
|
|
done.
|
|
|
|
EOF
|
|
|
|
|
2016-03-30 04:27:42 +03:00
|
|
|
test_expect_success 'submodule update --init --recursive from subdirectory' '
|
|
|
|
git -C recursivesuper/super reset --hard HEAD^ &&
|
|
|
|
(cd recursivesuper &&
|
|
|
|
mkdir tmp &&
|
|
|
|
cd tmp &&
|
2016-05-03 01:24:04 +03:00
|
|
|
git submodule update --init --recursive ../super >../../actual 2>../../actual2
|
2016-03-30 04:27:42 +03:00
|
|
|
) &&
|
2016-05-03 01:24:04 +03:00
|
|
|
test_cmp expect actual &&
|
|
|
|
test_cmp expect2 actual2
|
2016-03-30 04:27:42 +03:00
|
|
|
'
|
|
|
|
|
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
|
|
|
|
) &&
|
2011-05-21 22:44:02 +04:00
|
|
|
test_i18ncmp expected actual &&
|
2011-03-07 01:13:36 +03:00
|
|
|
! 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
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2012-07-25 21:41:54 +04:00
|
|
|
test_expect_success 'submodule update --force forcibly checks out submodules' '
|
|
|
|
(cd super &&
|
|
|
|
(cd submodule &&
|
|
|
|
rm -f file
|
|
|
|
) &&
|
|
|
|
git submodule update --force submodule &&
|
|
|
|
(cd submodule &&
|
|
|
|
test "$(git status -s file)" = ""
|
|
|
|
)
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
submodule update: add --remote for submodule's upstream changes
The current `update` command incorporates the superproject's gitlinked
SHA-1 ($sha1) into the submodule HEAD ($subsha1). Depending on the
options you use, it may checkout $sha1, rebase the $subsha1 onto
$sha1, or merge $sha1 into $subsha1. This helps you keep up with
changes in the upstream superproject.
However, it's also useful to stay up to date with changes in the
upstream subproject. Previous workflows for incorporating such
changes include the ungainly:
$ git submodule foreach 'git checkout $(git config --file $toplevel/.gitmodules submodule.$name.branch) && git pull'
With this patch, all of the useful functionality for incorporating
superproject changes can be reused to incorporate upstream subproject
updates. When you specify --remote, the target $sha1 is replaced with
a $sha1 of the submodule's origin/master tracking branch. If you want
to merge a different tracking branch, you can configure the
`submodule.<name>.branch` option in `.gitmodules`. You can override
the `.gitmodules` configuration setting for a particular superproject
by configuring the option in that superproject's default configuration
(using the usual configuration hierarchy, e.g. `.git/config`,
`~/.gitconfig`, etc.).
Previous use of submodule.<name>.branch
=======================================
Because we're adding a new configuration option, it's a good idea to
check if anyone else is already using the option. The foreach-pull
example above was described by Ævar in
commit f030c96d8643fa0a1a9b2bd9c2f36a77721fb61f
Author: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date: Fri May 21 16:10:10 2010 +0000
git-submodule foreach: Add $toplevel variable
Gerrit uses the same interpretation for the setting, but because
Gerrit has direct access to the subproject repositories, it updates
the superproject repositories automatically when a subproject changes.
Gerrit also accepts the special value '.', which it expands into the
superproject's branch name.
Although the --remote functionality is using `submodule.<name>.branch`
slightly differently, the effect is the same. The foreach-pull
example uses the option to record the name of the local branch to
checkout before pulls. The tracking branch to be pulled is recorded
in `.git/modules/<name>/config`, which was initialized by the module
clone during `submodule add` or `submodule init`. Because the branch
name stored in `submodule.<name>.branch` was likely the same as the
branch name used during the initial `submodule add`, the same branch
will be pulled in each workflow.
Implementation details
======================
In order to ensure a current tracking branch state, `update --remote`
fetches the submodule's remote repository before calculating the
SHA-1. However, I didn't change the logic guarding the existing fetch:
if test -z "$nofetch"
then
# Run fetch only if $sha1 isn't present or it
# is not reachable from a ref.
(clear_local_git_env; cd "$path" &&
( (rev=$(git rev-list -n 1 $sha1 --not --all 2>/dev/null) &&
test -z "$rev") || git-fetch)) ||
die "$(eval_gettext "Unable to fetch in submodule path '\$path'")"
fi
There will not be a double-fetch, because the new $sha1 determined
after the `--remote` triggered fetch should always exist in the
repository. If it doesn't, it's because some racy process removed it
from the submodule's repository and we *should* be re-fetching.
Signed-off-by: W. Trevor King <wking@tremily.us>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-12-19 20:03:32 +04:00
|
|
|
test_expect_success 'submodule update --remote should fetch upstream changes' '
|
|
|
|
(cd submodule &&
|
|
|
|
echo line4 >> file &&
|
|
|
|
git add file &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m "upstream line4"
|
|
|
|
) &&
|
|
|
|
(cd super &&
|
|
|
|
git submodule update --remote --force submodule &&
|
|
|
|
cd submodule &&
|
|
|
|
test "$(git log -1 --oneline)" = "$(GIT_DIR=../../submodule/.git git log -1 --oneline)"
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'local config should override .gitmodules branch' '
|
|
|
|
(cd submodule &&
|
|
|
|
git checkout -b test-branch &&
|
|
|
|
echo line5 >> file &&
|
|
|
|
git add file &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m "upstream line5" &&
|
|
|
|
git checkout master
|
|
|
|
) &&
|
|
|
|
(cd super &&
|
|
|
|
git config submodule.submodule.branch test-branch &&
|
|
|
|
git submodule update --remote --force submodule &&
|
|
|
|
cd submodule &&
|
|
|
|
test "$(git log -1 --oneline)" = "$(GIT_DIR=../../submodule/.git git log -1 --oneline test-branch)"
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
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
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2013-07-03 13:02:02 +04:00
|
|
|
test_expect_success 'submodule update - command in .git/config' '
|
|
|
|
(cd super &&
|
|
|
|
git config submodule.submodule.update "!git checkout"
|
|
|
|
) &&
|
|
|
|
(cd super/submodule &&
|
|
|
|
git reset --hard HEAD^
|
|
|
|
) &&
|
|
|
|
(cd super &&
|
|
|
|
(cd submodule &&
|
|
|
|
compare_head
|
|
|
|
) &&
|
|
|
|
git submodule update submodule &&
|
|
|
|
cd submodule &&
|
|
|
|
! compare_head
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2016-03-30 04:27:44 +03:00
|
|
|
cat << EOF >expect
|
|
|
|
Execution of 'false $submodulesha1' failed in submodule path 'submodule'
|
|
|
|
EOF
|
|
|
|
|
2013-07-03 13:02:02 +04:00
|
|
|
test_expect_success 'submodule update - command in .git/config catches failure' '
|
|
|
|
(cd super &&
|
|
|
|
git config submodule.submodule.update "!false"
|
|
|
|
) &&
|
|
|
|
(cd super/submodule &&
|
2016-03-30 04:27:44 +03:00
|
|
|
git reset --hard $submodulesha1^
|
2013-07-03 13:02:02 +04:00
|
|
|
) &&
|
|
|
|
(cd super &&
|
2016-03-30 04:27:44 +03:00
|
|
|
test_must_fail git submodule update submodule 2>../actual
|
|
|
|
) &&
|
|
|
|
test_cmp actual expect
|
|
|
|
'
|
|
|
|
|
|
|
|
cat << EOF >expect
|
|
|
|
Execution of 'false $submodulesha1' failed in submodule path '../submodule'
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'submodule update - command in .git/config catches failure -- subdirectory' '
|
|
|
|
(cd super &&
|
|
|
|
git config submodule.submodule.update "!false"
|
|
|
|
) &&
|
|
|
|
(cd super/submodule &&
|
|
|
|
git reset --hard $submodulesha1^
|
|
|
|
) &&
|
|
|
|
(cd super &&
|
|
|
|
mkdir tmp && cd tmp &&
|
|
|
|
test_must_fail git submodule update ../submodule 2>../../actual
|
2016-03-30 04:27:45 +03:00
|
|
|
) &&
|
|
|
|
test_cmp actual expect
|
|
|
|
'
|
|
|
|
|
|
|
|
cat << EOF >expect
|
|
|
|
Execution of 'false $submodulesha1' failed in submodule path '../super/submodule'
|
|
|
|
Failed to recurse into submodule path '../super'
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'recursive submodule update - command in .git/config catches failure -- subdirectory' '
|
|
|
|
(cd recursivesuper &&
|
|
|
|
git submodule update --remote super &&
|
|
|
|
git add super &&
|
|
|
|
git commit -m "update to latest to have more than one commit in submodules"
|
|
|
|
) &&
|
|
|
|
git -C recursivesuper/super config submodule.submodule.update "!false" &&
|
|
|
|
git -C recursivesuper/super/submodule reset --hard $submodulesha1^ &&
|
|
|
|
(cd recursivesuper &&
|
|
|
|
mkdir -p tmp && cd tmp &&
|
|
|
|
test_must_fail git submodule update --recursive ../super 2>../../actual
|
2016-03-30 04:27:44 +03:00
|
|
|
) &&
|
|
|
|
test_cmp actual expect
|
2013-07-03 13:02:02 +04:00
|
|
|
'
|
|
|
|
|
2013-12-03 01:31:55 +04:00
|
|
|
test_expect_success 'submodule init does not copy command into .git/config' '
|
|
|
|
(cd super &&
|
|
|
|
H=$(git ls-files -s submodule | cut -d" " -f2) &&
|
|
|
|
mkdir submodule1 &&
|
|
|
|
git update-index --add --cacheinfo 160000 $H submodule1 &&
|
|
|
|
git config -f .gitmodules submodule.submodule1.path submodule1 &&
|
|
|
|
git config -f .gitmodules submodule.submodule1.url ../submodule &&
|
|
|
|
git config -f .gitmodules submodule.submodule1.update !false &&
|
|
|
|
git submodule init submodule1 &&
|
|
|
|
echo "none" >expect &&
|
|
|
|
git config submodule.submodule1.update >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2009-04-24 03:06:38 +04:00
|
|
|
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
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2011-08-11 21:51:46 +04:00
|
|
|
test_expect_success 'submodule init picks up update=none' '
|
|
|
|
(cd super &&
|
|
|
|
git config -f .gitmodules submodule.none.update none &&
|
|
|
|
git submodule init none &&
|
|
|
|
test "none" = "$(git config submodule.none.update)"
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submodule update - update=none in .git/config' '
|
|
|
|
(cd super &&
|
|
|
|
git config submodule.submodule.update none &&
|
|
|
|
(cd submodule &&
|
|
|
|
git checkout master &&
|
|
|
|
compare_head
|
|
|
|
) &&
|
|
|
|
git diff --raw | grep " submodule" &&
|
|
|
|
git submodule update &&
|
|
|
|
git diff --raw | grep " submodule" &&
|
|
|
|
(cd submodule &&
|
|
|
|
compare_head
|
|
|
|
) &&
|
|
|
|
git config --unset submodule.submodule.update &&
|
|
|
|
git submodule update submodule
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submodule update - update=none in .git/config but --checkout given' '
|
|
|
|
(cd super &&
|
|
|
|
git config submodule.submodule.update none &&
|
|
|
|
(cd submodule &&
|
|
|
|
git checkout master &&
|
|
|
|
compare_head
|
|
|
|
) &&
|
|
|
|
git diff --raw | grep " submodule" &&
|
|
|
|
git submodule update --checkout &&
|
|
|
|
test_must_fail git diff --raw \| grep " submodule" &&
|
|
|
|
(cd submodule &&
|
|
|
|
test_must_fail compare_head
|
|
|
|
) &&
|
|
|
|
git config --unset submodule.submodule.update
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submodule update --init skips submodule with update=none' '
|
|
|
|
(cd super &&
|
|
|
|
git add .gitmodules &&
|
|
|
|
git commit -m ".gitmodules"
|
|
|
|
) &&
|
|
|
|
git clone super cloned &&
|
|
|
|
(cd cloned &&
|
|
|
|
git submodule update --init &&
|
|
|
|
test -e submodule/.git &&
|
|
|
|
test_must_fail test -e none/.git
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2011-06-13 21:15:26 +04:00
|
|
|
test_expect_success 'submodule update continues after checkout error' '
|
|
|
|
(cd super &&
|
|
|
|
git reset --hard HEAD &&
|
|
|
|
git submodule add ../submodule submodule2 &&
|
|
|
|
git submodule init &&
|
|
|
|
git commit -am "new_submodule" &&
|
|
|
|
(cd submodule2 &&
|
2012-07-30 21:51:52 +04:00
|
|
|
git rev-parse --verify HEAD >../expect
|
2011-06-13 21:15:26 +04:00
|
|
|
) &&
|
|
|
|
(cd submodule &&
|
|
|
|
test_commit "update_submodule" file
|
|
|
|
) &&
|
|
|
|
(cd submodule2 &&
|
|
|
|
test_commit "update_submodule2" file
|
|
|
|
) &&
|
|
|
|
git add submodule &&
|
|
|
|
git add submodule2 &&
|
|
|
|
git commit -m "two_new_submodule_commits" &&
|
|
|
|
(cd submodule &&
|
|
|
|
echo "" > file
|
|
|
|
) &&
|
|
|
|
git checkout HEAD^ &&
|
|
|
|
test_must_fail git submodule update &&
|
|
|
|
(cd submodule2 &&
|
2012-07-30 21:51:52 +04:00
|
|
|
git rev-parse --verify HEAD >../actual
|
2011-06-13 21:15:26 +04:00
|
|
|
) &&
|
|
|
|
test_cmp expect actual
|
|
|
|
)
|
|
|
|
'
|
|
|
|
test_expect_success 'submodule update continues after recursive checkout error' '
|
|
|
|
(cd super &&
|
|
|
|
git reset --hard HEAD &&
|
|
|
|
git checkout master &&
|
|
|
|
git submodule update &&
|
|
|
|
(cd submodule &&
|
|
|
|
git submodule add ../submodule subsubmodule &&
|
|
|
|
git submodule init &&
|
|
|
|
git commit -m "new_subsubmodule"
|
|
|
|
) &&
|
|
|
|
git add submodule &&
|
|
|
|
git commit -m "update_submodule" &&
|
|
|
|
(cd submodule &&
|
|
|
|
(cd subsubmodule &&
|
|
|
|
test_commit "update_subsubmodule" file
|
|
|
|
) &&
|
|
|
|
git add subsubmodule &&
|
|
|
|
test_commit "update_submodule_again" file &&
|
|
|
|
(cd subsubmodule &&
|
|
|
|
test_commit "update_subsubmodule_again" file
|
|
|
|
) &&
|
|
|
|
test_commit "update_submodule_again_again" file
|
|
|
|
) &&
|
|
|
|
(cd submodule2 &&
|
2012-07-30 21:51:52 +04:00
|
|
|
git rev-parse --verify HEAD >../expect &&
|
2011-06-13 21:15:26 +04:00
|
|
|
test_commit "update_submodule2_again" file
|
|
|
|
) &&
|
|
|
|
git add submodule &&
|
|
|
|
git add submodule2 &&
|
|
|
|
git commit -m "new_commits" &&
|
|
|
|
git checkout HEAD^ &&
|
|
|
|
(cd submodule &&
|
|
|
|
git checkout HEAD^ &&
|
|
|
|
(cd subsubmodule &&
|
|
|
|
echo "" > file
|
|
|
|
)
|
|
|
|
) &&
|
|
|
|
test_must_fail git submodule update --recursive &&
|
|
|
|
(cd submodule2 &&
|
2012-07-30 21:51:52 +04:00
|
|
|
git rev-parse --verify HEAD >../actual
|
2011-06-13 21:15:26 +04:00
|
|
|
) &&
|
|
|
|
test_cmp expect actual
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submodule update exit immediately in case of merge conflict' '
|
|
|
|
(cd super &&
|
|
|
|
git checkout master &&
|
|
|
|
git reset --hard HEAD &&
|
|
|
|
(cd submodule &&
|
|
|
|
(cd subsubmodule &&
|
|
|
|
git reset --hard HEAD
|
|
|
|
)
|
|
|
|
) &&
|
|
|
|
git submodule update --recursive &&
|
|
|
|
(cd submodule &&
|
|
|
|
test_commit "update_submodule_2" file
|
|
|
|
) &&
|
|
|
|
(cd submodule2 &&
|
|
|
|
test_commit "update_submodule2_2" file
|
|
|
|
) &&
|
|
|
|
git add submodule &&
|
|
|
|
git add submodule2 &&
|
|
|
|
git commit -m "two_new_submodule_commits" &&
|
|
|
|
(cd submodule &&
|
|
|
|
git checkout master &&
|
|
|
|
test_commit "conflict" file &&
|
|
|
|
echo "conflict" > file
|
|
|
|
) &&
|
|
|
|
git checkout HEAD^ &&
|
|
|
|
(cd submodule2 &&
|
2012-07-30 21:51:52 +04:00
|
|
|
git rev-parse --verify HEAD >../expect
|
2011-06-13 21:15:26 +04:00
|
|
|
) &&
|
|
|
|
git config submodule.submodule.update merge &&
|
|
|
|
test_must_fail git submodule update &&
|
|
|
|
(cd submodule2 &&
|
2012-07-30 21:51:52 +04:00
|
|
|
git rev-parse --verify HEAD >../actual
|
2011-06-13 21:15:26 +04:00
|
|
|
) &&
|
|
|
|
test_cmp expect actual
|
|
|
|
)
|
|
|
|
'
|
2011-08-16 01:17:47 +04:00
|
|
|
|
2011-06-13 21:15:26 +04:00
|
|
|
test_expect_success 'submodule update exit immediately after recursive rebase error' '
|
|
|
|
(cd super &&
|
|
|
|
git checkout master &&
|
|
|
|
git reset --hard HEAD &&
|
|
|
|
(cd submodule &&
|
|
|
|
git reset --hard HEAD &&
|
|
|
|
git submodule update --recursive
|
|
|
|
) &&
|
|
|
|
(cd submodule &&
|
|
|
|
test_commit "update_submodule_3" file
|
|
|
|
) &&
|
|
|
|
(cd submodule2 &&
|
|
|
|
test_commit "update_submodule2_3" file
|
|
|
|
) &&
|
|
|
|
git add submodule &&
|
|
|
|
git add submodule2 &&
|
|
|
|
git commit -m "two_new_submodule_commits" &&
|
|
|
|
(cd submodule &&
|
|
|
|
git checkout master &&
|
|
|
|
test_commit "conflict2" file &&
|
|
|
|
echo "conflict" > file
|
|
|
|
) &&
|
|
|
|
git checkout HEAD^ &&
|
|
|
|
(cd submodule2 &&
|
2012-07-30 21:51:52 +04:00
|
|
|
git rev-parse --verify HEAD >../expect
|
2011-06-13 21:15:26 +04:00
|
|
|
) &&
|
|
|
|
git config submodule.submodule.update rebase &&
|
|
|
|
test_must_fail git submodule update &&
|
|
|
|
(cd submodule2 &&
|
2012-07-30 21:51:52 +04:00
|
|
|
git rev-parse --verify HEAD >../actual
|
2011-06-13 21:15:26 +04:00
|
|
|
) &&
|
|
|
|
test_cmp expect actual
|
|
|
|
)
|
|
|
|
'
|
2011-08-16 01:17:47 +04:00
|
|
|
|
|
|
|
test_expect_success 'add different submodules to the same path' '
|
|
|
|
(cd super &&
|
|
|
|
git submodule add ../submodule s1 &&
|
|
|
|
test_must_fail git submodule add ../merging s1
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submodule add places git-dir in superprojects git-dir' '
|
|
|
|
(cd super &&
|
|
|
|
mkdir deeper &&
|
|
|
|
git submodule add ../submodule deeper/submodule &&
|
|
|
|
(cd deeper/submodule &&
|
|
|
|
git log > ../../expected
|
|
|
|
) &&
|
|
|
|
(cd .git/modules/deeper/submodule &&
|
|
|
|
git log > ../../../../actual
|
|
|
|
) &&
|
|
|
|
test_cmp actual expected
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submodule update places git-dir in superprojects git-dir' '
|
|
|
|
(cd super &&
|
|
|
|
git commit -m "added submodule"
|
|
|
|
) &&
|
|
|
|
git clone super super2 &&
|
|
|
|
(cd super2 &&
|
|
|
|
git submodule init deeper/submodule &&
|
|
|
|
git submodule update &&
|
|
|
|
(cd deeper/submodule &&
|
|
|
|
git log > ../../expected
|
|
|
|
) &&
|
|
|
|
(cd .git/modules/deeper/submodule &&
|
|
|
|
git log > ../../../../actual
|
|
|
|
) &&
|
|
|
|
test_cmp actual expected
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submodule add places git-dir in superprojects git-dir recursive' '
|
|
|
|
(cd super2 &&
|
|
|
|
(cd deeper/submodule &&
|
|
|
|
git submodule add ../submodule subsubmodule &&
|
|
|
|
(cd subsubmodule &&
|
|
|
|
git log > ../../../expected
|
|
|
|
) &&
|
|
|
|
git commit -m "added subsubmodule" &&
|
2013-01-05 04:19:19 +04:00
|
|
|
git push origin :
|
2011-08-16 01:17:47 +04:00
|
|
|
) &&
|
|
|
|
(cd .git/modules/deeper/submodule/modules/subsubmodule &&
|
|
|
|
git log > ../../../../../actual
|
|
|
|
) &&
|
|
|
|
git add deeper/submodule &&
|
|
|
|
git commit -m "update submodule" &&
|
2013-01-05 04:19:19 +04:00
|
|
|
git push origin : &&
|
2011-08-16 01:17:47 +04:00
|
|
|
test_cmp actual expected
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submodule update places git-dir in superprojects git-dir recursive' '
|
|
|
|
mkdir super_update_r &&
|
|
|
|
(cd super_update_r &&
|
|
|
|
git init --bare
|
|
|
|
) &&
|
|
|
|
mkdir subsuper_update_r &&
|
|
|
|
(cd subsuper_update_r &&
|
|
|
|
git init --bare
|
|
|
|
) &&
|
|
|
|
mkdir subsubsuper_update_r &&
|
|
|
|
(cd subsubsuper_update_r &&
|
|
|
|
git init --bare
|
|
|
|
) &&
|
|
|
|
git clone subsubsuper_update_r subsubsuper_update_r2 &&
|
|
|
|
(cd subsubsuper_update_r2 &&
|
|
|
|
test_commit "update_subsubsuper" file &&
|
|
|
|
git push origin master
|
|
|
|
) &&
|
|
|
|
git clone subsuper_update_r subsuper_update_r2 &&
|
|
|
|
(cd subsuper_update_r2 &&
|
|
|
|
test_commit "update_subsuper" file &&
|
|
|
|
git submodule add ../subsubsuper_update_r subsubmodule &&
|
|
|
|
git commit -am "subsubmodule" &&
|
|
|
|
git push origin master
|
|
|
|
) &&
|
|
|
|
git clone super_update_r super_update_r2 &&
|
|
|
|
(cd super_update_r2 &&
|
|
|
|
test_commit "update_super" file &&
|
|
|
|
git submodule add ../subsuper_update_r submodule &&
|
|
|
|
git commit -am "submodule" &&
|
|
|
|
git push origin master
|
|
|
|
) &&
|
|
|
|
rm -rf super_update_r2 &&
|
|
|
|
git clone super_update_r super_update_r2 &&
|
|
|
|
(cd super_update_r2 &&
|
2013-03-02 23:44:59 +04:00
|
|
|
git submodule update --init --recursive >actual &&
|
2014-04-03 01:15:36 +04:00
|
|
|
test_i18ngrep "Submodule path .submodule/subsubmodule.: checked out" actual &&
|
2011-08-16 01:17:47 +04:00
|
|
|
(cd submodule/subsubmodule &&
|
|
|
|
git log > ../../expected
|
|
|
|
) &&
|
|
|
|
(cd .git/modules/submodule/modules/subsubmodule
|
|
|
|
git log > ../../../../../actual
|
|
|
|
)
|
|
|
|
test_cmp actual expected
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2012-01-25 01:49:56 +04:00
|
|
|
test_expect_success 'submodule add properly re-creates deeper level submodules' '
|
|
|
|
(cd super &&
|
|
|
|
git reset --hard master &&
|
|
|
|
rm -rf deeper/ &&
|
2012-10-01 01:01:29 +04:00
|
|
|
git submodule add --force ../submodule deeper/submodule
|
2012-01-25 01:49:56 +04:00
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2012-03-05 01:15:36 +04:00
|
|
|
test_expect_success 'submodule update properly revives a moved submodule' '
|
|
|
|
(cd super &&
|
2013-03-13 15:42:52 +04:00
|
|
|
H=$(git rev-parse --short HEAD) &&
|
2012-03-05 01:15:36 +04:00
|
|
|
git commit -am "pre move" &&
|
2013-03-13 15:42:52 +04:00
|
|
|
H2=$(git rev-parse --short HEAD) &&
|
|
|
|
git status | sed "s/$H/XXX/" >expect &&
|
2012-03-05 01:15:36 +04:00
|
|
|
H=$(cd submodule2; git rev-parse HEAD) &&
|
|
|
|
git rm --cached submodule2 &&
|
|
|
|
rm -rf submodule2 &&
|
|
|
|
mkdir -p "moved/sub module" &&
|
|
|
|
git update-index --add --cacheinfo 160000 $H "moved/sub module" &&
|
|
|
|
git config -f .gitmodules submodule.submodule2.path "moved/sub module"
|
|
|
|
git commit -am "post move" &&
|
|
|
|
git submodule update &&
|
2013-03-13 15:42:52 +04:00
|
|
|
git status | sed "s/$H2/XXX/" >actual &&
|
2012-03-05 01:15:36 +04:00
|
|
|
test_cmp expect actual
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2012-07-12 21:45:32 +04:00
|
|
|
test_expect_success SYMLINKS 'submodule update can handle symbolic links in pwd' '
|
|
|
|
mkdir -p linked/dir &&
|
|
|
|
ln -s linked/dir linkto &&
|
2013-07-03 01:42:56 +04:00
|
|
|
(cd linkto &&
|
|
|
|
git clone "$TRASH_DIRECTORY"/super_update_r2 super &&
|
|
|
|
(cd super &&
|
|
|
|
git submodule update --init --recursive
|
|
|
|
)
|
2012-07-12 21:45:32 +04:00
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2013-07-03 01:42:56 +04:00
|
|
|
test_expect_success 'submodule update clone shallow submodule' '
|
|
|
|
git clone cloned super3 &&
|
2015-03-20 13:07:15 +03:00
|
|
|
pwd=$(pwd) &&
|
2013-07-03 01:42:56 +04:00
|
|
|
(cd super3 &&
|
|
|
|
sed -e "s#url = ../#url = file://$pwd/#" <.gitmodules >.gitmodules.tmp &&
|
|
|
|
mv -f .gitmodules.tmp .gitmodules &&
|
|
|
|
git submodule update --init --depth=3
|
|
|
|
(cd submodule &&
|
|
|
|
test 1 = $(git log --oneline | wc -l)
|
|
|
|
)
|
2013-11-12 00:55:52 +04:00
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submodule update --recursive drops module name before recursing' '
|
|
|
|
(cd super2 &&
|
|
|
|
(cd deeper/submodule/subsubmodule &&
|
|
|
|
git checkout HEAD^
|
|
|
|
) &&
|
|
|
|
git submodule update --recursive deeper/submodule >actual &&
|
|
|
|
test_i18ngrep "Submodule path .deeper/submodule/subsubmodule.: checked out" actual
|
2013-07-03 01:42:56 +04:00
|
|
|
)
|
|
|
|
'
|
2016-03-01 05:07:19 +03:00
|
|
|
|
|
|
|
test_expect_success 'submodule update can be run in parallel' '
|
|
|
|
(cd super2 &&
|
|
|
|
GIT_TRACE=$(pwd)/trace.out git submodule update --jobs 7 &&
|
|
|
|
grep "7 tasks" trace.out &&
|
|
|
|
git config submodule.fetchJobs 8 &&
|
|
|
|
GIT_TRACE=$(pwd)/trace.out git submodule update &&
|
|
|
|
grep "8 tasks" trace.out &&
|
|
|
|
GIT_TRACE=$(pwd)/trace.out git submodule update --jobs 9 &&
|
|
|
|
grep "9 tasks" trace.out
|
|
|
|
)
|
|
|
|
'
|
2016-03-01 05:07:20 +03:00
|
|
|
|
|
|
|
test_expect_success 'git clone passes the parallel jobs config on to submodules' '
|
|
|
|
test_when_finished "rm -rf super4" &&
|
|
|
|
GIT_TRACE=$(pwd)/trace.out git clone --recurse-submodules --jobs 7 . super4 &&
|
|
|
|
grep "7 tasks" trace.out &&
|
|
|
|
rm -rf super4 &&
|
|
|
|
git config --global submodule.fetchJobs 8 &&
|
|
|
|
GIT_TRACE=$(pwd)/trace.out git clone --recurse-submodules . super4 &&
|
|
|
|
grep "8 tasks" trace.out &&
|
|
|
|
rm -rf super4 &&
|
|
|
|
GIT_TRACE=$(pwd)/trace.out git clone --recurse-submodules --jobs 9 . super4 &&
|
|
|
|
grep "9 tasks" trace.out &&
|
|
|
|
rm -rf super4
|
|
|
|
'
|
|
|
|
|
2009-04-24 03:06:38 +04:00
|
|
|
test_done
|