2

I have set magit-repositories-directorylike this

  (setq magit-repository-directories `("~/go/src/github.com/cescoferraro", user-emacs-directory))

Then I can M-x magit-list-repositories RET and I get a nice list containing all git projects inside that folder.

Issue 1

I get Name, Version, L < U, U > L and Path columns. But what does L < U, U > L mean? I get 0 values for only random repos. I could not figure out what it means. Ideally I want to know if there is something modified that need to push and if there is something at origin that need to be pulled.

Issue 2

I want to use this as a sync tool. So I want to be able to push/pull and open magit-status for each project as I browse to the list

8

Issue 1

  • L<U is calculated by the function magit-repolist-column-unpulled-from-upstream, which inserts the number of upstream commits not in the current branch.
  • L>U is calculated by the function magit-repolist-column-unpushed-to-upstream, which inserts the number of commits in the current branch but not its upstream.

In other words, a nonzero value in either column means the local branch and its upstream are out of sync. You can sort the *Magit Repositories* buffer (and other tabulated lists in Emacs) by placing point in the desired column and invoking M-x tabulated-list-sort (default key binding S). Alternatively, you can call this command with a numeric prefix N in order to sort the Nth column.

You can customise the name, width, contents and alignment of the columns displayed in *Magit Repositories* via the variable magit-repolist-columns, which see. For example, to add a column in the third position indicating uncommitted changes (see comments below), you could do:

(setq magit-repolist-columns
      '(("Name"    25 magit-repolist-column-ident                  ())
        ("Version" 25 magit-repolist-column-version                ())
        ("D"        1 magit-repolist-column-dirty                  ())
        ("L<U"      3 magit-repolist-column-unpulled-from-upstream ((:right-align t)))
        ("L>U"      3 magit-repolist-column-unpushed-to-upstream   ((:right-align t)))
        ("Path"    99 magit-repolist-column-path                   ()))

You could achieve the same thing without having to redefine the whole list like so:

(with-eval-after-load 'magit
  (setcdr (cdr magit-repolist-columns)
          (cons '("D" 1 magit-repolist-column-dirty ())
                (cddr magit-repolist-columns))))

Of course, you could also skip having to write this elisp yourself and just use the customisation interface (M-x customize-group RET magit-repolist RET), but where's the fun in that? :)

Issue 2

You can open magit-status for each repository listed in *Magit Repositories* by typing M-x magit-repolist-status (default binding C-m or RET) on the corresponding line. Batch operations like pulling are not yet implemented; see https://github.com/magit/magit/issues/2971. In the meantime you could hack mapping something like magit-pull-from-pushremote over all entries in the list.

Issue 3

Note that populating the customisable variable magit-repository-directories with strings instead of (DIRECTORY . DEPTH) cons cells is only supported for backward compatibility, and the fallback variable magit-repository-directories-depth is obsolete. I recommend you restructure your setting as:

(setq magit-repository-directories
      `(("~/go/src/github.com/cescoferraro" . DEPTH1)
        (,user-emacs-directory              . DEPTH2)))

where DEPTH1 and DEPTH2 are the respective maximum depths to look for Git repositories, as documented by the variable magit-repository-directories.

  • 1
    To clarify: I am pretty sure that L and U stand for Local and Upstream, which may help clarify their meaning. If you find this confuses you, just customise magit-repolist-columns. – Basil May 9 '17 at 22:22
  • See relevant Magit feature request – Basil May 9 '17 at 22:33
  • 1
    You may also be interested in this useful feature. – Basil May 9 '17 at 22:35
  • You are a legend. But my setup is broken, Thats the whole cause of the issues. Neither C-m nor RET fire magit-repolist-status. I using evil and evil-magit. Is there a magit-repolist-hook I can set this manually? Concerning the issue 3, I figure DEPTH = 1 is ok if I do not use submodules right? – CESCO May 10 '17 at 12:16
  • 1
    @CESCO Yes, just look at the variable's documentation (C-h v magit-repolist-columns). The second element of each element of magit-repolist-columns represents a column width. – Basil May 11 '17 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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