From: "Michael S. Tsirkin" <mst@redhat.com>
To: Glen Choo <chooglen@google.com>
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
git@vger.kernel.org
Subject: Re: sudmodule.<name>.recurse ignored
Date: Wed, 12 Oct 2022 17:49:18 -0400 [thread overview]
Message-ID: <20221012174742-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <kl6lfsft0ylu.fsf@chooglen-macbookpro.roam.corp.google.com>
On Wed, Oct 12, 2022 at 09:56:45AM -0700, Glen Choo wrote:
> "Michael S. Tsirkin" <mst@redhat.com> writes:
>
> > Fundamentally the problem we encounter regularly is this:
> > qemu is superproject, ui/keycodemapdb is subproject.
> >
> >
> > I have a change on master setting the submodule commit:
> >
> > qemu$ git show master | grep +Sub
> > +Subproject commit 7381b9bfadd31c4c9e9a10b5bb5032f9189d4352
> >
> > and check it out:
> >
> > qemu$ git submodule update --init ui/keycodemapdb
> > Submodule 'ui/keycodemapdb' (https://gitlab.com/qemu-project/keycodemapdb.git) registered for path 'ui/keycodemapdb'
> > Submodule path 'ui/keycodemapdb': checked out '7381b9bfadd31c4c9e9a10b5bb5032f9189d4352'
> >
> >
> > In another branch I have a different commit:
> >
> > qemu$ git show sub-foo | grep +Sub
> > +Subproject commit 57ba70da5312170883a3d622cd2aa3fd0e2ec7ae
> >
> >
> > Now I switch branches and nothing happens, the submodule
> > is marked as dirty:
> >
> > qemu$ git checkout sub-foo
> > M ui/keycodemapdb
> > Switched to branch 'sub-foo'
> >
> > qemu$ (cd ui/keycodemapdb && git show | head -1)
> > commit 7381b9bfadd31c4c9e9a10b5bb5032f9189d4352
> >
> >
> > it is now very easy to generate incorrect code:
> > - git commit -a will commit the change to submodule
> > - any build will use a mix of super and subproject that
> > is completely untested
> >
> >
> > As a result people are basically saying avoid using submodules
> > but I am wondering whether git can be tweaked to do the
> > right thing by default.
> >
>
> It sounds like you want submodule.recurse [1] :)
yes. unfortuntely there is no way to set it by default
for cloned repos. users have to remember to set it.
> With that enabled, your
> "git checkout" should behave like "git checkout --recurse-submodules",
> which should make ui/keycodemapdb check out the correct commit as long
> as the submodule commit is present locally. If is is _not_ present
> locally, you will have to run "git submodule update".
>
> Unfortunately, you typically won't know whether the commit is present
> before running the command. This is yet another of those things that are
> painful with submodules.
>
> [1] https://git-scm.com/docs/git-config#Documentation/git-config.txt-submodulerecurse
>
> > I understand we can work around it by asking everyone to
> > create a correct config, but can't we make it DTRT by default
> > to reduce friction?
>
> You might be interested in the proposed 'new' Submodule UX [2]; one of
> the goals is to make manual submodule management via "git submodule"
> unnecessary.
>
> As a part of that, you should be able to set "submodule.recurse = true"
> and have high confidence that all necessary submodules and submodule
> commits are present.
Hmm. How about only doing this for active submodules? Possible?
> Work on that is still ongoing, but this situation
> should have improved as of [3].
>
> [2] https://lore.kernel.org/git/YHofmWcIAidkvJiD@google.com/
> [3] https://lore.kernel.org/git/20220308001433.94995-1-chooglen@google.com/
>
> >
> >
> > --
> > MST
prev parent reply other threads:[~2022-10-12 21:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-07 10:10 sudmodule.<name>.recurse ignored Michael S. Tsirkin
2022-10-07 11:09 ` Ævar Arnfjörð Bjarmason
2022-10-07 12:56 ` Michael S. Tsirkin
2022-10-07 21:04 ` Glen Choo
2022-10-07 21:13 ` Junio C Hamano
2022-10-11 22:34 ` Michael S. Tsirkin
2022-10-12 16:56 ` Glen Choo
2022-10-12 21:49 ` Michael S. Tsirkin [this message]
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=20221012174742-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=avarab@gmail.com \
--cc=chooglen@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).