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

Re: disallowing push to currently checked-out branch

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Feb 17, 2009, 00:18 UTC
Message-ID
<alpine.DEB.1.00.0902170112580.10279@pacific.mpi-cbg.de>
In-Reply-To
<4999FFCE.3060605@gmail.com>
Hi,
On Tue, 17 Feb 2009, Sergio Callegari wrote:
Show 7 quoted lines
> Johannes Schindelin wrote:
>
> > What you are suggesting, though, is that the _pusher_ detaches the 
> > HEAD.  So the _local_ user will never know.
>
> the only reason why the local user cannot know is precisely because "git 
> commit" does not complain if you call it from a detached head.

No, the only reason is that you sneakily detached the HEAD behind his back. It is not possible in physical life -- at least not without the owner of the head noticing -- and it should not be possible with Git, either.

All this "we need more complaining" is just a fix up for a failed design.
Show 13 quoted lines
> > > Btw, I am ignorant on this: is there some case where one wants and 
> > > has reasons to commit to a detached head before making a temporary 
> > > branch on it?
> >
> > Yes.  When you try fixups on a commit you just jumped to, for example.  
> > Or when bisecting.
> >
> > I often use the detached HEAD as kind of a stash during a bisect.  I 
> > try to fix it there, at the bad commit, and then cherry-pick HEAD@{1} 
> > into the branch after resetting the bisect.
>
> Interesting.  But it is sort of abusing the detached head thing, isn't 
> it? You use it as a temporary unnamed branch,
That is exactly what a detached HEAD is.
Show 5 quoted lines
> > Of course, you assume there that it was only one push between 
> > detaching the HEAD and inspecting the mess.
>
> After the first push, the head is already detached, so pre_push_branch 
> does not get touched by the second, the third, the forth push, etc...

Oh, so the user should be really fscked for not realizing just how much happened in the meantime?

Show 6 quoted lines
> > > Now, since before the push you were at the tip of that branch, to 
> > > know what happened it should be enough to ask the log (or the diff) 
> > > from pre_push_branch to HEAD. At the first user command that moves 
> > > HEAD, pre_push_branch should get deleted.
>
> > And you call that not much work?

That point is still valid. If you have to do too much to make your idea work, if you have to bolt on this and that, it is a sure sign that the design is borked.

Show 7 quoted lines
> > > Btw, what does happen now if you delete the branch the remote 
> > > worktree is on?
>
> I tried.  With current git 1.6.1.3, head remains pointing at a non 
> existent branch and git status thinks that you need to do your initial 
> commit. When you commit, the deleted branch is immediately recreated 
> from scratch and you loose the history that got you at that status.
As I remarked already, this is a bug that is actively being squashed.

Of course, you can go on and on and on with the detached HEAD ide, but so far you haven't convinced me that this is a sensible thing to do.

Ciao, Dscho

