git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Make 'git submodule update --force' always check out submodules.

From
SZStefan Zager <szager@google.com>
Date
Jul 25, 2012, 18:03 UTC
Message-ID
<1343239412-26780-1-git-send-email-szager@google.com>

Currently, it will only do a checkout if the sha1 registered in the containing repository doesn't match the HEAD of the submodule, regardless of whether the submodule is dirty. As discussed on the mailing list, the '--force' flag is a strong indicator that the state of the submodule is suspect, and should be reset to HEAD.

Signed-off-by: Stefan Zager <szager@google.com>
---
 git-submodule.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index dba4d39..621eff7 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -575,7 +575,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
-- 
1.7.11.rc2
Next: Junio C Hamano
Message 1 of 5 in “Make 'git submodule update --force' always check out submodules.”
  1. Make 'git submodule update --force' always check out submodules.Stefan Zager, Jul 25, 2012
  2. Junio C HamanoJul 25, 2012
  3. Jens LehmannJul 25, 2012
  4. Junio C HamanoJul 25, 2012
  5. Junio C HamanoAug 17, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.