Skip to content

Instantly share code, notes, and snippets.

@sbryant
Created June 22, 2010 15:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbryant/448664 to your computer and use it in GitHub Desktop.
Save sbryant/448664 to your computer and use it in GitHub Desktop.
ccommit 42ee3d2b74ac93a760d7f7479e5fa066bacc15ba
Author: Sean Bryant <sean@vitrue.com>
Date: Tue Jun 22 11:54:50 2010 -0400
make pushing to explicit ref merge branch only push explicitly when it is available
Modified magit.el
diff --git a/magit.el b/magit.el
index 0de0bfc..f8b5aee 100644
--- a/magit.el
+++ b/magit.el
@@ -3041,11 +3041,14 @@ typing and automatically refreshes the status buffer."
(magit-read-remote (format "Push %s to" branch)
branch-remote)
branch-remote))
- (ref-branch (magit-get "branch" branch "merge")))
+ (merge-branch (magit-get "branch" branch "merge"))
+ (ref-branch (if merge-branch
+ (format "%s:%s" branch merge-branch)
+ branch)))
(if (and (not branch-remote)
(not current-prefix-arg))
(magit-set push-remote "branch" branch "remote"))
- (magit-run-git-async "push" "-v" push-remote (format "%s:%s" branch ref-branch))))
+ (magit-run-git-async "push" "-v" push-remote ref-branch)))
;;; Log edit mode
@binjo
Copy link

binjo commented Jun 25, 2010

Hi,

I tried this patch, however it still does not work properly, since the ref-branch is "" when pushing repo,
it becomes "push --no-pager push -v origin", and git complains:
fatal: remote part of refspec is not a valid name in

I changed your code a little bit as follows:

 (ref-branch (if merge-branch
                 (format "%s:%s" branch merge-branch)
               branch)))

substitute "" with branch, which works. Since I am still newbie of git,
I don't know if this change breaks things though.

Cheers,

Binjo

@sbryant
Copy link
Author

sbryant commented Jun 25, 2010

That's probably for the better, I'll update the patch and regenerate the diff for submission.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment