From: Benjamin Schindler <beschindler@gmail.com>
To: Brandon Williams <bmwill@google.com>
Cc: git@vger.kernel.org, sbeller@google.com
Subject: Re: gitconfig get out of sync with submodule entries on branch switch
Date: Tue, 31 Jan 2017 08:46:09 +0100 [thread overview]
Message-ID: <b614a44a-fbc6-b5fe-ae40-ccf43dd9fcfb@gmail.com> (raw)
In-Reply-To: <20170130175118.GA35626@google.com>
Hi Brandon
I did try your suggestion, so basically:
git checkout branch
git submodule init
git submodule update
Unfortunately, I still have two entries in my git config this way. It
seems that git submodule update only considers submodules listed in
.gitmodules.
The background of my question is this - we have a jenkins farm which
needs to switch branches continuously in an automated fashion and this
needs to work even in when submodules are around. I did however, just
now, find a reliable way to switch a branch, keeping the gitconfig in sync:
The basic workflow for switching a branch is:
git submodule deinit .
git checkout branch
git submodule init
git submodule update
Because the .git folder of the submodules are not within the submodule
directories, this is, while still quite heavy-handed, reasonably fast
and robust. At least it is better than deleting the entire repository
every time a branch switch is issued.
Regards
Benjamin Schindler
On 30.01.2017 18:51, Brandon Williams wrote:
> On 01/30, Benjamin Schindler wrote:
>> Hi
>>
>> Consider the following usecase: I have the master branch where I
>> have a submodule A. I create a branch where I rename the submodule
>> to be in the directory B. After doing all of this, everything looks
>> good.
>> Now, I switch back to master. The first oddity is, that it fails to
>> remove the folder B because there are still files in there:
>>
>> bschindler@metis ~/Projects/submodule_test (testbranch) $ git
>> checkout master
>> warning: unable to rmdir other_submodule: Directory not empty
>> Switched to branch 'master'
>>
>> Git submodule deinit on B fails because the submodule is not known
>> to git anymore (after all, the folder B exists only in the other
>> branch). I can easily just remove the folder B from disk and
>> initialize the submodule A again, so all seems good.
>>
>> However, what is not good is that the submodule b is still known in
>> .git/config. This is in particular a problem for us, because I know
>> a number of tools which use git config to retrieve the submodule
>> list. Is it therefore a bug that upon branch switch, the submodule
>> gets deregistered, but its entry in .git/config remains?
>>
>> thanks a lot
>> Benjamin Schindler
>>
>> P.s. I did not subscribe to the mailing list, please add me at least
>> do CC. Thanks
> submodules and checkout don't really play nicely with each other at the
> moment. Stefan (cc'd) is currently working on a patch series to improve
> the behavior of checkout with submodules. Currently, if you want to
> ensure you have a good working state after a checkout you should run
> `git submodule update` to update all of the submoules. As far as your
> submodule still being listed in the config, that should be expected
> given the scenario you described.
>
> If I'm understanding you correctly, A and B are both the same submodule
> just renamed on a different branch. The moment you add a submoule to a
> repository it is given a name which is fixed. Typically this is the
> path from the root of the repository. The thing is, since you are able
> to freely move a submodule, its path can change. To account for this
> there is the .gitmodules file which allows you to do a lookup from
> submodule name to the path at which it exists (or vice versa). The
> submodules that are stored in .git/config are those which are
> 'initialize' or rather the submodules in which you are interested in and
> will be updated by `git submodule update`. So given your scenario you
> should only have a single submodule in .git/config and the .gitmodules
> file should have a single entry with a differing path for each branch.
>
> Hopefully this gives you a bit more information to work with. Since
> Stefan has been working with this more recently than me he may have some
> more input.
>
next prev parent reply other threads:[~2017-01-31 7:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-30 16:21 gitconfig get out of sync with submodule entries on branch switch Benjamin Schindler
2017-01-30 17:51 ` Brandon Williams
2017-01-31 7:46 ` Benjamin Schindler [this message]
2017-01-31 22:04 ` Stefan Beller
2017-02-06 10:35 ` Stefan Beller
2017-02-06 12:17 ` Benjamin Schindler
2017-02-08 19:07 ` 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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b614a44a-fbc6-b5fe-ae40-ccf43dd9fcfb@gmail.com \
--to=beschindler@gmail.com \
--cc=bmwill@google.com \
--cc=git@vger.kernel.org \
--cc=sbeller@google.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).