Commit 815d4ed6 authored by Noam Postavsky's avatar Noam Postavsky Committed by Jonas Bernoulli

Make magit-get setf'able

parent f3301686
......@@ -1457,9 +1457,14 @@ Return a list of two integers: (A>B B>A)."
(defun magit-set (val &rest keys)
"Set Git config settings specified by KEYS to VAL."
(if val
(magit-git-string "config" (mapconcat 'identity keys ".") val)
(magit-git-string "config" "--unset" (mapconcat 'identity keys "."))))
(let ((key (mapconcat 'identity keys ".")))
(if val
(magit-git-success "config" key val)
(magit-git-success "config" "--unset" key))
val))
(gv-define-setter magit-get (val &rest keys)
`(magit-set ,val ,@keys))
;;; magit-git.el ends soon
......
......@@ -78,7 +78,7 @@ Then show the status buffer for the new repository."
(when (or (eq magit-clone-set-remote.pushDefault t)
(and magit-clone-set-remote.pushDefault
(y-or-n-p "Set `remote.pushDefault' to \"origin\"? ")))
(magit-call-git "config" "remote.pushDefault" "origin"))
(setf (magit-get "remote.pushDefault") "origin"))
(unless magit-clone-set-remote-head
(magit-remote-unset-head "origin")))
(with-current-buffer (process-get process 'command-buf)
......@@ -128,7 +128,7 @@ the variable isn't already set."
((or `(ask ,_) `(ask-if-unset nil))
(y-or-n-p (format "Set `remote.pushDefault' to \"%s\"? " remote))))
(progn (magit-call-git "remote" "add" "-f" remote url)
(magit-call-git "config" "remote.pushDefault" remote)
(setf (magit-get "remote.pushDefault") remote)
(magit-refresh))
(magit-run-git-async "remote" "add" "-f" remote url)))
......@@ -477,13 +477,12 @@ the push-remote can be changed before pushed to it."
(magit-get-current-branch)))))))
(--if-let (magit-get-current-branch)
(progn (when push-remote
(magit-call-git
"config"
(if (eq magit-push-current-set-remote-if-missing 'default)
"remote.pushDefault"
(format "branch.%s.pushRemote"
(magit-get-current-branch)))
push-remote))
(setf (magit-get
(if (eq magit-push-current-set-remote-if-missing 'default)
"remote.pushDefault"
(format "branch.%s.pushRemote"
(magit-get-current-branch))))
push-remote))
(-if-let (remote (magit-get-push-remote it))
(if (member remote (magit-list-remotes))
(magit-git-push it (concat remote "/" it) args)
......
......@@ -1660,9 +1660,9 @@ already set. When nil, then always unset."
(magit-read-upstream-branch)))))
(if upstream
(-let (((remote . merge) (magit-split-branch-name upstream)))
(magit-call-git "config" (format "branch.%s.remote" branch) remote)
(magit-call-git "config" (format "branch.%s.merge" branch)
(concat "refs/heads/" merge)))
(setf (magit-get (format "branch.%s.remote" branch)) remote)
(setf (magit-get (format "branch.%s.merge" branch))
(concat "refs/heads/" merge)))
(magit-call-git "branch" "--unset-upstream" branch))
(when (called-interactively-p 'any)
(magit-refresh)))
......
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