summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2012-09-11 11:10:17 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2012-09-11 11:10:17 -0700
commitee7a83f6314a6fe281c8e3e041cfd42b5a2deb44 (patch)
tree2dfda34bb7872b99c9af10b66201b596663b5370
parentMerge branch 'ph/stash-rerere' into maint-1.7.11 (diff)
parentMake 'git submodule update --force' always check out submodules. (diff)
downloadtgif-ee7a83f6314a6fe281c8e3e041cfd42b5a2deb44.tar.xz
Merge branch 'sz/submodule-force-update' into maint-1.7.11
* sz/submodule-force-update: Make 'git submodule update --force' always check out submodules.
-rw-r--r--Documentation/git-submodule.txt9
-rwxr-xr-xgit-submodule.sh2
-rwxr-xr-xt/t7406-submodule-update.sh12
3 files changed, 21 insertions, 2 deletions
diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
index fbbbcb282c..2de7bf0900 100644
--- a/Documentation/git-submodule.txt
+++ b/Documentation/git-submodule.txt
@@ -149,6 +149,11 @@ submodule with the `--init` option.
+
If `--recursive` is specified, this command will recurse into the
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::
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.
When running add, allow adding an otherwise ignored submodule path.
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::
This option is only valid for status and summary commands. These
diff --git a/git-submodule.sh b/git-submodule.sh
index dd3ae0e1a0..e89b516039 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -564,7 +564,7 @@ Maybe you want to use 'update --init'?")"
die "$(eval_gettext "Unable to find current revision in submodule path '\$sm_path'")"
fi
- if test "$subsha1" != "$sha1"
+ if test "$subsha1" != "$sha1" -o -n "$force"
then
subforce=$force
# If we don't already have a -f flag and the submodule has never been checked out
diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index 646298b212..15426530e4 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -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' '
(cd super/submodule &&
git checkout master