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

Re: Why does 'submodule add' stage the relevant portions?

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Mar 25, 2013, 08:59 UTC
Message-ID
<CALkWK0kJ2QVA6is85Sdwn1mnGVbuNUSGqg_37WBxPYrepHz9ow@mail.gmail.com>
In-Reply-To
<51500C67.9040308@web.de>
Jens Lehmann wrote:
Show 12 quoted lines
> Am 24.03.2013 18:38, schrieb Ramkumar Ramachandra:
>> I find this behavior very inconsistent and annoying.  Why would I want
>> to commit the submodule change immediately?  Maybe I want to batch it
>> up with other changes and stage it at a later time.  Why should I have
>> to unstage them manually now?  I get the other side of the argument:
>> what if the user commits the .gitmodule change at a different time
>> from the file change?  In other words, the user should have a way of
>> saying 'submodule stage' and 'submodule unstage'.
>
> Hmm, AFAIK you are the first to bring up such a feature, as in most
> use cases doing a "git (submodule) add <path>" is expected to stage
> what you added.

In my opinion, the 'git submodule add <path>' form is broken, because it doesn't relocate the object store of the submodule repository (a bug that we need to fix?). I always use the 'git submodule add <repository> <path>' form, which puts the object store of the submodule repository in .git/modules of the parent repository. This form is nothing like 'git add', but more like a 'git clone': arguably, 'submodule clone' is a better name for it.

> Maybe you could teach the stage/unstage code to also
> stage/unstage the corresponding part of the .gitmodules file, but
> I'm not sure it is worth the hassle.

Maybe not. I'm still not an heavy user of submodules; I notice many breakages and inconsistencies, but I'm not sure what to fix first, and how to go about fixing it. I'm yet to look at git-subtree and draw inspiration from its design.

Maybe the WTF "You need to run this command from the toplevel of the working tree" needs to be fixed first? I think it's a matter of a simple pushd, popd before the operation and building the correct relative path. I'm not sure how it'll work with nested submodules though. Then again, I think nested submodules are Wrong; submodules are probably not the right tool for the job.

Show 8 quoted lines
>> Now, for the implementation.  Do we have existing infrastructure to
>> stage a hunk non-interactively?  (The ability to select a hunk to
>> stage/ unstage programmatically).  If not, it might be quite a
>> non-trivial thing to write.
>
> Have fun when adding two submodules and unstage only one of them
> later. I think this feature will not work unless you analyze
> .gitmodules and stage/unstage section-wise.

Yes, which is why I asked if we have existing infrastructure to make this possible.

Previous: Jens LehmannNext: Jens Lehmann
Message 3 of 18 in “Why does 'submodule add' stage the relevant portions?”
  1. Ramkumar RamachandraMar 24, 2013
  2. Jens LehmannMar 25, 2013
  3. Ramkumar RamachandraMar 25, 2013
  4. Jens LehmannMar 25, 2013
  5. Ramkumar RamachandraMar 25, 2013
  6. Jens LehmannMar 25, 2013
  7. Ramkumar RamachandraMar 26, 2013
  8. Jens LehmannMar 26, 2013
  9. Junio C HamanoMar 25, 2013
  10. Ramkumar RamachandraMar 25, 2013
  11. Jonathan NiederMar 25, 2013
  12. Ramkumar RamachandraMar 25, 2013
  13. Junio C HamanoMar 25, 2013
  14. Ramkumar RamachandraMar 25, 2013
  15. Jonathan NiederMar 25, 2013
  16. Ramkumar RamachandraMar 25, 2013
  17. Jonathan NiederMar 25, 2013
  18. Duy NguyenMar 26, 2013

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.