Commit e95550cd authored by Jonas Bernoulli's avatar Jonas Bernoulli

magit--set-popup-variable: new function

This function used to be part of Magit-Popup
under the name `magit-popup-set-variable'.
parent a8a247c7
......@@ -741,9 +741,9 @@ When that variable is undefined then the value of `pull.rebase'
is used instead. It defaults to `false'."
(interactive (list (magit-branch-config-branch
"Cycle branch.<name>.rebase for")))
(magit-popup-set-variable (format "branch.%s.rebase" branch)
'("true" "false")
"false" "pull.rebase"))
(magit--set-popup-variable (format "branch.%s.rebase" branch)
'("true" "false")
"false" "pull.rebase"))
(defun magit-format-branch*rebase ()
(let ((branch (magit-branch-config-branch)))
......@@ -766,9 +766,9 @@ If that variable is undefined, then the value of the Git variable
which by default it is not."
(interactive (list (magit-branch-config-branch
"Cycle branch.<name>.pushRemote for")))
(magit-popup-set-variable (format "branch.%s.pushRemote" branch)
(magit--set-popup-variable (format "branch.%s.pushRemote" branch)
(defun magit-format-branch*pushRemote ()
(let ((branch (magit-branch-config-branch)))
......@@ -788,7 +788,7 @@ variable `branch.<name>.rebase'.
When `true' then pulling is done by rebasing.
When `false' (the default) then pulling is done by merging."
(magit-popup-set-variable "pull.rebase" '("true" "false") "false"))
(magit--set-popup-variable "pull.rebase" '("true" "false") "false"))
(defun magit-format-pull.rebase ()
(magit-popup-format-variable "pull.rebase" '("true" "false") "false" nil 19))
......@@ -801,7 +801,7 @@ The Git variable `remote.pushDefault' specifies the remote that
local branches are usually pushed to. It can be overwritten
using the Git variable `branch.<name>.pushRemote'."
(magit-popup-set-variable "remote.pushDefault" (magit-list-remotes)))
(magit--set-popup-variable "remote.pushDefault" (magit-list-remotes)))
(defun magit-format-remote.pushDefault ()
(magit-popup-format-variable "remote.pushDefault"
......@@ -827,8 +827,8 @@ branch.
When `false' then the variables are never set."
(magit-popup-set-variable "branch.autoSetupMerge"
'("always" "true" "false") "true"))
(magit--set-popup-variable "branch.autoSetupMerge"
'("always" "true" "false") "true"))
(defun magit-format-branch*autoSetupMerge ()
(magit-popup-format-variable "branch.autoSetupMerge"
......@@ -853,8 +853,8 @@ is a remote branch, but not when it is a local branch.
When `never' (the default) then the variable is never set."
(magit-popup-set-variable "branch.autoSetupRebase"
'("always" "local" "remote" "never") "never"))
(magit--set-popup-variable "branch.autoSetupRebase"
'("always" "local" "remote" "never") "never"))
(defun magit-format-branch*autoSetupRebase ()
(magit-popup-format-variable "branch.autoSetupRebase"
......@@ -30,6 +30,7 @@
(require 'cl-lib)
(require 'dash)
(require 'magit-popup)
(require 'magit-utils)
(require 'magit-section)
......@@ -38,6 +39,7 @@
(declare-function magit-process-buffer 'magit-process)
(declare-function magit-process-file 'magit-process)
(declare-function magit-process-insert-section 'magit-process)
(declare-function magit-refresh 'magit-mode)
(defvar magit-process-error-message-regexps)
(defvar magit-refresh-args) ; from `magit-mode' for `magit-current-file'
(defvar magit-branch-prefer-remote-upstream)
......@@ -1824,5 +1826,18 @@ the reference is used. The first regexp submatch becomes the
(dolist (v values)
(magit-call-git "config" arg "--add" var v))))
;;;; Variables in Popups
(defun magit--set-popup-variable
(variable choices &optional default other)
(magit-set (--if-let (magit-git-string "config" "--local" variable)
(cadr (member it choices))
(car choices))
(message "%s %s" variable
(magit-popup-format-variable variable choices default other)))
(provide 'magit-git)
;;; magit-git.el ends here
......@@ -279,8 +279,8 @@ Delete the symbolic-ref \"refs/remotes/<remote>/HEAD\"."
(defun magit-cycle-remote*tagOpt (remote)
(interactive (list (magit-remote-config--remote)))
(magit-popup-set-variable (format "remote.%s.tagOpts" remote)
'("--no-tags" "--tags") nil))
(magit--set-popup-variable (format "remote.%s.tagOpts" remote)
'("--no-tags" "--tags") nil))
(defun magit-format-remote*url ()
(magit-remote-config--format-variable "url"))
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