All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Make 'git submodule update --force' always check out submodules.
@ 2012-07-25 18:03 Stefan Zager
  2012-07-25 18:44 ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Zager @ 2012-07-25 18:03 UTC (permalink / raw)
  To: git; +Cc: Stefan Zager, gitster

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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] Make 'git submodule update --force' always check out submodules.
  2012-07-25 18:03 [PATCH] Make 'git submodule update --force' always check out submodules Stefan Zager
@ 2012-07-25 18:44 ` Junio C Hamano
  2012-07-25 20:51   ` Jens Lehmann
  0 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2012-07-25 18:44 UTC (permalink / raw)
  To: Jens Lehmann, Heiko Voigt; +Cc: git, Stefan Zager

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Make 'git submodule update --force' always check out submodules.
  2012-07-25 18:44 ` Junio C Hamano
@ 2012-07-25 20:51   ` Jens Lehmann
  2012-07-25 22:09     ` Junio C Hamano
  2012-08-17  3:23     ` Junio C Hamano
  0 siblings, 2 replies; 8+ messages in thread
From: Jens Lehmann @ 2012-07-25 20:51 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Heiko Voigt, git, Stefan Zager

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
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Make 'git submodule update --force' always check out submodules.
  2012-07-25 20:51   ` Jens Lehmann
@ 2012-07-25 22:09     ` Junio C Hamano
  2012-08-17  3:23     ` Junio C Hamano
  1 sibling, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2012-07-25 22:09 UTC (permalink / raw)
  To: Jens Lehmann; +Cc: Heiko Voigt, git, Stefan Zager

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Make 'git submodule update --force' always check out submodules.
  2012-07-25 20:51   ` Jens Lehmann
  2012-07-25 22:09     ` Junio C Hamano
@ 2012-08-17  3:23     ` Junio C Hamano
  1 sibling, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2012-08-17  3:23 UTC (permalink / raw)
  To: Stefan Zager; +Cc: Heiko Voigt, Jens Lehmann, git

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Make 'git submodule update --force' always check out submodules.
  2012-08-23  1:43 ` Junio C Hamano
@ 2012-08-23 18:51   ` Jens Lehmann
  0 siblings, 0 replies; 8+ messages in thread
From: Jens Lehmann @ 2012-08-23 18:51 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Stefan Zager, git

Am 23.08.2012 03:43, 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>
>> ---
> 
> Thanks for a reroll.  Will queue; looking good ;-)

Yup, nicely done!

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Make 'git submodule update --force' always check out submodules.
  2012-07-25 17:41 Stefan Zager
@ 2012-08-23  1:43 ` Junio C Hamano
  2012-08-23 18:51   ` Jens Lehmann
  0 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2012-08-23  1:43 UTC (permalink / raw)
  To: Stefan Zager; +Cc: git

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

Thanks for a reroll.  Will queue; looking good ;-)

>  Documentation/git-submodule.txt |  9 ++++++++-
>  git-submodule.sh                |  2 +-
>  t/t7406-submodule-update.sh     | 12 ++++++++++++
>  3 files changed, 21 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
> index fbbbcb2..2de7bf0 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 aac575e..3aa7644 100755
> --- a/git-submodule.sh
> +++ b/git-submodule.sh
> @@ -578,7 +578,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 ce61d4c..9706436 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] Make 'git submodule update --force' always check out submodules.
@ 2012-07-25 17:41 Stefan Zager
  2012-08-23  1:43 ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Zager @ 2012-07-25 17:41 UTC (permalink / raw)


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>
---
 Documentation/git-submodule.txt |  9 ++++++++-
 git-submodule.sh                |  2 +-
 t/t7406-submodule-update.sh     | 12 ++++++++++++
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
index fbbbcb2..2de7bf0 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 aac575e..3aa7644 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -578,7 +578,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 ce61d4c..9706436 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
-- 
1.7.12.2.gf3df7bf.dirty

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-08-23 18:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-25 18:03 [PATCH] Make 'git submodule update --force' always check out submodules Stefan Zager
2012-07-25 18:44 ` Junio C Hamano
2012-07-25 20:51   ` Jens Lehmann
2012-07-25 22:09     ` Junio C Hamano
2012-08-17  3:23     ` Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2012-07-25 17:41 Stefan Zager
2012-08-23  1:43 ` Junio C Hamano
2012-08-23 18:51   ` Jens Lehmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.