mbox series

[v3,0/8] fixes for unqualified <dst> push

Message ID 20181026230741.23321-1-avarab@gmail.com (mailing list archive)
Headers show
Series fixes for unqualified <dst> push | expand

Message

Ævar Arnfjörð Bjarmason Oct. 26, 2018, 11:07 p.m. UTC
After sending out v2 I noticed I didn't update the examples in a
couple of the commit messages, and figured I'd finish this up by
adding a patch to document how this works in the "git-push"
manpage. This behavior has never been properly documented. range-diff
with v2:
    
    1:  ca8eb6dc28 = 1:  ca8eb6dc28 remote.c: add braces in anticipation of a follow-up change
    2:  b0e15b6ff1 = 2:  b0e15b6ff1 i18n: remote.c: mark error(...) messages for translation
    3:  052fc5860e = 3:  052fc5860e push: improve the error shown on unqualified <dst> push
    4:  e6aa2e360f = 4:  e6aa2e360f push: move unqualified refname error into a function
    5:  57840952b2 ! 5:  dcf566e16e push: add an advice on unqualified <dst> push
        @@ -13,8 +13,10 @@
                 error: The destination you provided is not a full refname (i.e.,
                 starting with "refs/"). We tried to guess what you meant by:
         
        -        - Looking for a ref that matches newbranch on the remote side.
        -        - Looking at the refname of the local source.
        +        - Looking for a ref that matches 'newbranch' on the remote side.
        +        - Checking if the <src> being pushed ('v2.19.0^{commit}')
        +          is a ref in "refs/{heads,tags}/". If so we add a corresponding
        +          refs/{heads,tags}/ prefix on the remote side.
         
                 Neither worked, so we gave up. You must fully-qualify the ref.
                 hint: The <src> part of the refspec is a commit object.
    6:  a2d98855cc = 6:  92ff753437 push: test that <src> doesn't DWYM if <dst> is unqualified
    7:  4e1953da82 ! 7:  58eeb0f3f3 push: add DWYM support for "git push refs/remotes/...:<dst>"
        @@ -3,22 +3,44 @@
             push: add DWYM support for "git push refs/remotes/...:<dst>"
         
             Add DWYM support for pushing a ref in refs/remotes/* when the <dst>
        -    ref is unqualified, e.g.:
        +    ref is unqualified. Now instead of erroring out we support e.g.:
         
        -        git push origin refs/remotes/origin/master:upstream-master
        +        $ ./git-push avar refs/remotes/origin/master:upstream-master -n
        +        To github.com:avar/git.git
        +         * [new branch]            origin/master -> upstream-master
         
             Before this we wouldn't know what do do with
             refs/remotes/origin/master, now we'll look it up and discover that
             it's a commit (or tag) and add a refs/{heads,tags}/ prefix to <dst> as
             appropriate.
         
        +    The error message emitted when we still don't know what to do has been
        +    amended to note that this is something we tried:
        +
        +        $ ./git-push avar v2.19.0^{commit}:newbranch -n
        +        error: The destination you provided is not a full refname (i.e.,
        +        starting with "refs/"). We tried to guess what you meant by:
        +
        +        - Looking for a ref that matches 'newbranch' on the remote side.
        +        - Checking if the <src> being pushed ('v2.19.0^{commit}')
        +          is a ref in "refs/{heads,tags}/". If so we add a corresponding
        +          refs/{heads,tags}/ prefix on the remote side.
        +        - Checking if the <src> being pushed ('v2.19.0^{commit}')
        +          is a commit or tag in "refs/remotes/*". Then we infer a
        +          corresponding refs/{heads,tags} on the remote side.
        +
        +        None of those worked, so we gave up. You must fully-qualify the ref.
        +        hint: The <src> part of the refspec is a commit object.
        +        hint: Did you mean to create a new branch by pushing to
        +        hint: 'v2.19.0^{commit}:refs/heads/newbranch'?
        +
             I'm bending over backwards and assuming that someone might have hacked
             in remote tracking tags (see [1] for a discussion of how that can be
             done), but punting on any tree or blob objects found under
             refs/remotes/*.
         
             This is the first use of the %N$<fmt> style of printf format in
        -    the *.[ch] files in our codebase, but it's supported by POSIX[2] and
        +    the *.[ch] files in our codebase. It's supported by POSIX[2] and
             there's existing uses for it in po/*.po files, so hopefully it won't
             cause any trouble. It's more obvious for translators than to have a
             3rd argument to the function identical to the 2nd, by re-using the 2nd
    -:  ---------- > 8:  bc171b0312 push doc: document the DWYM behavior pushing to unqualified <dst>

Ævar Arnfjörð Bjarmason (8):
  remote.c: add braces in anticipation of a follow-up change
  i18n: remote.c: mark error(...) messages for translation
  push: improve the error shown on unqualified <dst> push
  push: move unqualified refname error into a function
  push: add an advice on unqualified <dst> push
  push: test that <src> doesn't DWYM if <dst> is unqualified
  push: add DWYM support for "git push refs/remotes/...:<dst>"
  push doc: document the DWYM behavior pushing to unqualified <dst>

 Documentation/config.txt   |   7 +++
 Documentation/git-push.txt |  27 ++++++++
 advice.c                   |   2 +
 advice.h                   |   1 +
 remote.c                   | 124 +++++++++++++++++++++++++++++--------
 t/t5505-remote.sh          |  57 +++++++++++++++++
 6 files changed, 193 insertions(+), 25 deletions(-)

Comments

Jeff King Nov. 2, 2018, 6:52 a.m. UTC | #1
On Fri, Oct 26, 2018 at 11:07:33PM +0000, Ævar Arnfjörð Bjarmason wrote:

> After sending out v2 I noticed I didn't update the examples in a
> couple of the commit messages, and figured I'd finish this up by
> adding a patch to document how this works in the "git-push"
> manpage. This behavior has never been properly documented. range-diff
> with v2:

I read over these patches and the comments from Junio. Overall, I like
the direction of the first half 5, and tend to agree with the review
that the "refs/remotes" thing is going too far.

I didn't dig down into reviewing each line, since it looked like Junio
already did, and there's probably a re-roll coming.

-Peff