Re: [RFC PATCH 09/10] submodule: support reading .gitmodules even when it's not checked out
- From
Stefan Beller <sbeller@google.com>
- Date
- May 15, 2018, 01:45 UTC
- Message-ID
- <CAGZ79kYP_ensQR6caaxCwabvcLDdvJNLu2C8DT-jzy+oP7BpJw@mail.gmail.com>
- In-Reply-To
- <20180514105823.8378-10-ao2@ao2.it>
On Mon, May 14, 2018 at 3:58 AM, Antonio Ospite <ao2@ao2.it> wrote:
> When the .gitmodules file is not available in the working directory, try > using HEAD:.gitmodules from the index.
I think HEAD:.gitmodules is different than the index (the former is part of the latest commit, whereas the index could have changed via git-add, that is not committed yet).
Show 7 quoted lines
> This covers the case when the > file is part of the repository but for some reason it is not checked > out, for example because of a sparse checkout. > > This makes it possible to use at least the 'git submodule' commands > which *read* the gitmodules configuration file without fully populating > the work dir.
Instead of checking for an explicit sparse "hidden" could we just rely on the file missing? Then I could continue using submodules if I just "rm .gitmodules".
> > Writing to .gitmodules wills still require that the file is checked out, > so check for that in config_gitmodules_set.
That makes sense!
Show 6 quoted lines
> > Signed-off-by: Antonio Ospite <ao2@ao2.it> > --- > > I am doing the is_gitmodules_hidden() check in the open for now, I am not sure > whether it is approprate to do that inside stage_updated_gitmodules.
Why do we need that check at all?
In your use case, you want to checkout *a* .gitmodules file, not necessarily the .gitmodules file of that repo you're currently working on. So it sort of makes sense to prevent cross-repo changes (i.e. committing the .gitmodules accidentally into the wrong repo)
Stefan