Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add magit-branch-manager-options #517

Closed
wants to merge 3 commits into from

4 participants

@tkf
tkf commented

This can be used for hiding merged branches in branch manger,
like Github does.

Example:

(setq magit-branch-manager-options '("--no-merged"))
@tkf tkf Add magit-branch-manager-options
This can be used for hiding merged branches in branch manger,
like Github does.
2a35ba5
@dudebout
Owner

Looks good. Two comments:

  • I do not think the reference to github should be in the comments since github might change over time and this would become confusing for people reading the code
  • we might want to call the property magit-branch-option since it is straight up an option for a git command
@tkf
tkf commented

I fixed the docstring. I am not sure about changing it to magit-branch-manager-option. You can set several options for git branch, like this:

(setq magit-branch-manager-options '("--no-merged" "master" "--abbrev=10"))

It is also constant with other variable such as magit-git-standard-options.

Yes, it seems that currently --no-merged is the only useful option. But there can be more useful options in the future.

@tkf
tkf commented

Ah, you mean to drop "manager-" part. I'll do it.

@dudebout
Owner

Exactly. It serves in the manager but there is nothing "manager" about it, it is straight up git branch

@tkf
tkf commented

Done!

@tkf

Thinking about this, it probably makes sense to add "manager-" to the variable, as it is not used for other branch operations such as creating and deleting.

@sigma
Owner

I have mixed feelings about this one. It seems to me that the set of options that would make sense (while not breaking the display ?) is probably fairly limited. Also, I'd think that filtering branches (like unmerged ones) would be more useful if was accessible dynamically. Shouldn't we try to extend the current branch manager menu with options ?

@tkf
tkf commented

Right, I agree that setting options dynamically is better. I will make a pull request later.

But it is better if I can set default option and toggle it dynamically. Is it possible to do that by magit UI in general (e.g., add "-a" option to log view by default)?

@tkf tkf closed this
@sigma
Owner

well, the way it's done currently (which is less than ideal in my opinion), is to store those dynamic options temporarily in magit-custom-options. See magit-key-mode.el for details.

@sigma
Owner

hmm, interestingly I didn't know about that mag-menu project. I guess I'll put in my todo-list to investigate whether we can just drop entirely that code from magit, and rely on that external package instead !

@dudebout
Owner

I have been considering making magit more modular lately. This would be an interesting approach in that direction. I also had in mind to separate the git interface in a way that could be used by other emacs utilities. And also separate the GUI part to increase consistency and code reuse.

@sigma
Owner

yep, at this point more modularity would be highly desirable.

@tkf
tkf commented

Pinging @chumpage about this discussion (in case you did not notice).

I really like the idea magit using mag-menu so that everyone can contribute to and get benefit from this great interface.

@dudebout
Owner

I would like to suggest merging these efforts under the magit organization.
I think the way https://github.com/yesodweb does it is really nice.
They have a main product, yesod, but they also have libraries.
The libraries came from developing yesod but now have a life on their own and are packaged independently.
They are all merged together with git submodules for the main product.

@chumpage

I'd be happy to bring the improvements I made in mag-menu back to a new version of magit-key-mode that's easily usable as a stand-alone library but still under the magit org. The approach dudebout describes with yesod would work, although I'm not sure separate repos are really necessary. At least with melpa you can have multiple packages in the same repo.

Obviously I'd also be fine if you wanted to have magit use mag-menu as a package dependency.

@sigma
Owner

yes I think it would be best to have magit depend on mag-menu directly, so that we can centralize efforts there (see for example recent fix in #514 which I personally dislike :( ). There's no reason why that particular piece of code should be tied to magit in the first place.
If you'd like to do that, I'd gladly accept a patch :)

@tkf tkf deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 5, 2012
  1. @tkf

    Add magit-branch-manager-options

    tkf authored
    This can be used for hiding merged branches in branch manger,
    like Github does.
Commits on Dec 6, 2012
  1. @tkf
  2. @tkf

    Rename to magit-branch-options

    tkf authored
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 4 deletions.
  1. +15 −4 magit.el
View
19 magit.el
@@ -222,6 +222,15 @@ Only considered when moving past the last entry with
:group 'magit
:type 'boolean)
+(defcustom magit-branch-options nil
+ "Options for \"git branch\" command used in `magit-branch-manager'.
+
+For example, to show only non-merged branches, use the following
+configuration:
+ (setq magit-branch-options '(\"--no-merged\"))"
+ :group 'magit
+ :type '(repeat string))
+
(defcustom magit-process-popup-time -1
"Popup the process buffer if a command takes longer than this many seconds."
:group 'magit
@@ -5801,10 +5810,12 @@ These are the branch names with the remote name stripped."
(defun magit-refresh-branch-manager ()
(magit-create-buffer-sections
- (magit-git-section "branches" nil 'magit-wash-branches
- "branch"
- "-vva"
- (format "--abbrev=%s" magit-sha1-abbrev-length))))
+ (apply #'magit-git-section
+ "branches" nil 'magit-wash-branches
+ "branch"
+ "-vva"
+ (format "--abbrev=%s" magit-sha1-abbrev-length)
+ magit-branch-options)))
(magit-define-command branch-manager ()
(interactive)
Something went wrong with that request. Please try again.