Previous: Sergio CallegariNext: Sergio Callegari
Message 35 of 91 in “[RFC - draft] List of proposed future changes that are backward incompatible”
  1. Junio C HamanoFeb 15, 2009
  2. Junio C HamanoFeb 15, 2009
  3. Jakub NarebskiFeb 15, 2009
  4. Junio C HamanoFeb 15, 2009
  5. Heikki OrsilaFeb 15, 2009
  6. disallowing push to currently checked-out branchJeff King, Feb 16, 2009
  7. david@lang.hmFeb 16, 2009
  8. david@lang.hmFeb 16, 2009
  9. Julian PhillipsFeb 16, 2009
  10. Jeff KingFeb 16, 2009
  11. Daniel BarkalowFeb 16, 2009
  12. Junio C HamanoFeb 16, 2009
  13. Sergio CallegariFeb 16, 2009
  14. Jeff KingFeb 16, 2009
  15. Sergio CallegariFeb 16, 2009
  16. Matthieu MoyFeb 16, 2009
  17. Johannes SchindelinFeb 16, 2009
  18. Jay SoffianFeb 16, 2009
  19. Johannes SchindelinFeb 16, 2009
  20. Jay SoffianFeb 16, 2009
  21. Johannes SchindelinFeb 16, 2009
  22. Jay SoffianFeb 16, 2009
  23. Jeff KingFeb 16, 2009
  24. Jay SoffianFeb 17, 2009
  25. PUSH_HEAD, was Re: disallowing push to currently checked-out branchJohannes Schindelin, Feb 17, 2009
  26. Jay SoffianFeb 17, 2009
  27. Jeff KingFeb 17, 2009
  28. Junio C HamanoFeb 17, 2009
  29. Jay SoffianFeb 17, 2009
  30. Johannes SchindelinFeb 17, 2009
  31. Sergio CallegariFeb 16, 2009
  32. Johannes SchindelinFeb 16, 2009
  33. Jay SoffianFeb 16, 2009
  34. Sergio CallegariFeb 17, 2009
  35. Johannes SchindelinFeb 17, 2009
  36. Sergio CallegariFeb 17, 2009
  37. Johannes SchindelinFeb 17, 2009
  38. Junio C HamanoFeb 17, 2009
  39. Junio C HamanoFeb 17, 2009
  40. Junio C HamanoFeb 16, 2009
  41. Jeff KingFeb 16, 2009
  42. Junio C HamanoFeb 16, 2009
  43. Jeff KingFeb 17, 2009
  44. Junio C HamanoFeb 17, 2009
  45. Jeff KingFeb 17, 2009
  46. Jeff KingFeb 16, 2009
  47. david@lang.hmFeb 16, 2009
  48. Jeff KingFeb 16, 2009
  49. david@lang.hmFeb 16, 2009
  50. Jeff KingFeb 16, 2009
  51. david@lang.hmFeb 16, 2009
  52. Jeff KingFeb 16, 2009
  53. Johannes SchindelinFeb 16, 2009
  54. dashed commands, was Re: disallowing push to currently checked-out branchJohannes Schindelin, Feb 16, 2009
  55. david@lang.hmFeb 15, 2009
  56. Johannes SchindelinFeb 15, 2009
  57. Junio C HamanoFeb 15, 2009
  58. david@lang.hmFeb 16, 2009
  59. Johannes SchindelinFeb 15, 2009
  60. david@lang.hmFeb 16, 2009
  61. Junio C HamanoFeb 16, 2009
  62. Johannes SchindelinFeb 16, 2009
  63. david@lang.hmFeb 16, 2009
  64. Sverre RabbelierFeb 16, 2009
  65. disallowing push to currently checked-out branchJeff King, Feb 16, 2009
  66. Sergio CallegariFeb 16, 2009
  67. Jakub NarebskiFeb 15, 2009
  68. Johannes SchindelinFeb 15, 2009
  69. Jakub NarebskiFeb 15, 2009
  70. david@lang.hmFeb 16, 2009
  71. send-email sending shallow threads by defaultJeff King, Feb 16, 2009
  72. Pieter de BieFeb 16, 2009
  73. Jeff KingFeb 16, 2009
  74. Brian GernhardtFeb 16, 2009
  75. Wincent ColaiutaFeb 16, 2009
  76. SZEDER GáborFeb 16, 2009
  77. Martin MaresFeb 16, 2009
  78. Andreas EricssonFeb 17, 2009
  79. Martin MaresFeb 17, 2009
  80. Jeff KingFeb 17, 2009
  81. Eric W. BiedermanFeb 20, 2009
  82. Jeff KingFeb 20, 2009
  83. Eric W. BiedermanFeb 20, 2009
  84. Andreas EricssonFeb 17, 2009
  85. Sitaram ChamartyFeb 16, 2009
  86. Björn SteinbrinkFeb 16, 2009
  87. Junio C HamanoFeb 16, 2009
  88. Björn SteinbrinkFeb 16, 2009
  89. [RFC - draft #2] List of proposed future changes that are backward incompatibleJunio C Hamano, Feb 16, 2009
  90. Jeff KingFeb 16, 2009
  91. Jakub NarebskiFeb 16, 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.