Merge branch 'sz/submodule-force-update'
"git submodule update --force" used to leave the working tree of the submodule intact when there were local changes. It is more intiutive to make "--force" a sign to run "checkout -f" to overwrite them. * sz/submodule-force-update: Make 'git submodule update --force' always check out submodules.
This commit is contained in:
commit
81dbbf7240
@ -149,6 +149,11 @@ submodule with the `--init` option.
|
|||||||
+
|
+
|
||||||
If `--recursive` is specified, this command will recurse into the
|
If `--recursive` is specified, this command will recurse into the
|
||||||
registered submodules, and update any nested submodules within.
|
registered submodules, and update any nested submodules within.
|
||||||
|
+
|
||||||
|
If `--force` is specified, the submodule will be checked out (using
|
||||||
|
`git checkout --force` if appropriate), even if the commit specified in the
|
||||||
|
index of the containing repository already matches the commit checked out in
|
||||||
|
the submodule.
|
||||||
|
|
||||||
summary::
|
summary::
|
||||||
Show commit summary between the given commit (defaults to HEAD) and
|
Show commit summary between the given commit (defaults to HEAD) and
|
||||||
@ -210,7 +215,9 @@ OPTIONS
|
|||||||
This option is only valid for add and update commands.
|
This option is only valid for add and update commands.
|
||||||
When running add, allow adding an otherwise ignored submodule path.
|
When running add, allow adding an otherwise ignored submodule path.
|
||||||
When running update, throw away local changes in submodules when
|
When running update, throw away local changes in submodules when
|
||||||
switching to a different commit.
|
switching to a different commit; and always run a checkout operation
|
||||||
|
in the submodule, even if the commit listed in the index of the
|
||||||
|
containing repository matches the commit checked out in the submodule.
|
||||||
|
|
||||||
--cached::
|
--cached::
|
||||||
This option is only valid for status and summary commands. These
|
This option is only valid for status and summary commands. These
|
||||||
|
@ -603,7 +603,7 @@ Maybe you want to use 'update --init'?")"
|
|||||||
die "$(eval_gettext "Unable to find current revision in submodule path '\$sm_path'")"
|
die "$(eval_gettext "Unable to find current revision in submodule path '\$sm_path'")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "$subsha1" != "$sha1"
|
if test "$subsha1" != "$sha1" -o -n "$force"
|
||||||
then
|
then
|
||||||
subforce=$force
|
subforce=$force
|
||||||
# If we don't already have a -f flag and the submodule has never been checked out
|
# If we don't already have a -f flag and the submodule has never been checked out
|
||||||
|
@ -123,6 +123,18 @@ test_expect_success 'submodule update should throw away changes with --force ' '
|
|||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
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)" = ""
|
||||||
|
)
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'submodule update --rebase staying on master' '
|
test_expect_success 'submodule update --rebase staying on master' '
|
||||||
(cd super/submodule &&
|
(cd super/submodule &&
|
||||||
git checkout master
|
git checkout master
|
||||||
|
Loading…
Reference in New Issue
Block a user