Commit f6d56031 authored by Jonas Bernoulli's avatar Jonas Bernoulli

magit-pull-or-fetch-popup: new popup

Combine `magit-pull-popup' and `magit-fetch-popup' into one common
popup.  By default the old popups are still bound in `magit-mode-map'.

Add this to your init file to use the new popup:

  (with-eval-after-load 'magit-remote
    (define-key magit-mode-map "f" 'magit-pull-and-fetch-popup)
    (define-key magit-mode-map "F" nil))

One advantage of the new popup is that it is once more possible to
press the same key twice to fetch.  However that binding now is "f f",
not "F F", and it fetches all remotes not just the current remote.

The new popup also lacks the commands for fetching from only a single
remote.  You can add them to the new popup by adding something like this
to your init file:

  (with-eval-after-load 'magit-remote
    (magit-define-popup-action 'magit-pull-and-fetch-popup ?U
      'magit-get-upstream-branch
      'magit-fetch-from-upstream-remote ?F)
    (magit-define-popup-action 'magit-pull-and-fetch-popup ?P
      'magit-get-push-branch
      'magit-fetch-from-push-remote ?F))
parent e2b333d2
......@@ -46,6 +46,10 @@ Changes since v2.3.0
Likewise many commands were renamed and their behavior was adjusted.
Some new commands, related to the push-remote, were added. #2414
* The popup command `magit-pull-and-fetch-popup' was added as a
possible replacement for the separate `magit-push-popup' and
`magit-fetch-popup'. #2452
* The status buffer now features up to four logs listing unpulled and
unpushed commits. Two for the upstream and two for the push-remote.
#2414
......
......@@ -3859,6 +3859,10 @@ Also see [[info:gitman#git-fetch]].
Fetch all submodules. With a prefix argument fetch all remotes of
all submodules.
Instead of using one popup for fetching and another for pulling, you
could also use ~magit-pull-and-fetch-popup~. See its doc-string for
more information.
** Pulling
Also see [[info:gitman#git-pull]].
......@@ -3880,6 +3884,10 @@ Also see [[info:gitman#git-pull]].
Pull from a branch read in the minibuffer.
Instead of using one popup for fetching and another for pulling, you
could also use ~magit-pull-and-fetch-popup~. See its doc-string for
more information.
** Pushing
Also see [[info:gitman#git-push]].
......
......@@ -5407,6 +5407,10 @@ Fetch all submodules. With a prefix argument fetch all remotes of
all submodules.
@end table
Instead of using one popup for fetching and another for pulling, you
could also use @code{magit-pull-and-fetch-popup}. See its doc-string for
more information.
@node Pulling
@section Pulling
......@@ -5451,6 +5455,10 @@ Pull from the upstream of the current branch.
Pull from a branch read in the minibuffer.
@end table
Instead of using one popup for fetching and another for pulling, you
could also use @code{magit-pull-and-fetch-popup}. See its doc-string for
more information.
@node Pushing
@section Pushing
......
......@@ -195,6 +195,22 @@ the variable isn't already set."
(run-hooks 'magit-credential-hook)
(magit-run-git-async-no-revert "remote" "update" args))
;;;###autoload
(defun magit-fetch-all-prune ()
"Fetch from all remotes, and prune.
Prune remote tracking branches for branches that have been
removed on the respective remote."
(interactive)
(run-hooks 'magit-credential-hook)
(magit-run-git-async-no-revert "remote" "update" "--prune"))
;;;###autoload
(defun magit-fetch-all-no-prune ()
"Fetch from all remotes."
(interactive)
(run-hooks 'magit-credential-hook)
(magit-run-git-async-no-revert "remote" "update"))
;;; Pull
;;;###autoload (autoload 'magit-pull-popup "magit-remote" nil t)
......@@ -202,7 +218,8 @@ the variable isn't already set."
"Popup console for pull commands."
'magit-commands
:man-page "git-pull"
:variables '((?r "branch.%s.rebase"
:variables '("Variables"
(?r "branch.%s.rebase"
magit-cycle-branch*rebase
magit-pull-format-branch*rebase))
:actions '((lambda ()
......@@ -218,6 +235,56 @@ the variable isn't already set."
:default-action 'magit-pull
:max-action-columns 1)
;;;###autoload (autoload 'magit-pull-and-fetch-popup "magit-remote" nil t)
(magit-define-popup magit-pull-and-fetch-popup
"Popup console for pull and fetch commands.
This popup is intended as a replacement for the separate popups
`magit-pull-popup' and `magit-fetch-popup'. To use it, add this
to you init file:
(with-eval-after-load 'magit-remote
(define-key magit-mode-map \"f\" 'magit-pull-and-fetch-popup)
(define-key magit-mode-map \"F\" nil))
The combined popup does not offer all commands and arguments
available from the individual popups. Instead of the argument
`--prune' and the command `magit-fetch-all' it uses two commands
`magit-fetch-prune' and `magit-fetch-no-prune'. And the commands
`magit-fetch-from-pushremote' and `magit-fetch-from-upstream' are
missing. To add them use something like:
(with-eval-after-load 'magit-remote
(magit-define-popup-action 'magit-pull-and-fetch-popup ?U
'magit-get-upstream-branch
'magit-fetch-from-upstream-remote ?F)
(magit-define-popup-action 'magit-pull-and-fetch-popup ?P
'magit-get-push-branch
'magit-fetch-from-push-remote ?F))"
'magit-commands
:man-page "git-pull"
:variables '("Pull variables"
(?r "branch.%s.rebase"
magit-cycle-branch*rebase
magit-pull-format-branch*rebase))
:actions '((lambda ()
(--if-let (magit-get-current-branch)
(concat
(propertize "Pull into " 'face 'magit-popup-heading)
(propertize it 'face 'magit-branch-local)
(propertize " from" 'face 'magit-popup-heading))
(propertize "Pull from" 'face 'magit-popup-heading)))
(?p magit-get-push-branch magit-pull-from-pushremote)
(?u magit-get-upstream-branch magit-pull-from-upstream)
(?e "elsewhere" magit-pull)
"Fetch from"
(?f "remotes" magit-fetch-all-no-prune)
(?F "remotes and prune" magit-fetch-all-prune)
"Fetch"
(?m "submodules" magit-submodule-fetch))
:default-action 'magit-fetch
:max-action-columns 1)
(defun magit-pull-format-branch*rebase ()
(magit-popup-format-variable (format "branch.%s.rebase"
(or (magit-get-current-branch) "<name>"))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment