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

5 messages from 2012-07-25 to 2012-08-17. Participants: Stefan Zager, Junio C Hamano, Jens Lehmann.
Thread: https://gitlist.dev/t/31099

## Stefan Zager, 2012-07-25 18:03

Subject: [PATCH] Make 'git submodule update --force' always check out submodules.
Message-ID: <1343239412-26780-1-git-send-email-szager@google.com>
URL: https://gitlist.dev/e/1343239412-26780-1-git-send-email-szager%40google.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

```

## Junio C Hamano, 2012-07-25 18:44

Subject: Re: [PATCH] Make 'git submodule update --force' always check out submodules.
Message-ID: <7vipdbbs0b.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vipdbbs0b.fsf%40alter.siamese.dyndns.org
In-Reply-To: <1343239412-26780-1-git-send-email-szager@google.com>

```
Stefan Zager <szager@google.com> writes:

> 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>
> ---

Looks sensible (again -- see http://thread.gmane.org/gmane.comp.version-control.git/197532
for the original discussion).  Can submodule folks Ack it?

Thanks.


>  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

```

## Jens Lehmann, 2012-07-25 20:51

Subject: Re: [PATCH] Make 'git submodule update --force' always check out submodules.
Message-ID: <50105C60.4050303@web.de>
URL: https://gitlist.dev/e/50105C60.4050303%40web.de
In-Reply-To: <7vipdbbs0b.fsf@alter.siamese.dyndns.org>

```
Am 25.07.2012 20:44, schrieb Junio C Hamano:
> Stefan Zager <szager@google.com> writes:
> 
>> 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>
>> ---
> 
> Looks sensible (again -- see http://thread.gmane.org/gmane.comp.version-control.git/197532
> for the original discussion).  Can submodule folks Ack it?

I like it. Still I'd vote for amending the documentation like the
original thread proposed and would appreciate to have a test or two,
but apart from that I have no objections.

>>  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
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

```

## Junio C Hamano, 2012-07-25 22:09

Subject: Re: [PATCH] Make 'git submodule update --force' always check out submodules.
Message-ID: <7vwr1ra3x2.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vwr1ra3x2.fsf%40alter.siamese.dyndns.org
In-Reply-To: <50105C60.4050303@web.de>

```
Jens Lehmann <Jens.Lehmann@web.de> writes:

> Am 25.07.2012 20:44, schrieb Junio C Hamano:
>> Stefan Zager <szager@google.com> writes:
>> 
>>> 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>
>>> ---
>> 
>> Looks sensible (again -- see http://thread.gmane.org/gmane.comp.version-control.git/197532
>> for the original discussion).  Can submodule folks Ack it?
>
> I like it. Still I'd vote for amending the documentation like the
> original thread proposed and would appreciate to have a test or two,
> but apart from that I have no objections.

OK, then I'll queue this so that we won't forget about the topic for
now, and docs and tests can be done as follow-up patches to the
topic.

Thanks.

```

## Junio C Hamano, 2012-08-17 03:23

Subject: Re: [PATCH] Make 'git submodule update --force' always check out submodules.
Message-ID: <7v7gsyxktu.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v7gsyxktu.fsf%40alter.siamese.dyndns.org
In-Reply-To: <50105C60.4050303@web.de>

```
Jens Lehmann <Jens.Lehmann@web.de> writes:

> Am 25.07.2012 20:44, schrieb Junio C Hamano:
>> Stefan Zager <szager@google.com> writes:
>> 
>>> 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>
>>> ---
>> 
>> Looks sensible (again -- see http://thread.gmane.org/gmane.comp.version-control.git/197532
>> for the original discussion).  Can submodule folks Ack it?
>
> I like it. Still I'd vote for amending the documentation like the
> original thread proposed and would appreciate to have a test or two,
> but apart from that I have no objections.

Mind ping on missing follow-ups.

```
