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

Re: [RFC PATCH] push: start warning upcoming default change for push.default

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Mar 14, 2012, 08:59 UTC
Message-ID
<4F605DD8.9040504@alum.mit.edu>
In-Reply-To
<20120312183725.GA2187@sigill.intra.peff.net>
On 03/12/2012 07:37 PM, Jeff King wrote:
Show 12 quoted lines
> On Mon, Mar 12, 2012 at 05:37:32PM +0100, Matthieu Moy wrote:
>> * For newbies, the sequence "create an empty repository, clone it,
>>   commit and push" works like a charm with either 'upstream' or
>>   'current'. Today, the first push to an empty repository requires
>>   either saying "git push origin master" or "git push --all", both of
>>   which sound like black magic to the poor user who did not yet learn
>>   what 'origin' is and what a branch is.
> 
> Ending that confusion is one of the best reasons to switch the default,
> IMHO, but I don't think it argues for "current" versus "upstream", as
> they both fix it (but Michael's matching-current hybrid would not, so I
> agree it is less appealing).

In the case of my proposed matching-current hybrid, the error message for the failing push would make it pretty obvious what went wrong and how to fix it; something like:

    $ git push
    The remote repository "git.example.com:myproject" does not yet
    contain a branch called "master".  If you would like to create one
    now, type
        git push origin master
    For other alternatives, please see gitworkflows(7).

This error message would appear *whenever* the matching-current hybrid policy caused the push to fail. Since this problem occurs only if (1) the upstream repository is empty and (2) the user hasn't configured a more liberal global push.default, and since it is blindingly obvious what to do to fix the problem, it doesn't seem especially onerous.

