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

Re: [PATCH] Add git-submodule command

From
LHLars Hjemli <hjemli@gmail.com>
Date
May 25, 2007, 20:29 UTC
Message-ID
<8c5c35580705251329u33ac1462m9db35cac0c37e3a9@mail.gmail.com>
In-Reply-To
<7vodk8r97s.fsf@assigned-by-dhcp.cox.net>
On 5/25/07, Junio C Hamano <junkio@cox.net> wrote:
Show 19 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
> > On Fri, 25 May 2007, Lars Hjemli wrote:
> >
> >> Btw: testing this quickly becomes tedious, so I'll try to make a proper
> >> testscript later tonight.
> >
> > Very good.
> >
> >> +'git-submodule' [--init | --update | --cached] [--quiet] [--] [<path>...]
> >
> > I did not realize this earlier, but we seem to have more and more programs
> > where actions are specified without "--", i.e. "git-svn fetch", or
> > "git-bundle create".
> >
> > I actually like that, to separate actions from options. Hmm?
>
> I think it is a sensible thing to do for this kind of "wrapper
> of different functionalities related to one area".

Ok, there seems to be general agreement on this, so how about something like this instead:

  git-submodule [--quiet] [--cached] [init | update] [--] [<path>...]
or would you rather have
  git-submodule [--quiet] [--cached] <cmd> [<path>...]
with cmd being one of init, update, status?
Show 21 quoted lines
> >> +FILES
> >> +-----
> >> +When cloning submodules, a .gitmodules file in the top-level directory
> >> +of the containing work-tree is examined for the url of each submodule.
> >> +The url is the value of the key module.$path.url.
> >
> > IIRC Junio talked about a name for overriding. But I think it would be
> > even better to to override by mapping the URLs from .gitmodules to the
> > locally-wanted URLs.
> >
> > Junio?
>
> I really do not want that (mis)conception that .gitmodules
> specify the default and .git/config the override.  I really
> think we should use the .git/config as _the_ only authority to
> get URL, but keyed with the three-level scheme, with URL in
> .gitmodules used _solely_ as a hint when setting up the URL in
> the .git/config file.
>
>         cf. $gmane/47502, 47548, 47621
>

I've read these articles, but I think much of the concerns about trusting the url supplied by upstream goes away when the submodule clone/checkout isn't an integrated part of the superproject clone/checkout. Besides, if you trust your upstream enough to clone their repository (the superproject), why wouldn't you trust the data (.gitmodules) in that very repository?

Still, a way to locally override the suggested url is probably needed.
 This can be easily achieved by either yours or Linus' suggestion
about 'url rewriting'. And if clone/checkout doesn't touch the
submodules at all, the downstream user can look at/override the
.gitmodules file in his local tree before deciding to do the submodule
 clone or checkout. I don't think there is any need for an interactive
tool here.

Another possibility is simply doing the submodule clone/checkout by hand (i.e. do 'git clone preferred-url path', don't do 'git submodule init path').

Show 14 quoted lines
> >> +When updating submodules, the same .gitmodules file is examined for a key
> >> +named 'module.$path.branch'. If found, and if the named branch is currently
> >> +at the same revision as the commit-id in the containing repositories index,
> >> +the specified branch will be checked out in the submodule. If not found, or
> >> +if the branch isn't currently positioned at the wanted revision, a checkout
> >> +of the wanted sha1 will happen in the submodule, leaving its HEAD detached.
> >
> > A very good description, and I think this is the only method to checkout
> > the submodule which makes sense. (Just maybe default the value of
> > module.<path>.branch to "master"?)
>
> I suspect leaving the HEAD always detached if the superproject
> tree names a concrete commit object name would be less confusing
> and consistent.
And easier to explain :)
Show 5 quoted lines
>When the name of the commit object in the
> superproject tree and/or index is 0{40}, it would be a good
> extension to use "whatever commit that happens to be at the tip
> of this branch" taken from the .gitmodules file.
>

I really can't imagine what kind of superproject would have such a setup. Why would this be needed?

-- 
larsh
Previous: Junio C HamanoNext: Junio C Hamano
Message 12 of 26 in “Add git-submodule command”
  1. Add git-submodule commandLars Hjemli, May 25, 2007
  2. Johannes SchindelinMay 25, 2007
  3. Johannes SchindelinMay 25, 2007
  4. Lars HjemliMay 25, 2007
  5. Johannes SchindelinMay 25, 2007
  6. Lars HjemliMay 25, 2007
  7. Johannes SchindelinMay 25, 2007
  8. Lars HjemliMay 25, 2007
  9. Add git-submodule commandLars Hjemli, May 25, 2007
  10. Johannes SchindelinMay 25, 2007
  11. Junio C HamanoMay 25, 2007
  12. Lars HjemliMay 25, 2007
  13. Junio C HamanoMay 25, 2007
  14. Lars HjemliMay 25, 2007
  15. Add git-submodule commandLars Hjemli, May 26, 2007
  16. Johannes SchindelinMay 26, 2007
  17. Junio C HamanoMay 26, 2007
  18. Lars HjemliMay 26, 2007
  19. Johannes SchindelinMay 26, 2007
  20. Add git-submodule commandLars Hjemli, May 26, 2007
  21. Simon HausmannMay 26, 2007
  22. Lars HjemliMay 26, 2007
  23. Johannes SchindelinMay 25, 2007
  24. Linus TorvaldsMay 25, 2007
  25. Johannes SchindelinMay 25, 2007
  26. Lars HjemliMay 25, 2007

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.