Skip to content
  • Jeff King's avatar
    push: allow unqualified dest refspecs to DWIM · f8aae120
    Jeff King authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    Previously, a push like:
    
      git push remote src:dst
    
    would go through the following steps:
    
      1. check for an unambiguous 'dst' on the remote; if it
         exists, then push to that ref
      2. otherwise, check if 'dst' begins with 'refs/'; if it
         does, create a new ref
      3. otherwise, complain because we don't know where in the
         refs hierarchy to put 'dst'
    
    However, in some cases, we can guess about the ref type of
    'dst' based on the ref type of 'src'. Specifically, before
    complaining we now check:
    
      2.5. if 'src' resolves to a ref starting with refs/heads
           or refs/tags, then prepend that to 'dst'
    
    So now this creates a new branch on the remote, whereas it
    previously failed with an error message:
    
      git push master:newbranch
    
    Note that, by design, we limit this DWIM behavior only to
    source refs which resolve exactly (including symrefs which
    resolve to existing refs). We still complain on a partial
    destination refspec if the source is a raw sha1, or a ref
    expression such as 'master~10'.
    
    Signed-off-by: default avatarJeff King <peff@peff.net>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    f8aae120