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

Re: [PATCH/RFC] builtin-checkout: suggest creating local branch when appropriate to do so

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 13, 2009, 21:59 UTC
Message-ID
<7vaazvt0pk.fsf@alter.siamese.dyndns.org>
In-Reply-To
<alpine.DEB.1.00.0910132302380.4985@pacific.mpi-cbg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 11 quoted lines
> So in my opinion, we should DWIM "git checkout $X" to mean "git checkout 
> -b $X refs/remotes/$REMOTE/$X" when there is no ref $X, refs/heads/$X and 
> no other refs/remotes/$OTHER/$X.
>
> Likewise "git checkout $REMOTE/$X".
>
> But, in my opinion, if there is refs/heads/$X and refs/remotes/origin/$X, 
> and the user says "git checkout origin/$X", we should tell the user that 
> there are the options to checkout $X and origin/$X^0 (the latter only if 
> the user really intended to detach her HEAD), but not try to DWIM 
> anything.
I am somewhat unhappy with that kind of inconsistent DWIMery.

Naively I would agree that it would be nice if "git checkout origin/next" (or "next" when no other remotes/*/next exists) were DWIMmed as "git checkout -t -b next origin/next". But the way we _define_ that particular DWIMmery and the way it appears to an uninitiated would be different.

We define this DWIMmery as s|^(.*)/([^/]*)$|-t -b $2 $1/$2|; iow, when the user types "origin/next" and other coniditions hold, we pretend as if the user typed "-b next origin/next". But it would give an incorrect impression to an end user "Ah, when my upstream project has next branch, I can check it out with origin/next (or next)." But when the user wants to work further on 'next' by running "git checkout origin/next" the next day, we say "Uh oh, that is ambiguous and we won't DWIM," which is technically and implementation wise correct, but breaks the misconception the user formed with your earlier DWIMmery. I suspect that the user will be better off if we do not give a wrong impression in the first place. If any DWIMmery gave a conception different from the following four points, that DWIMmery is actively hurting the users:

 * You clone and get copies of where the other end has its branches;
 * You do all your work on your local branches;
 * You may incorporate what the other end further did by merging from the
   tracking branch from it;
 * You update the other end by pushing what you did on your local branches.
Now, the conclusion of the above embodied in the _current_ UI is:
 * To start your branch to build on what the other end did, you fork your
   local branch at the commit the other end left off, and make sure it builds
   on that tracking branch, with
        git checkout -t -b next origin/next
 * Since "-t -b $2 $1/$2" often appears as a pattern, you can say "-t $1/$2"
   and we DWIM as if you said "-t -b $2 $1/$2".

I do not think loosening the DWIMmery so that "$1/$2" is DWIMmed to the above would help users. If the current DWIM is not helping the users understand the first four points and instead encouraging an incorrect picture of how the world works, the new DWIMmery would be just as bad, if not worse.

> IMHO it is obvious that Hannes' suggestion to fast-forward $X and check it 
> out in said scenario has some benefits in certain situations, but dramatic 
> downsides in others.
Yes.
Show 7 quoted lines
> But I need to drive some very important point home in this thread: 1.7.0 
> was announced to break some old-time habits in favor of a better 
> user-interface.  We _need_ to use this opportunity fully.
>
> Even if that means that a few fingers have to be retrained.  Because 
> retraining a few for the benefit of an easier time with the many others 
> is Just Worth It.

Absolutely. My point is that this particular DWIMmery would _NOT_ be a better user interface. Not for 1.7.0, not for any other release. It would not help the users to form a clear world model git offers and that actively hurts them.

Previous: Johannes SchindelinNext: Jeff King
Message 68 of 91 in “builtin-checkout: suggest creating local branch when appropriate to do so”
  1. builtin-checkout: suggest creating local branch when appropriate to do soJay Soffian, Oct 5, 2009
  2. Sverre RabbelierOct 5, 2009
  3. Johannes SchindelinOct 5, 2009
  4. Sverre RabbelierOct 5, 2009
  5. Jay SoffianOct 5, 2009
  6. Jay SoffianOct 5, 2009
  7. Johannes SchindelinOct 5, 2009
  8. Jeff KingOct 5, 2009
  9. Thomas RastOct 6, 2009
  10. Johannes SchindelinOct 6, 2009
  11. Junio C HamanoOct 6, 2009
  12. Johannes SchindelinOct 6, 2009
  13. Junio C HamanoOct 6, 2009
  14. Johannes SchindelinOct 6, 2009
  15. Matthieu MoyOct 6, 2009
  16. Mikael MagnussonOct 6, 2009
  17. Johannes SchindelinOct 6, 2009
  18. Junio C HamanoOct 18, 2009
  19. 1/3 check_filename(): make verify_filename() callable without dyingJunio C Hamano, Oct 18, 2009
  20. 2/3 DWIM "git checkout frotz" to "git checkout -b frotz origin/frotz"Junio C Hamano, Oct 18, 2009
  21. Nanako ShiraishiOct 18, 2009
  22. Björn SteinbrinkOct 18, 2009
  23. Nanako ShiraishiOct 18, 2009
  24. Junio C HamanoOct 18, 2009
  25. Björn SteinbrinkOct 19, 2009
  26. 3/3 git checkout --nodwimJunio C Hamano, Oct 18, 2009
  27. Alex RiesenOct 18, 2009
  28. Junio C HamanoOct 18, 2009
  29. Use "--no-" prefix to switch off some of checkout dwimmeryAlex Riesen, Oct 18, 2009
  30. Junio C HamanoOct 18, 2009
  31. Alex RiesenOct 19, 2009
  32. Alex RiesenOct 19, 2009
  33. Junio C HamanoOct 19, 2009
  34. Alex RiesenOct 19, 2009
  35. Junio C HamanoOct 19, 2009
  36. Avery PennarunOct 21, 2009
  37. Nanako ShiraishiOct 21, 2009
  38. Junio C HamanoOct 21, 2009
  39. git checkout --no-guessJunio C Hamano, Oct 21, 2009
  40. Avery PennarunOct 21, 2009
  41. Jay SoffianOct 26, 2009
  42. Avery PennarunOct 26, 2009
  43. Johannes SchindelinOct 22, 2009
  44. Erik Faye-LundOct 22, 2009
  45. Michael J GruberOct 23, 2009
  46. Junio C HamanoOct 24, 2009
  47. David RoundyOct 24, 2009
  48. Junio C HamanoOct 24, 2009
  49. Johannes SchindelinOct 26, 2009
  50. Avery PennarunOct 26, 2009
  51. Jeff KingOct 26, 2009
  52. Avery PennarunOct 26, 2009
  53. Jeff KingOct 26, 2009
  54. Avery PennarunOct 26, 2009
  55. Jeff KingOct 5, 2009
  56. Eugene SajineOct 6, 2009
  57. Junio C HamanoOct 6, 2009
  58. Johannes SchindelinOct 12, 2009
  59. Björn SteinbrinkOct 12, 2009
  60. Thomas RastOct 12, 2009
  61. Junio C HamanoOct 12, 2009
  62. Thomas RastOct 13, 2009
  63. Junio C HamanoOct 13, 2009
  64. Junio C HamanoOct 13, 2009
  65. Thomas RastOct 13, 2009
  66. Junio C HamanoOct 13, 2009
  67. Johannes SchindelinOct 13, 2009
  68. Junio C HamanoOct 13, 2009
  69. Jeff KingOct 13, 2009
  70. Johannes SchindelinOct 13, 2009
  71. Jay SoffianOct 14, 2009
  72. Junio C HamanoOct 14, 2009
  73. Jay SoffianOct 14, 2009
  74. Junio C HamanoOct 14, 2009
  75. Uri OkrentOct 25, 2009
  76. Jeff KingOct 14, 2009
  77. Thomas RastOct 14, 2009
  78. Jakub NarebskiOct 14, 2009
  79. Johannes SixtOct 13, 2009
  80. Daniel BarkalowOct 13, 2009
  81. Junio C HamanoOct 13, 2009
  82. Daniel BarkalowOct 13, 2009
  83. Jeff KingOct 13, 2009
  84. Junio C HamanoOct 13, 2009
  85. Johannes SchindelinOct 13, 2009
  86. Thomas RastOct 14, 2009
  87. Johannes SchindelinOct 16, 2009
  88. Thomas RastOct 16, 2009
  89. Uri OkrentOct 25, 2009
  90. Junio C HamanoOct 26, 2009
  91. Björn SteinbrinkOct 13, 2009

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.