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

Re: [PATCH v7 2/4] worktree: improve message when creating a new worktree

From
Thomas Gummerer <t.gummerer@gmail.com>
Date
Apr 23, 2018, 18:50 UTC
Message-ID
<20180423185008.GB25294@hank>
In-Reply-To
<CAPig+cQSgY3yqYtZwTCY7Mq1e66WczbV3vM7=KsKH4b7peDw+Q@mail.gmail.com>
On 04/23, Eric Sunshine wrote:
Show 36 quoted lines
> On Sun, Apr 15, 2018 at 4:29 PM, Thomas Gummerer <t.gummerer@gmail.com> wrote:
> > Currently 'git worktree add' produces output like the following:
> >
> >     Preparing ../foo (identifier foo)
> >     HEAD is now at 26da330922 <title>
> > [...]
> > Instead of this message, print a message that gives the user a bit more
> > detail of what exactly 'git worktree' is doing.  There are various dwim
> > modes which are perform some magic under the hood, which should be
> > helpful to users.  Just from the output of the command it is not always
> > visible to users what exactly has happened.
> >
> > Help the users a bit more by modifying the "Preparing ..." message and
> > adding some additional information of what 'git worktree add' did under
> > the hood, while not displaying the identifier anymore.
> >
> > Currently this ends up in three different cases:
> >
> >   - 'git worktree add -b ...' or 'git worktree add <path>' [...]
> >
> >   - 'git worktree add -B ...', which may either create a new branch if
> >     the branch with the given name does not exist yet, or resets an
> >     existing branch to the current HEAD, or the commit-ish given.
> >     Depending on which action is taken, we'll end up with the following
> >     output:
> >
> >       Preparing worktree (resetting branch 'next' (was at caa68db14))
> >       HEAD is now at 26da330922 <title>
> 
> The (...) embedded inside another (...) is ugly and hard to read.
> Better perhaps:
> 
>     Preparing worktree (resetting branch 'next'; was at caa68db14)
> 
> Not necessarily worth a re-roll. It would be nice to see this series
> land; perhaps this can be tweaked later.
I'll tweak it while fixing the other bit.
Show 14 quoted lines
> >     or:
> >
> >       Preparing worktree (new branch '<branch>')
> >       HEAD is now at 26da330922 <title>
> >
> >   - 'git worktree add --detach' or 'git worktree add <path> <branch>',
> >     both of which create a new worktree with a detached HEAD, for which
> >     we will print the following output:
> >
> >       Preparing worktree (detached HEAD 26da330922)
> >       HEAD is now at 26da330922 <title>
> 
> This is inaccurate, isn't it? Certainly, specifying something like
> "origin/floop" for <branch> ends up detached:

Ah indeed, this was the case I missed. I thought I managed to go through all of them, but this one slipped through the cracks. Thanks for catching this, will fix in a re-roll.

