]> git.ipfire.org Git - thirdparty/git.git/commit - builtin/push.c
push: error out when the "upstream" semantics does not make sense
authorJunio C Hamano <gitster@pobox.com>
Fri, 30 Mar 2012 23:07:12 +0000 (16:07 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Apr 2012 20:35:57 +0000 (13:35 -0700)
commit135dadef712f0c4cf884940e751024c831937904
tree84572dd70ab3621c74df5a172b332469c2c77c1a
parentd365a432271d2f6384cda9c37fb2fe463bdc2850
push: error out when the "upstream" semantics does not make sense

The user can say "git push" without specifying any refspec.  When using
the "upstream" semantics via the push.default configuration, the user
wants to update the "upstream" branch of the current branch, which is the
branch at a remote repository the current branch is set to integrate with,
with this command.

However, there are cases that such a "git push" that uses the "upstream"
semantics does not make sense:

 - The current branch does not have branch.$name.remote configured.  By
   definition, "git push" that does not name where to push to will not
   know where to push to.  The user may explicitly say "git push $there",
   but again, by definition, no branch at repository $there is set to
   integrate with the current branch in this case and we wouldn't know
   which remote branch to update.

 - The current branch does have branch.$name.remote configured, but it
   does not specify branch.$name.merge that names what branch at the
   remote this branch integrates with. "git push" knows where to push in
   this case (or the user may explicitly say "git push $remote" to tell us
   where to push), but we do not know which remote branch to update.

 - The current branch does have its remote and upstream branch configured,
   but the user said "git push $there", where $there is not the remote
   named by "branch.$name.remote".  By definition, no branch at repository
   $there is set to integrate with the current branch in this case, and
   this push is not meant to update any branch at the remote repository
   $there.

The first two cases were already checked correctly, but the third case was
not checked and we ended up updating the branch named branch.$name.merge
at repository $there, which was totally bogus.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/push.c
t/t5528-push-default.sh [new file with mode: 0755]