(One could even create a special-case to allow such a push when the upstream repository is empty, but I don't think the gain in convenience is worth the loss of consistency.)

Show 6 quoted lines
> So far a lot of the discussion has focused on "what is the most sensible
> default for the most number of people". But I wonder if a better
> question is "what is the default that is the least likely to do
> something dangerous and embarrassing". People who use git enough to say
> "wow, I don't like this default for my workflow" are probably at the
> point that they can configure push.default themselves.

I agree entirely. And here is an algorithm for deciding what the default should be:

1. Make a list of branch configurations that can be distinguished by
   git, which would be something like all combinations of
   * remote has a branch with the same name as the current branch?
     * no
     * yes, and remote branch could be fast-forwarded to local state
     * yes, but remote branch cannot be fast-forwarded to local state
   * local branch has known upstream branch on remote?
     * no
     * yes, and remote upstream branch could be fast-forwarded to
       the state of the current local branch
     * yes, but remote upstream branch cannot be fast-forwarded to
       the state of the current local branch
2. In each of these situations, decide what "git push" should do in
   each of the common workflows.
3. In the branching configurations for which all workflows agree about
   what "git push" should do, then that is what "git push" should do by
   default.  When they do not agree, then "git push" should do nothing,
   give an informative error message, and leave it to the user to
   decide.  If all workflows agree on a safe subset of what "git push"
   should do (for example, "matching" and "current" agree that the
   current branch should be pushed even though they disagree whether
   other branches should be pushed), then it might be OK to carry out
   the safe subset.

The most common workflows, along with the configuration settings that are recommended for that workflow, should be given standard names and documented in gitworkflows(7). The warning message for a failed "git push" invocations (especially if push.default is unset) should direct the user to this manpage.

Isn't it obvious?: The fact that we cannot even agree among ourselves what "git push" should do in all cases *proves* that we are trying to be too ambitious with DWIM. "git push" must therefore become more deferential when the obvious thing to do is unclear, especially given that mistakes (due to the very nature of "git push") often have embarrassing and publicly visible effects.

Michael
-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
Previous: Matthieu MoyNext: Jeff King
Message 82 of 116 in “git push default behaviour?”
  1. Jeremy MortonMar 8, 2012
  2. Thomas RastMar 8, 2012
  3. Jeremy MortonMar 8, 2012
  4. Carlos Martín NietoMar 8, 2012
  5. Jeremy MortonMar 8, 2012
  6. Carlos Martín NietoMar 8, 2012
  7. Jeremy MortonMar 8, 2012
  8. Junio C HamanoMar 8, 2012
  9. Matthieu MoyMar 8, 2012
  10. Andreas KreyMar 8, 2012
  11. Junio C HamanoMar 8, 2012
  12. Matthieu MoyMar 9, 2012
  13. Junio C HamanoMar 9, 2012
  14. Jeremy MortonMar 9, 2012
  15. Matthieu MoyMar 9, 2012
  16. Jakub NarebskiMar 9, 2012
  17. Miles BaderMar 19, 2012
  18. Philippe VaucherMar 19, 2012
  19. Marc BranchaudMar 8, 2012
  20. Matthieu MoyMar 8, 2012
  21. Dmitry PotapovMar 8, 2012
  22. Matthieu MoyMar 8, 2012
  23. Jeff KingMar 9, 2012
  24. Junio C HamanoMar 9, 2012
  25. Junio C HamanoMar 9, 2012
  26. demerphqMar 9, 2012
  27. Thomas RastMar 9, 2012
  28. Junio C HamanoMar 9, 2012
  29. Gelonida NMar 16, 2012
  30. Matthieu MoyMar 9, 2012
  31. push: start warning upcoming default change for push.defaultMatthieu Moy, Mar 9, 2012
  32. Junio C HamanoMar 9, 2012
  33. Junio C HamanoMar 9, 2012
  34. Carlos Martín NietoMar 9, 2012
  35. Marc BranchaudMar 9, 2012
  36. Stefan HallerMar 9, 2012
  37. Junio C HamanoMar 10, 2012
  38. Stefan HallerMar 11, 2012
  39. Matthieu MoyMar 12, 2012
  40. Stefan HallerMar 12, 2012
  41. Matthieu MoyMar 12, 2012
  42. Junio C HamanoMar 12, 2012
  43. Marc BranchaudMar 12, 2012
  44. Michael HaggertyMar 10, 2012
  45. Marc BranchaudMar 12, 2012
  46. Matthieu MoyMar 12, 2012
  47. Junio C HamanoMar 12, 2012
  48. Jeff KingMar 12, 2012
  49. Junio C HamanoMar 12, 2012
  50. Junio C HamanoMar 12, 2012
  51. Marc BranchaudMar 12, 2012
  52. Matthieu MoyMar 13, 2012
  53. Matthieu MoyMar 13, 2012
  54. Jeff KingMar 13, 2012
  55. Junio C HamanoMar 13, 2012
  56. Jeff KingMar 14, 2012
  57. Junio C HamanoMar 14, 2012
  58. Matthieu MoyMar 13, 2012
  59. Junio C HamanoMar 13, 2012
  60. Matthieu MoyMar 13, 2012
  61. Stefan HallerMar 13, 2012
  62. Matthieu MoyMar 14, 2012
  63. Marc BranchaudMar 13, 2012
  64. Holger HellmuthMar 13, 2012
  65. Junio C HamanoMar 13, 2012
  66. Holger HellmuthMar 14, 2012
  67. Matthieu MoyMar 15, 2012
  68. Holger HellmuthMar 15, 2012
  69. Andreas EricssonMar 13, 2012
  70. Jeff KingMar 13, 2012
  71. Dmitry PotapovMar 13, 2012
  72. Junio C HamanoMar 14, 2012
  73. Dmitry PotapovMar 14, 2012
  74. Junio C HamanoMar 14, 2012
  75. Dmitry PotapovMar 14, 2012
  76. Junio C HamanoMar 14, 2012
  77. Matthieu MoyMar 14, 2012
  78. Dmitry PotapovMar 14, 2012
  79. Matthieu MoyMar 14, 2012
  80. Dmitry PotapovMar 14, 2012
  81. Matthieu MoyMar 15, 2012
  82. Michael HaggertyMar 14, 2012
  83. Jeff KingMar 14, 2012
  84. Ævar Arnfjörð BjarmasonMar 9, 2012
  85. Clemens BuchacherMar 16, 2012
  86. Matthieu MoyMar 16, 2012
  87. Junio C HamanoMar 16, 2012
  88. Matthieu MoyMar 16, 2012
  89. Clemens BuchacherMar 16, 2012
  90. Matthieu MoyMar 17, 2012
  91. Andrew MyersMar 19, 2012
  92. Junio C HamanoMar 9, 2012
  93. Matthieu MoyMar 9, 2012
  94. Junio C HamanoMar 9, 2012
  95. Junio C HamanoMar 9, 2012
  96. Jakub NarebskiMar 9, 2012
  97. Junio C HamanoMar 9, 2012
  98. Jakub NarebskiMar 13, 2012
  99. Matthieu MoyMar 12, 2012
  100. Junio C HamanoMar 12, 2012
  101. Matthieu MoyMar 13, 2012
  102. Junio C HamanoMar 13, 2012
  103. Junio C HamanoMar 16, 2012
  104. Eric HanchrowMar 17, 2012
  105. Dmitry PotapovMar 8, 2012
  106. Jakub NarebskiMar 8, 2012
  107. Jeremy MortonMar 8, 2012
  108. Jakub NarebskiMar 13, 2012
  109. Jeremy MortonMar 14, 2012
  110. Jakub NarebskiMar 14, 2012
  111. Matthieu MoyMar 8, 2012
  112. demerphqMar 8, 2012
  113. Sebastien DoucheMar 17, 2012
  114. Jeremy MortonMar 17, 2012
  115. Sebastien DoucheMar 17, 2012
  116. Pavel PospíšilMar 18, 2012

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.