All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Beller <sbeller@google.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Brandon Williams <bmwill@google.com>,
	Chris Packham <judge.packham@gmail.com>,
	Spencer Olson <olsonse@umich.edu>,
	"git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: [PATCH] submodule update: run custom update script for initial populating as well
Date: Fri, 13 Jan 2017 15:52:21 -0800	[thread overview]
Message-ID: <CAGZ79kYg=nJ8EqBEhoiWm2XRh3_3AuL7Qw-dCSKZqPO6CjFFwg@mail.gmail.com> (raw)
In-Reply-To: <xmqqfukmedca.fsf@gitster.mtv.corp.google.com>

On Fri, Jan 13, 2017 at 3:42 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Stefan Beller <sbeller@google.com> writes:
>
>> In 1b4735d9f3 (submodule: no [--merge|--rebase] when newly cloned,
>> 2011-02-17), all actions were defaulted to checkout for populating
>> a submodule initially, because merging or rebasing makes no sense
>> in that situation.
>>
>> Other commands however do make sense, such as the custom command
>> that was added later (6cb5728c43, submodule update: allow custom
>> command to update submodule working tree, 2013-07-03).
>
> Makes sense.
>
>> I am unsure about the "none" command, as I can see an initial
>> checkout there as a useful thing. On the other hand going strictly
>> by our own documentation, we should do nothing in case of "none"
>> as well, because the user asked for it.
>
> I think "none" is "I'll decide which revision of the submodule
> should be there---do not decide it for me".  If the user is
> explicitly saying with "git submodule init" to have "some" version,
> and if the user did not have any (because the user didn't show
> interest in any checkout of the submodule before), then I think it
> probably makes more sense to checkout the version bound to the
> superproject, than leaving the directory empty.
>
>> Reported-by: Han-Wen Nienhuys <hanwen@google.com>
>> Signed-off-by: Stefan Beller <sbeller@google.com>
>> ---
>>  git-submodule.sh            |  7 ++++++-
>>  t/t7406-submodule-update.sh | 15 +++++++++++++++
>>  2 files changed, 21 insertions(+), 1 deletion(-)
>>
>> diff --git a/git-submodule.sh b/git-submodule.sh
>> index 554bd1c494..aeb721ab7e 100755
>> --- a/git-submodule.sh
>> +++ b/git-submodule.sh
>> @@ -606,7 +606,12 @@ cmd_update()
>>               if test $just_cloned -eq 1
>>               then
>>                       subsha1=
>> -                     update_module=checkout
>> +                     if test "$update_module" = "merge" ||
>> +                        test "$update_module" = "rebase" ||
>> +                        test "$update_module" = "none"
>> +                     then
>> +                             update_module=checkout
>> +                     fi
>
> ... which seems to be what you did.  Do we need a documentation
> update, or does this just make the behaviour of this corner case
> consistent with what is already documented?

I think we do not need to update the documentation, because the
documentation doesn't call out the first/initial call to update to be special.
So for a non existing submodule we can do:

    git submodule update --init --[rebase|merge]

and that falls back to checkout, which *looks* like it was a rebase/merge.
The original bug report was that

    $ git config submodule.<name>.update !echo-script.sh
    $ git submodule update <submodule>
    Submodule path '<submodule>': 'echo-script.sh'
    $ rm -rf <submodule>
    $ git submodule update <submodule>
    .. checked out ..

So while I usually think more verbose documentation is a good idea,
this time it's different, as it merely aligns current documented
behavior with reality.

Thanks,
Stefan

  reply	other threads:[~2017-01-13 23:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-13 19:43 [PATCH] submodule update: run custom update script for initial populating as well Stefan Beller
2017-01-13 23:42 ` Junio C Hamano
2017-01-13 23:52   ` Stefan Beller [this message]
2017-01-13 23:58 ` Junio C Hamano
2017-01-14  0:00   ` Stefan Beller
2017-01-25 23:37     ` [PATCHv2] " Stefan Beller
2017-01-25 23:41       ` Brandon Williams
2017-01-25 23:48         ` [PATCHv3] " Stefan Beller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGZ79kYg=nJ8EqBEhoiWm2XRh3_3AuL7Qw-dCSKZqPO6CjFFwg@mail.gmail.com' \
    --to=sbeller@google.com \
    --cc=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=judge.packham@gmail.com \
    --cc=olsonse@umich.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.