Re: branch.<name>.pushremote not working with push.default simple or upstream

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[+CC: jc, jk]

Leandro Lucarella wrote:
> I changed branch.master.remote to upstream and set
> branch.master.pushremote to origin, but when I do I git push I get an
> error:
>
> $ git push --dry-run --verbose
> fatal: You are pushing to remote 'origin', which is not the upstream of
> your current branch 'master', without telling me what to push
> to update which remote branch.

Yes, this is a defect: both remote.pushdefault and
branch.<name>.pushremote suffer from it.

Let me explain what's happening.  The error is triggered off in
setup_push_upstream() in builtin/push.c (which both simple and
upstream use).  It's exactly the same error that will be reported if
you do the following without a branch.master.pushremote or
remote.pushdefault configured:

  $ git push origin --dry-run --verbose
  fatal: You are pushing to remote 'origin', which is not the upstream of
  your current branch 'master', without telling me what to push
  to update which remote branch.

You should therefore be able to infer that remote.pushdefault/
branch.<name>.pushremote is simply saving you from remembering/ typing
out that "origin" on the command-line.  The error precisely describes
the problem.  To understand what this "upstream" the error is talking
about, see:

   $ git rev-parse --symbolic-full-name @{u}
   refs/remotes/upstream/master

So, if you are pushing to upstream, the push knows what to do: push to
the refspec <branch>:<branch>@{u} (see builtin/push.c:148).  If you're
pushing to origin, it has no idea _what_ to push, and hence errors
out.  By design, upstream/ simple assume that you push to the same
place that you pull from: the description clearly says that it is
intended to make the push and pull symmetric.

Finally, the reason remote.pushdefault/ branch.<name>.pushremote works
in the other modes is simple: in matching and current, the push
refspec is not dependent on the current branch's upstream.  In
matching, the refspec it is the constant ":", and in current, it is
the constant "HEAD" (will subtly change with rr/push-head).

I think the correct fix is to change the semantics of upstream/simple
to dictate a refspec independent of remote.  So, if:

1. branch.master.merge is configured to refs/heads/rr/master
2. branch.master.remote is configured to origin
3. remote.pushdefault is configured to ram
4. push.default is configured to upstream

Then, the a push should push the refspec master:rr/master to the
remote ram.  Let's see what the others have to say before proceeding.

Thank you for reporting this problem.  It is indeed very serious,
especially since simple is going to be default in Git 2.0.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]