Anonymous committed ee7a83f Merge

Merge branch 'sz/submodule-force-update' into maint-1.7.11

* sz/submodule-force-update:
Make 'git submodule update --force' always check out submodules.

Comments (0)

Files changed (3)


 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.
 	Show commit summary between the given commit (defaults to HEAD) and
 	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.
 	This option is only valid for status and summary commands.  These
 			die "$(eval_gettext "Unable to find current revision in submodule path '\$sm_path'")"
-		if test "$subsha1" != "$sha1"
+		if test "$subsha1" != "$sha1" -o -n "$force"
 			# If we don't already have a -f flag and the submodule has never been checked out


+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