Show 24 quoted lines
>     % git worktree add w1 origin/floop
>     ...
>     % git worktree list
>     /proj     fe0a9eaf31 [master]
>     /proj/w1  b46fe60e1d (detached HEAD)
> 
> but specifying an existing local branch (say "wip") does not end up detached:
> 
>     % git worktree add w2 wip
>     ...
>     % git worktree list
>     /proj     fe0a9eaf31 [master]
>     /proj/w1  b46fe60e1d (detached HEAD)
>     /proj/w2  820ed2a513 [wip]
> 
> > Additionally currently the "Preparing ..." line is printed to stderr,
> > while the "HEAD is now at ..." line is printed to stdout by 'git reset
> > --hard', which is used internally by 'git worktree add'.  Fix this
> > inconsistency by printing the "Preparing ..." message to stdout as
> > well.  As "Preparing ..." is not an error, stdout also seems like the
> > more appropriate output stream.
> >
> > Helped-by: Eric Sunshine <sunshine@sunshineco.com>
> > Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Previous: Eric SunshineNext: Thomas Gummerer
Message 93 of 112 in “worktree: teach "add" to check out existing branches”
  1. worktree: teach "add" to check out existing branchesThomas Gummerer, Jan 21, 2018
  2. Robert P. J. DayJan 21, 2018
  3. Duy NguyenJan 22, 2018
  4. Thomas GummererJan 22, 2018
  5. 0/3 worktree: teach "add" to check out existing branchesThomas Gummerer, Feb 4, 2018
  6. 1/3 worktree: improve message when creating a new worktreeThomas Gummerer, Feb 4, 2018
  7. Duy NguyenFeb 5, 2018
  8. Thomas GummererFeb 5, 2018
  9. Junio C HamanoFeb 5, 2018
  10. Eric SunshineFeb 7, 2018
  11. Thomas GummererFeb 9, 2018
  12. Duy NguyenFeb 9, 2018
  13. Duy NguyenFeb 10, 2018
  14. 2/3 worktree: be clearer when "add" dwim-ery kicks inThomas Gummerer, Feb 4, 2018
  15. 3/3 worktree: teach "add" to check out existing branchesThomas Gummerer, Feb 4, 2018
  16. Duy NguyenFeb 5, 2018
  17. Junio C HamanoFeb 5, 2018
  18. Thomas GummererFeb 5, 2018
  19. Duy NguyenFeb 6, 2018
  20. Thomas GummererFeb 9, 2018
  21. 0/4 worktree: teach "add" to check out existing branchesThomas Gummerer, Mar 17, 2018
  22. 1/4 worktree: improve message when creating a new worktreeThomas Gummerer, Mar 17, 2018
  23. 2/4 worktree: be clearer when "add" dwim-ery kicks inThomas Gummerer, Mar 17, 2018
  24. 3/4 worktree: factor out dwim_branch functionThomas Gummerer, Mar 17, 2018
  25. 4/4 worktree: teach "add" to check out existing branchesThomas Gummerer, Mar 17, 2018
  26. 0/4 worktree: teach "add" to check out existing branchesThomas Gummerer, Mar 17, 2018
  27. 1/4 worktree: improve message when creating a new worktreeThomas Gummerer, Mar 17, 2018
  28. Duy NguyenMar 19, 2018
  29. Junio C HamanoMar 19, 2018
  30. Eric SunshineMar 20, 2018
  31. Thomas GummererMar 24, 2018
  32. 3/4 worktree: factor out dwim_branch functionThomas Gummerer, Mar 17, 2018
  33. 2/4 worktree: be clearer when "add" dwim-ery kicks inThomas Gummerer, Mar 17, 2018
  34. Eric SunshineMar 20, 2018
  35. Eric SunshineMar 20, 2018
  36. Eric SunshineMar 20, 2018
  37. Thomas GummererMar 24, 2018
  38. 4/4 worktree: teach "add" to check out existing branchesThomas Gummerer, Mar 17, 2018
  39. Eric SunshineMar 20, 2018
  40. Thomas GummererMar 24, 2018
  41. 0/6 worktree: teach "add" to check out existing branchesThomas Gummerer, Mar 25, 2018
  42. 1/6 worktree: improve message when creating a new worktreeThomas Gummerer, Mar 25, 2018
  43. 2/6 worktree: be clearer when "add" dwim-ery kicks inThomas Gummerer, Mar 25, 2018
  44. Eric SunshineMar 27, 2018
  45. Thomas GummererMar 30, 2018
  46. 3/6 worktree: remove force_new_branch from struct add_optsThomas Gummerer, Mar 25, 2018
  47. Eric SunshineMar 27, 2018
  48. Thomas GummererMar 30, 2018
  49. 4/6 worktree: factor out dwim_branch functionThomas Gummerer, Mar 25, 2018
  50. Eric SunshineMar 27, 2018
  51. 5/6 worktree: teach "add" to check out existing branchesThomas Gummerer, Mar 25, 2018
  52. Eric SunshineMar 27, 2018
  53. Thomas GummererMar 30, 2018
  54. 6/6 t2025: rename now outdated branch nameThomas Gummerer, Mar 25, 2018
  55. Eric SunshineMar 27, 2018
  56. Thomas GummererMar 30, 2018
  57. 0/6 worktree: teach "add" to check out existing branchesThomas Gummerer, Mar 31, 2018
  58. 1/6 worktree: remove extra members from struct add_optsThomas Gummerer, Mar 31, 2018
  59. 3/6 worktree: improve message when creating a new worktreeThomas Gummerer, Mar 31, 2018
  60. Eric SunshineApr 8, 2018
  61. 2/6 reset: introduce show-new-head-line optionThomas Gummerer, Mar 31, 2018
  62. Junio C HamanoApr 2, 2018
  63. Thomas GummererApr 2, 2018
  64. Thomas GummererApr 2, 2018
  65. Junio C HamanoApr 2, 2018
  66. Thomas GummererApr 2, 2018
  67. 6/6 worktree: teach "add" to check out existing branchesThomas Gummerer, Mar 31, 2018
  68. 5/6 fixup! worktree: teach "add" to check out existing branchesThomas Gummerer, Apr 1, 2018
  69. Eric SunshineApr 9, 2018
  70. Thomas GummererApr 9, 2018
  71. Eric SunshineApr 9, 2018
  72. Eric SunshineApr 8, 2018
  73. Thomas GummererApr 8, 2018
  74. 4/6 worktree: be clearer when "add" dwim-ery kicks inThomas Gummerer, Mar 31, 2018
  75. 5/6 worktree: factor out dwim_branch functionThomas Gummerer, Mar 31, 2018
  76. Eric SunshineApr 8, 2018
  77. Thomas GummererApr 8, 2018
  78. Eric SunshineApr 9, 2018
  79. Thomas GummererApr 9, 2018
  80. Thomas GummererApr 9, 2018
  81. Eric SunshineApr 9, 2018
  82. Thomas GummererApr 11, 2018
  83. Eric SunshineApr 11, 2018
  84. Thomas GummererApr 11, 2018
  85. Eric SunshineApr 11, 2018
  86. 0/4 worktree: teach "add" to check out existing branchesThomas Gummerer, Apr 15, 2018
  87. 1/4 worktree: remove extra members from struct add_optsThomas Gummerer, Apr 15, 2018
  88. 3/4 worktree: factor out dwim_branch functionThomas Gummerer, Apr 15, 2018
  89. 2/4 worktree: improve message when creating a new worktreeThomas Gummerer, Apr 15, 2018
  90. Junio C HamanoApr 16, 2018
  91. Thomas GummererApr 23, 2018
  92. Eric SunshineApr 23, 2018
  93. Thomas GummererApr 23, 2018
  94. 4/4 worktree: teach "add" to check out existing branchesThomas Gummerer, Apr 15, 2018
  95. Eric SunshineApr 23, 2018
  96. 0/4 worktree: teach "add" to check out existing branchesThomas Gummerer, Apr 23, 2018
  97. 1/4 worktree: remove extra members from struct add_optsThomas Gummerer, Apr 23, 2018
  98. Eric SunshineApr 24, 2018
  99. 2/4 worktree: improve message when creating a new worktreeThomas Gummerer, Apr 23, 2018
  100. Eric SunshineApr 24, 2018
  101. 3/4 worktree: factor out dwim_branch functionThomas Gummerer, Apr 23, 2018
  102. 4/4 worktree: teach "add" to check out existing branchesThomas Gummerer, Apr 23, 2018
  103. Eric SunshineApr 24, 2018
  104. 0/4 worktree: teach "add" to check out existing branchesThomas Gummerer, Apr 24, 2018
  105. 1/4 worktree: remove extra members from struct add_optsThomas Gummerer, Apr 24, 2018
  106. 2/4 worktree: improve message when creating a new worktreeThomas Gummerer, Apr 24, 2018
  107. 3/4 worktree: factor out dwim_branch functionThomas Gummerer, Apr 24, 2018
  108. 4/4 worktree: teach "add" to check out existing branchesThomas Gummerer, Apr 24, 2018
  109. Eric SunshineApr 27, 2018
  110. Thomas GummererApr 28, 2018
  111. Junio C HamanoApr 30, 2018
  112. Junio C HamanoMar 18, 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.