Hi, I believe this change has the side-effect of making push to an empty repository (e.g. you set up a new shared repository for your project, clone it, commit to your clone and push) not work by default because the refspec argument is required in that case. Rare case perhaps, but so is the one you are trading it for. I guess one can work around this by using the prefix argument if one knows what's going on but... Do you think you could come up with a version without this disadvantage?
Moritz Bunkus <[email protected]> writes: > If the current local branch's name differs from the remote's branch > name then using the local branch name as an explicit refspec will > cause git to create a new branch in the remote repository. magit > itself does not parse the "remote.<remotename>.push" config option. By > leaving out the refspec from the push command git will parse that > config option itself and push to the correct branch in the remote > repository. > > If 'magit-push' is called with a prefix or if no remote has been > configured for the current local branch then the local branch name > will still be used as an explicit refspec. > --- > magit.el | 12 ++++++++---- > 1 files changed, 8 insertions(+), 4 deletions(-) > > diff --git a/magit.el b/magit.el > index af15e0f..b20884c 100644 > --- a/magit.el > +++ b/magit.el > @@ -2598,15 +2598,19 @@ branch." > (let* ((branch (or (magit-get-current-branch) > (error "Don't push a detached head. That's gross."))) > (branch-remote (magit-get "branch" branch "remote")) > - (push-remote (if (or current-prefix-arg > - (not branch-remote)) > + (explicit-remote-branch (or current-prefix-arg > + (not branch-remote))) > + (push-remote (if explicit-remote-branch > (magit-read-remote (format "Push %s to" branch) > branch-remote) > - branch-remote))) > + branch-remote)) > + (args (list "push" "-v" push-remote))) > + (if explicit-remote-branch > + (nconc args (list branch))) In general it's bad style to use nconc for its side effect even though it works in this case. I'd also use when instead of if when there is no else case. For what it's worth, I'd have written (args (list* "push" "-v" push-remote (when explicit-remote-branch (list branch)))) or, actually, instead of building args to begin with, simply (apply 'magit-run-git-async "push" "-v" push-remote (when explicit-remote-branch (list 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 branch))) > + (apply 'magit-run-git-async args))) > > ;;; Log edit mode -- Hannu To unsubscribe from this group, send email to magit+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
