Have magit-get-current-remote default to "origin", like Git does.

This commit is contained in:
Nathan Weizenbaum 2010-06-10 16:36:54 -07:00
parent 5744d3ec98
commit db32004209

View file

@ -485,13 +485,20 @@ Many Magit faces inherit from this one by default."
(substring head 11) (substring head 11)
nil))) nil)))
(defun magit-get-remote (branch)
"Return the name of the remote for BRANCH.
If branch is nil or it has no remote, but a remote named
\"origin\" exists, return that. Otherwise, return nil."
(let ((remote (or (and branch (magit-get "branch" branch "remote"))
(and (magit-get "remote" "origin" "url") "origin"))))
(if (string= remote "") nil remote)))
(defun magit-get-current-remote () (defun magit-get-current-remote ()
"Return the name of the remote for the current branch. "Return the name of the remote for the current branch.
If there is no current branch, or no remote for that branch, If there is no current branch, or no remote for that branch,
return nil." but a remote named \"origin\" is configured, return that.
(let* ((branch (magit-get-current-branch)) Otherwise, return nil."
(remote (and branch (magit-get "branch" branch "remote")))) (magit-get-remote (magit-get-current-branch)))
(if (string= remote "") nil remote)))
(defun magit-ref-exists-p (ref) (defun magit-ref-exists-p (ref)
(= (magit-git-exit-code "show-ref" "--verify" ref) 0)) (= (magit-git-exit-code "show-ref" "--verify" ref) 0))