Re: [PATCH v3 7/7] submodule: support reading .gitmodules even when it's not checked out
- From
Antonio Ospite <ao2@ao2.it>
- Date
- Aug 23, 2018, 11:48 UTC
- Message-ID
- <20180823134824.db90021628baef8c6706fa38@ao2.it>
- In-Reply-To
- <xmqqd0ua773e.fsf@gitster-ct.c.googlers.com>
On Wed, 22 Aug 2018 08:29:25 -0700 Junio C Hamano <gitster@pobox.com> wrote:
> Antonio Ospite <ao2@ao2.it> writes: >
[...]
Show 10 quoted lines
> >> > > + else if (get_oid(GITMODULES_HEAD, &oid) >= 0) > >> > > + config_source.blob = GITMODULES_HEAD; > >> > > >> Would using ":.gitmodules" instead of "HEAD:.gitmodules" be enough? > > Yeah, either "instead of", or "in addition" (i.e. "try the index > version in addition, before falling further back to the HEAD > version"), would be more consistent with the remainder of the system > (or, at least where the remainder of the system wants to go). >
OK, I now tested with both "rm .gitmodules" and "git rm .gitmodules" and I see why one would want to try _both_ ":.gitmodules" and "HEAD:.gitmodules".
I'll go with "in addition" then, adding tests for both the scenarios.
Show 9 quoted lines
> >> If so, what name should I use instead of GITMODULES_HEAD? > >> GITMODULES_BLOB is already taken for something different, maybe > >> GITMODULES_REF or GITMODULES_OBJECT? > > I do not know why you want to refrain from spelling them out as > "HEAD:.gitmodules" and ":.gitmodules"; at least to me the extra > layer of names do not look like they are making the code easier > to understand that much. >
This is in the spirit of commit 4c0eeafe47 (cache.h: add GITMODULES_FILE macro, 2017-08-02), IIRC this was done mainly to get help from the preprocessor to spot typos: I caught myself writing ".gitmdoules" several times; GITMDOULES_FILE would not compile.
If this makes sense I'll use GITMODULES_INDEX and GITMODULES_HEAD.
Thanks, Antonio
-- Antonio Ospite https://ao2.it https://twitter.com/ao2it A: Because it messes up the order in which people normally read text. See http://en.wikipedia.org/wiki/Posting_style Q: Why is top-posting such a bad thing?