10

I used to be able to press "o" then "u" (magit-submodule-update) in a magit buffer and have it update all my submodules. Now, it asks me to type in the path of which submodule I want to update. Is there a way to go back the the old behavior where all submodules were updated?

My submodules are somewhat buried in a directory structure, so having to type them in each time is annoying (not to mention, I have more than one).

I'm currently using Magit 20180220.1117, Git 2.15.1, Emacs 25.3.1, darwin

3 Answers 3

9

I got caught out by this as well when it changed. A couple of ideas:

  • As the documentation posted in another answer notes, you can use the universal argument (C-u) before a submodule operation to apply it to all.

  • You can add custom commands to the submodules popup which emulate the old behaviour. I use this:

(use-package magit
  :config

  (transient-define-suffix magit-submodule-update-all ()
    "Update all submodules"
    :description "Update All (git submodule update --init --recursive)"
    (interactive)
    (magit-with-toplevel
      (magit-run-git-async "submodule" "update" "--init" "--recursive")))

  (transient-append-suffix 'magit-submodule "u"
    '("U" magit-submodule-update-all))

  )

(This sample uses use-package.)

2022 EDIT: The Magit transient syntax changed subtly again, define-suffix-command is now the better named transient-define-suffix. So updated this once again and removed the old versions.

3
  • 1
    This is the real answer to the question. You should now press o C-u u to update all submodules with default magit configuration. Dec 6, 2018 at 13:38
  • One closing parenthesis is missing. (Edits need to be longer than 6 characters.) Feb 21, 2019 at 8:56
  • @Zelphir fixed, thanks
    – projectgus
    Feb 22, 2019 at 5:24
5

Often such questions can be answered simply by consulting the documentation. The section about the Submodule Popup contains this:

Some of the below commands default to act on the modules that are selected using the region. For brevity their description talk about "the selected modules", but if no modules are selected, then they act on the current module instead, or if point isn't on a module, then the read a single module to act on. With a prefix argument these commands ignore the selection and the current module and instead act on all suitable modules.


If you are unsure what "the modules that are selected using the region" means, then read about that in the manual. I would recommend you also read some of the close by nodes, maybe even read about all Interface Concepts.

By default Magit does not insert any module sections into the status buffer, but you can learn how to do that at Status Module Sections.

The buffer created by the command magit-submodule-list uses the mode tabulated-list-mode, which is an user interface abstraction different from the one Magit uses in most of its buffers. If you use the region to select multiple lines here, then Magit commands won't recognize that as a selection.


It is also easy to get documentation about an action (or argument) directly from the popup by pressing ? followed by the key(s) that would invoke the action (or argument) had you not pressed ? first.

Though in this case the doc-strings did not mention how these commands determine the module(s) to act on, which I have fixed now.

3
  • Where does one select a module (submodule?) with the region? A magit-submodule-list buffer would seem to be the place, but doesn't apparently have any key bindings for updating.
    – andy turk
    Feb 22, 2018 at 1:28
  • I have updated my answer to address these follow up questions.
    – tarsius
    Feb 22, 2018 at 2:14
  • 4
    Press o, then C-u u to update all submodules.
    – user30747
    Oct 23, 2018 at 18:34
3

The headline question was, "Why does magit now prompt for which submodule to update?"

The answer is simply that magit's default interface changed at some point. (I believe) magit used to automatically operate on all submodules, but now requires an explicit selection in the submodules status section or a path.

The second question was, "Is there a way to go back the the old behavior where all submodules were updated?"

Apparently not, but there is a workaround that gets close. To use it, it's important to ensure that submodule information is visible in magit's status buffer:

(magit-add-section-hook 'magit-status-sections-hook
                      'magit-insert-modules-overview
                      'magit-insert-unpulled-from-upstream)

Simply select all the submodules shown in the overview and then "o" "u" as before.

The magit documentation talks about "modules that are selected using the region," but unless module information is displayed, it can't be selected, much less seen. This was my confusion earlier--my magit configuration was not displaying any submodule information in the status buffer.

I discovered the missing hook in a magit issue discussion thread. Note that the original magit-insert-submodules mentioned in that discussion has changed to magit-insert-modules-overview as of version 2.11.0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.