From db320042090bedea192c3fa3d969cfc904651ce2 Mon Sep 17 00:00:00 2001 From: Nathan Weizenbaum Date: Thu, 10 Jun 2010 16:36:54 -0700 Subject: [PATCH] Have magit-get-current-remote default to "origin", like Git does. --- magit.el | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/magit.el b/magit.el index c03ad68d..98ca8c84 100644 --- a/magit.el +++ b/magit.el @@ -485,13 +485,20 @@ Many Magit faces inherit from this one by default." (substring head 11) 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 () "Return the name of the remote for the current branch. If there is no current branch, or no remote for that branch, -return nil." - (let* ((branch (magit-get-current-branch)) - (remote (and branch (magit-get "branch" branch "remote")))) - (if (string= remote "") nil remote))) +but a remote named \"origin\" is configured, return that. +Otherwise, return nil." + (magit-get-remote (magit-get-current-branch))) (defun magit-ref-exists-p (ref) (= (magit-git-exit-code "show-ref" "--verify" ref) 0))