{"thread":{"id":"31326","subject":"[PATCH] Make 'git submodule update --force' always check out submodules.","startedAt":"2012-07-25T17:41:54Z","lastAt":"2012-08-23T18:51:52Z","messageCount":3,"participants":["Stefan Zager","Junio C Hamano","Jens Lehmann"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"197670","messageId":"20120822233610.710C01C2DAF@stefro.sfo.corp.google.com","threadId":"31326","inReplyTo":null,"subject":"[PATCH] Make 'git submodule update --force' always check out submodules.","fromName":"Stefan Zager","fromEmail":"szager@google.com","sentAt":"2012-07-25T17:41:54Z","receivedAt":"2012-07-25T17:41:54Z","isPatch":true,"sender":{"key":"szager@google.com","avatar":null},"body":"Currently, it will only do a checkout if the sha1 registered in the containing\nrepository doesn't match the HEAD of the submodule, regardless of whether the\nsubmodule is dirty.  As discussed on the mailing list, the '--force' flag is a\nstrong indicator that the state of the submodule is suspect, and should be reset\nto HEAD.\n\nSigned-off-by: Stefan Zager <szager@google.com>\n---\n Documentation/git-submodule.txt |  9 ++++++++-\n git-submodule.sh                |  2 +-\n t/t7406-submodule-update.sh     | 12 ++++++++++++\n 3 files changed, 21 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\nindex fbbbcb2..2de7bf0 100644\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -149,6 +149,11 @@ submodule with the `--init` option.\n +\n If `--recursive` is specified, this command will recurse into the\n registered submodules, and update any nested submodules within.\n++\n+If `--force` is specified, the submodule will be checked out (using\n+`git checkout --force` if appropriate), even if the commit specified in the\n+index of the containing repository already matches the commit checked out in\n+the submodule.\n \n summary::\n \tShow commit summary between the given commit (defaults to HEAD) and\n@@ -210,7 +215,9 @@ OPTIONS\n \tThis option is only valid for add and update commands.\n \tWhen running add, allow adding an otherwise ignored submodule path.\n \tWhen running update, throw away local changes in submodules when\n-\tswitching to a different commit.\n+\tswitching to a different commit; and always run a checkout operation\n+\tin the submodule, even if the commit listed in the index of the\n+\tcontaining repository matches the commit checked out in the submodule.\n \n --cached::\n \tThis option is only valid for status and summary commands.  These\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex aac575e..3aa7644 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -578,7 +578,7 @@ Maybe you want to use 'update --init'?\")\"\n \t\t\tdie \"$(eval_gettext \"Unable to find current revision in submodule path '\\$sm_path'\")\"\n \t\tfi\n \n-\t\tif test \"$subsha1\" != \"$sha1\"\n+\t\tif test \"$subsha1\" != \"$sha1\" -o -n \"$force\"\n \t\tthen\n \t\t\tsubforce=$force\n \t\t\t# If we don't already have a -f flag and the submodule has never been checked out\ndiff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh\nindex ce61d4c..9706436 100755\n--- a/t/t7406-submodule-update.sh\n+++ b/t/t7406-submodule-update.sh\n@@ -123,6 +123,18 @@ test_expect_success 'submodule update should throw away changes with --force ' '\n \t)\n '\n \n+test_expect_success 'submodule update --force forcibly checks out submodules' '\n+\t(cd super &&\n+\t (cd submodule &&\n+\t  rm -f file\n+\t ) &&\n+\t git submodule update --force submodule &&\n+\t (cd submodule &&\n+\t  test \"$(git status -s file)\" = \"\"\n+\t )\n+\t)\n+'\n+\n test_expect_success 'submodule update --rebase staying on master' '\n \t(cd super/submodule &&\n \t  git checkout master\n-- \n1.7.12.2.gf3df7bf.dirty\n"},{"id":"197672","messageId":"7v8vd65qob.fsf@alter.siamese.dyndns.org","threadId":"31326","inReplyTo":"20120822233610.710C01C2DAF@stefro.sfo.corp.google.com","subject":"Re: [PATCH] Make 'git submodule update --force' always check out submodules.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-23T01:43:16Z","receivedAt":"2012-08-23T01:43:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Zager <szager@google.com> writes:\n\n> Currently, it will only do a checkout if the sha1 registered in the containing\n> repository doesn't match the HEAD of the submodule, regardless of whether the\n> submodule is dirty.  As discussed on the mailing list, the '--force' flag is a\n> strong indicator that the state of the submodule is suspect, and should be reset\n> to HEAD.\n>\n> Signed-off-by: Stefan Zager <szager@google.com>\n> ---\n\nThanks for a reroll.  Will queue; looking good ;-)\n\n>  Documentation/git-submodule.txt |  9 ++++++++-\n>  git-submodule.sh                |  2 +-\n>  t/t7406-submodule-update.sh     | 12 ++++++++++++\n>  3 files changed, 21 insertions(+), 2 deletions(-)\n>\n> diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\n> index fbbbcb2..2de7bf0 100644\n> --- a/Documentation/git-submodule.txt\n> +++ b/Documentation/git-submodule.txt\n> @@ -149,6 +149,11 @@ submodule with the `--init` option.\n>  +\n>  If `--recursive` is specified, this command will recurse into the\n>  registered submodules, and update any nested submodules within.\n> ++\n> +If `--force` is specified, the submodule will be checked out (using\n> +`git checkout --force` if appropriate), even if the commit specified in the\n> +index of the containing repository already matches the commit checked out in\n> +the submodule.\n>  \n>  summary::\n>  \tShow commit summary between the given commit (defaults to HEAD) and\n> @@ -210,7 +215,9 @@ OPTIONS\n>  \tThis option is only valid for add and update commands.\n>  \tWhen running add, allow adding an otherwise ignored submodule path.\n>  \tWhen running update, throw away local changes in submodules when\n> -\tswitching to a different commit.\n> +\tswitching to a different commit; and always run a checkout operation\n> +\tin the submodule, even if the commit listed in the index of the\n> +\tcontaining repository matches the commit checked out in the submodule.\n>  \n>  --cached::\n>  \tThis option is only valid for status and summary commands.  These\n> diff --git a/git-submodule.sh b/git-submodule.sh\n> index aac575e..3aa7644 100755\n> --- a/git-submodule.sh\n> +++ b/git-submodule.sh\n> @@ -578,7 +578,7 @@ Maybe you want to use 'update --init'?\")\"\n>  \t\t\tdie \"$(eval_gettext \"Unable to find current revision in submodule path '\\$sm_path'\")\"\n>  \t\tfi\n>  \n> -\t\tif test \"$subsha1\" != \"$sha1\"\n> +\t\tif test \"$subsha1\" != \"$sha1\" -o -n \"$force\"\n>  \t\tthen\n>  \t\t\tsubforce=$force\n>  \t\t\t# If we don't already have a -f flag and the submodule has never been checked out\n> diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh\n> index ce61d4c..9706436 100755\n> --- a/t/t7406-submodule-update.sh\n> +++ b/t/t7406-submodule-update.sh\n> @@ -123,6 +123,18 @@ test_expect_success 'submodule update should throw away changes with --force ' '\n>  \t)\n>  '\n>  \n> +test_expect_success 'submodule update --force forcibly checks out submodules' '\n> +\t(cd super &&\n> +\t (cd submodule &&\n> +\t  rm -f file\n> +\t ) &&\n> +\t git submodule update --force submodule &&\n> +\t (cd submodule &&\n> +\t  test \"$(git status -s file)\" = \"\"\n> +\t )\n> +\t)\n> +'\n> +\n>  test_expect_success 'submodule update --rebase staying on master' '\n>  \t(cd super/submodule &&\n>  \t  git checkout master\n"},{"id":"197728","messageId":"50367BC8.3090902@web.de","threadId":"31326","inReplyTo":"7v8vd65qob.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Make 'git submodule update --force' always check out submodules.","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2012-08-23T18:51:52Z","receivedAt":"2012-08-23T18:51:52Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 23.08.2012 03:43, schrieb Junio C Hamano:\n> Stefan Zager <szager@google.com> writes:\n> \n>> Currently, it will only do a checkout if the sha1 registered in the containing\n>> repository doesn't match the HEAD of the submodule, regardless of whether the\n>> submodule is dirty.  As discussed on the mailing list, the '--force' flag is a\n>> strong indicator that the state of the submodule is suspect, and should be reset\n>> to HEAD.\n>>\n>> Signed-off-by: Stefan Zager <szager@google.com>\n>> ---\n> \n> Thanks for a reroll.  Will queue; looking good ;-)\n\nYup, nicely done!\n"}]}