Skip to content
  • Junio C Hamano's avatar
    push: error out when the "upstream" semantics does not make sense · 135dadef
    Junio C Hamano authored
    
    
    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: default avatarJunio C Hamano <gitster@pobox.com>
    135dadef