git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3 7/8] push: add DWYM support for "git push refs/remotes/...:<dst>"

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Nov 5, 2018, 11:31 UTC
Message-ID
<87k1lr7obd.fsf@evledraar.gmail.com>
In-Reply-To
<xmqqy3adtopw.fsf@gitster-ct.c.googlers.com>

I'll re-roll this. Hopefully sooner than later. I'll leave out the later part of this series as it's more controversial and we can discuss that later on its own. Meanwhile just some replies to this (while I remember):

Show 40 quoted lines
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>>> On the other hand, I do not think I mind all that much if a src that
>>> is a tag object to automatically go to refs/tags/ (having a tag
>>> object in refs/remotes/** is rare enough to matter in the first
>>> place).
>>
>> Yeah maybe this is going too far. I don't think so, but happy to me
>> challenged on that point :)
>>
>> I don't think so because the only reason I've ever needed this is
>> because I deleted some branch accidentally and am using a push from
>> "remotes/*" to bring it back. I.e. I'll always want branch-for-branch,
>> not to push that as a tag.
>
> Oh, I didn't consider pushing it out as a tag, but now you bring it
> up, I think that it also would make sense in a workflow to tell your
> colleages to look at (sort of like how people use pastebin---"look
> here, this commit has the kind of change I have in mind in this
> discussion") some random commit and the commit happens to be sitting
> at a tip of a remote-trackig branch.  Instead of pushing it out as a
> branch or a remote-tracking branch, which has strong connotations of
> inviting others to build on top, pushing it out as a tag would make
> more sense in that context.
>
> And as I mentioned already, I think it would equally likely, if not
> more likely, for people like me to push remotes/** out as a
> remote-tracking branch (rather than a local branch) of the
> repository I'm pushing into.
>
> So I tend to agree that this is going too far.  If the original
> motivating example was not an ingredient of everyday workflow, but
> was an one-off "recovery", I'd rather see people forced to be more
> careful by requiring "push origin/frotz:refs/heads/frotz" rather
> than incorrectly DWIDNM "push origin/frotz:frotz" and ending up with
> creating refs/tags/frotz or refs/remotes/origin/frotz, which also
> are plausible choices depending on what the user is trying to
> recover from, which the sending end would not know (the side on
> which the accidental loss of a ref happened earlier is on the remote
> repository that would be receiving this push, and it _might_ know).

Yeah this example was bad, but now since I've written it I've become more convinced that it's the right way to go, just that I didn't explain it well.

E.g. just now I did:
    git push avar avar/some-branch:some-branch-wip
    git push avar HEAD -f # I was on 'some-branch'

Because I'd regretted taking the "some-branch" name with some WIP code, but didn't want to lose the work, so I wanted to swap.

It's also arbitrary and contrary to the distributed nature of git that we're treating branches from other repos differently than the ones from ours.

After all sometimes "other" is just the repo on my laptop or server. I shouldn't need to jump through hoops to re-push stuff from my "other" repo anymore than from the local repo.

Yes refs/remotes/* isn't guaranteed to be "other repo's branches" in the same way our local refs/heads/* is, and this series bends over backwards to check if someone's (ab)used it for that, but I think for the purposes of the default UI we should treat it as "branches from other remotes" if we find commit objects there.

So I think the *only* thing we should be checking for the purposes of this DWYM feature is what local type of object (branch or tag) we find on the LHS of the refspec. And if we're sure of its type push to refs/{heads,tags}/* as appropriate.

I don't think it makes any sense as you suggest to move away from "guess based on existing type" to breaking the dwimmery because we found the branch in some other place. The user's pushing "newref" from an existing branch, let's just assume the new thing is a branch, whether the source is local or not.

Show 15 quoted lines
> As to the entirety of the series,
>
>  - I do not think this step 7, and its documentation in step 8, are
>    particularly a good idea, in their current shape.  Pushing tag
>    objects to refs/tags/ is probably a good idea, but pushing a
>    commit as local branch heads are necessarily not.
>
>  - Step 6 is probably a good documentation on the cases in which we
>    make and do not make guess on the unqualified push destination.
>
>  - Step 5 and earlier looked like good changes.
>
> If we were to salvage some parts of step 7 (and step 8), we'd
> probably need fb7c2268 ("SQUASH???", 2018-10-29) to number all the
> placeholders in the printf format string.
Thanks. As noted will try to re-roll this soon.
Previous: Junio C HamanoNext: Junio C Hamano
Message 38 of 53 in “add an advice on unqualified <dst> push”
  1. 0/2 add an advice on unqualified <dst> pushÆvar Arnfjörð Bjarmason, Oct 10, 2018
  2. 1/2 i18n: remote.c: mark error(...) messages for translationÆvar Arnfjörð Bjarmason, Oct 10, 2018
  3. Jeff KingOct 10, 2018
  4. 2/2 push: add an advice on unqualified <dst> pushÆvar Arnfjörð Bjarmason, Oct 10, 2018
  5. Jeff KingOct 10, 2018
  6. Ævar Arnfjörð BjarmasonOct 10, 2018
  7. Jeff KingOct 11, 2018
  8. Junio C HamanoOct 11, 2018
  9. Ævar Arnfjörð BjarmasonOct 26, 2018
  10. Junio C HamanoOct 29, 2018
  11. Junio C HamanoOct 29, 2018
  12. 0/7 fixes for unqualified <dst> pushÆvar Arnfjörð Bjarmason, Oct 26, 2018
  13. 0/8 fixes for unqualified <dst> pushÆvar Arnfjörð Bjarmason, Oct 26, 2018
  14. Jeff KingNov 2, 2018
  15. 0/7 fixes for unqualified <dst> pushÆvar Arnfjörð Bjarmason, Nov 13, 2018
  16. Junio C HamanoNov 14, 2018
  17. 1/7 remote.c: add braces in anticipation of a follow-up changeÆvar Arnfjörð Bjarmason, Nov 13, 2018
  18. 2/7 i18n: remote.c: mark error(...) messages for translationÆvar Arnfjörð Bjarmason, Nov 13, 2018
  19. 3/7 push: improve the error shown on unqualified <dst> pushÆvar Arnfjörð Bjarmason, Nov 13, 2018
  20. 4/7 push: move unqualified refname error into a functionÆvar Arnfjörð Bjarmason, Nov 13, 2018
  21. 5/7 push: add an advice on unqualified <dst> pushÆvar Arnfjörð Bjarmason, Nov 13, 2018
  22. 6/7 push: test that <src> doesn't DWYM if <dst> is unqualifiedÆvar Arnfjörð Bjarmason, Nov 13, 2018
  23. 7/7 push doc: document the DWYM behavior pushing to unqualified <dst>Ævar Arnfjörð Bjarmason, Nov 13, 2018
  24. 1/8 remote.c: add braces in anticipation of a follow-up changeÆvar Arnfjörð Bjarmason, Oct 26, 2018
  25. 2/8 i18n: remote.c: mark error(...) messages for translationÆvar Arnfjörð Bjarmason, Oct 26, 2018
  26. 3/8 push: improve the error shown on unqualified <dst> pushÆvar Arnfjörð Bjarmason, Oct 26, 2018
  27. Junio C HamanoOct 29, 2018
  28. 4/8 push: move unqualified refname error into a functionÆvar Arnfjörð Bjarmason, Oct 26, 2018
  29. 6/8 push: test that <src> doesn't DWYM if <dst> is unqualifiedÆvar Arnfjörð Bjarmason, Oct 26, 2018
  30. Junio C HamanoOct 29, 2018
  31. 5/8 push: add an advice on unqualified <dst> pushÆvar Arnfjörð Bjarmason, Oct 26, 2018
  32. Junio C HamanoOct 29, 2018
  33. Jeff KingNov 2, 2018
  34. 7/8 push: add DWYM support for "git push refs/remotes/...:<dst>"Ævar Arnfjörð Bjarmason, Oct 26, 2018
  35. Junio C HamanoOct 29, 2018
  36. Ævar Arnfjörð BjarmasonOct 29, 2018
  37. Junio C HamanoNov 1, 2018
  38. Ævar Arnfjörð BjarmasonNov 5, 2018
  39. Junio C HamanoNov 5, 2018
  40. Junio C HamanoOct 29, 2018
  41. Junio C HamanoOct 29, 2018
  42. Ævar Arnfjörð BjarmasonOct 29, 2018
  43. 8/8 push doc: document the DWYM behavior pushing to unqualified <dst>Ævar Arnfjörð Bjarmason, Oct 26, 2018
  44. 1/7 remote.c: add braces in anticipation of a follow-up changeÆvar Arnfjörð Bjarmason, Oct 26, 2018
  45. Stefan BellerOct 26, 2018
  46. 2/7 i18n: remote.c: mark error(...) messages for translationÆvar Arnfjörð Bjarmason, Oct 26, 2018
  47. 3/7 push: improve the error shown on unqualified <dst> pushÆvar Arnfjörð Bjarmason, Oct 26, 2018
  48. 5/7 push: add an advice on unqualified <dst> pushÆvar Arnfjörð Bjarmason, Oct 26, 2018
  49. 6/7 push: test that <src> doesn't DWYM if <dst> is unqualifiedÆvar Arnfjörð Bjarmason, Oct 26, 2018
  50. 7/7 push: add DWYM support for "git push refs/remotes/...:<dst>"Ævar Arnfjörð Bjarmason, Oct 26, 2018
  51. 4/7 push: move unqualified refname error into a functionÆvar Arnfjörð Bjarmason, Oct 26, 2018
  52. Junio C HamanoOct 10, 2018
  53. Jeff KingOct 11, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.