git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [wishlist?] make submodule commands robust to having non-submodule Subprojects

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 16, 2016, 18:28 UTC
Message-ID
<xmqqwpibk8bg.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20160916141143.GA47240@book.hvoigt.net>
Heiko Voigt <hvoigt@hvoigt.net> writes:
Show 18 quoted lines
> On Thu, Sep 15, 2016 at 11:27:54AM -0700, Junio C Hamano wrote:
>
>> If the trend in Git community collectively these days is to make
>> usage of submodules easier and smoother, I'd imagine that you would
>> want to teach "git add" that was given a submodule to "git submodule
>> add" instead by default, with an option "git add --no-gitmodules
>> sub" to disable it, or something like that.
>> 
>> >          $ git submodule add --fixup-modules-file ./sub sub
>> >          Adding .gitmodule entry only for `sub` to use `git -C remote
>> > show origin` as URL.
>> 
>> I agree that a feature like this is needed regardless of what
>> happens at "git add" time.
>
> How about just
>
>    git submodule add <submodulepath>

When I said "a feature like this is needed", I didn't care about exact syntax. I am not sure how often people need the "fixup", what kind of causes there are that they need the "fixup", and what the distribution of vaious causes would be like. If the _ONLY_ kind of fixup necessary is "I meant to say 'git submodule add ./path path' but I said 'git add path' instead", then I think it makes sense to teach "submodule add" that the form "git submodule add <path>" is a short-pand for "git submodule add ./<path> <path>". I am not sure if we want to _ignore_ a gitlink that is already in the index unconditionally, i.e. if it is a good idea to let the second one override the first one

	git submodule add $URL sub &&
        git submodule add sub
in this sequence, though.
Show 15 quoted lines
> ? I remember back in the days when I started with submodules thats the
> way I imagined submodules would work:
>
> 1. clone the submodule into a directory
> 2. git submodule add it
> 3. git commit everything
>
> Because that how you basically work with files.  So instead of adding
> another option I would rather like to autodetect that:
>
>  * its a relative path inside this repo that is passed to
>    'git submodule add'
>  * there is no .gitmodules entry
>  * and no .git/config
> ==> create those from a remote in the submodule

In other words, I agree with the general direction but I'd add another condition to the above three, i.e.

   * and there is no gitlink for that path in the index yet.
Previous: Jacob Keller
Message 13 of 13 in “[wishlist?] make submodule commands robust to having non-submodule Subprojects”
  1. Yaroslav HalchenkoSep 15, 2016
  2. Stefan BellerSep 15, 2016
  3. Yaroslav HalchenkoSep 15, 2016
  4. Stefan BellerSep 15, 2016
  5. Junio C HamanoSep 15, 2016
  6. Yaroslav HalchenkoSep 15, 2016
  7. Stefan BellerSep 15, 2016
  8. Junio C HamanoSep 15, 2016
  9. Stefan BellerSep 15, 2016
  10. Junio C HamanoSep 15, 2016
  11. Heiko VoigtSep 16, 2016
  12. Jacob KellerSep 16, 2016
  13. Junio C HamanoSep 16, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.