git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergio Callegari <sergio.callegari@gmail.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Jeff King <peff@peff.net>, git@vger.kernel.org
Subject: Re: disallowing push to currently checked-out branch
Date: Tue, 17 Feb 2009 01:07:42 +0100	[thread overview]
Message-ID: <4999FFCE.3060605@gmail.com> (raw)
In-Reply-To: <alpine.DEB.1.00.0902162103580.6289@intel-tinevez-2-302>

Johannes Schindelin wrote:
> What you are suggesting, though, is that the _pusher_ detaches the HEAD.  
> So the _local_ user will never know.
>
>   
I am not sure that I get what you mean.  But if I get it right, 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.
Otherwise the local user would find out that a push happened behind his 
shoulder right at the first "status" or "commit", as he was expecting to 
be on a branch and he finds himself off it.
>> 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, and it becomes the tip of 
a short-lived development burst... It is not anymore just a way to peek 
at some status as I remember it was initially introduced, is it?
>>>> Furthermore, one could do just a bit more than detaching, namely 
>>>> store the fact that head got detached and the name of the branch 
>>>> where the head was. With this, when the unconscious user types git 
>>>> status or git commit the system could alert him that head got 
>>>> detached because someone updated the branch behind his shoulders 
>>>> from remote...
>>>>         
>>> And of course, you need a way to show the user all the updates the branch
>>> went through while the HEAD was detached, so that the user has a chance of
>>> understanding what happened in the meantime.
>>>
>>> So much additional work, just to fix up the shortcomings of the 
>>> 'detach' paradigm?  I take it as a clear mark of a not-so-elegant 
>>> design.
>>>       
>>   
>> Well not that much additional work...
>>
>> when you push to the checked out branch, head gets detached and branch name
>> (say /ref/heads/master) gets stored (say in .git/pre_push_branch).
>> when you run status or commit, you realize that there is a pre_push_branch and
>> you give the warning, saying what the pre_push_branch was.
>>     
>
> 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...
Which I guess is what the local user should want. He expected to be at 
some commit at the tip of some branch and he needs to find out what has 
happened between that commit and the new tip of that branch. Does he 
really need to know in how many and what precise push operations the 
branch tip moved?

>> 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?
>
>   
>> 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.

Which brings me back to my former consideration.

I initially thought of detaching head because it looks like a way to 
save a bit of info that I would like to see preserved.  When someone 
pushes in my repo, if my current branch tip moves, at the first action 
that I attempt on the repo I would like to see a big alert that it did 
and have an easy way to find out at what commit I was before the push 
happened.  Otherwise, I cannot really find out what the push precisely 
changed, I cannot easily revert it if it was wrong, etc.

Sergio

  parent reply	other threads:[~2009-02-17  0:09 UTC|newest]

Thread overview: 91+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-15 21:31 [RFC - draft] List of proposed future changes that are backward incompatible Junio C Hamano
2009-02-15 21:48 ` Junio C Hamano
2009-02-15 22:56   ` Jakub Narebski
2009-02-15 23:39     ` Junio C Hamano
2009-02-15 23:20 ` Heikki Orsila
2009-02-16  0:04   ` disallowing push to currently checked-out branch Jeff King
2009-02-16  1:33     ` david
2009-02-16  1:47       ` david
2009-02-16  1:30         ` Julian Phillips
2009-02-16  4:01         ` Jeff King
2009-02-16  8:33         ` Daniel Barkalow
2009-02-16  8:51           ` Junio C Hamano
2009-02-16 10:17             ` Sergio Callegari
2009-02-16 13:58               ` Jeff King
2009-02-16 17:13                 ` Sergio Callegari
2009-02-16 17:33                   ` Matthieu Moy
2009-02-16 17:43                   ` Johannes Schindelin
2009-02-16 18:48                     ` Jay Soffian
2009-02-16 20:02                       ` Johannes Schindelin
2009-02-16 21:12                         ` Jay Soffian
2009-02-16 21:15                           ` Johannes Schindelin
2009-02-16 22:28                             ` Jay Soffian
2009-02-16 22:52                               ` Jeff King
2009-02-17  5:53                                 ` Jay Soffian
2009-02-17 11:28                                   ` PUSH_HEAD, was " Johannes Schindelin
2009-02-17 17:29                                     ` Jay Soffian
2009-02-17 19:48                                       ` Jeff King
2009-02-17 22:20                                       ` Junio C Hamano
2009-02-17 22:42                                         ` Jay Soffian
2009-02-17 22:54                                       ` Johannes Schindelin
2009-02-16 19:24                     ` Sergio Callegari
2009-02-16 20:09                       ` Johannes Schindelin
2009-02-16 21:42                         ` Jay Soffian
2009-02-17  0:07                         ` Sergio Callegari [this message]
2009-02-17  0:18                           ` Johannes Schindelin
2009-02-17  0:41                             ` Sergio Callegari
2009-02-17  0:56                               ` Johannes Schindelin
2009-02-17  1:18                                 ` Junio C Hamano
2009-02-17  0:57                               ` Junio C Hamano
2009-02-16 21:43                       ` Junio C Hamano
2009-02-16 22:43                         ` Jeff King
2009-02-16 23:23                           ` Junio C Hamano
2009-02-17  0:23                             ` Jeff King
2009-02-17  0:43                               ` Junio C Hamano
2009-02-17  1:29                                 ` Jeff King
2009-02-16  3:50       ` Jeff King
2009-02-16  5:05         ` david
2009-02-16  4:05           ` Jeff King
2009-02-16  5:18             ` david
2009-02-16  4:37               ` Jeff King
2009-02-16  5:55                 ` david
2009-02-16  5:06                   ` Jeff King
2009-02-16 10:53                     ` Johannes Schindelin
2009-02-16 10:50                   ` dashed commands, was " Johannes Schindelin
2009-02-15 23:53 ` [RFC - draft] List of proposed future changes that are backward incompatible david
2009-02-15 23:01   ` Johannes Schindelin
2009-02-15 23:36     ` Junio C Hamano
2009-02-16  0:14     ` david
2009-02-15 23:18       ` Johannes Schindelin
2009-02-16  0:38         ` david
2009-02-16  0:29           ` Junio C Hamano
2009-02-16 10:23           ` Johannes Schindelin
2009-02-16 15:33             ` david
2009-02-16 14:40               ` Sverre Rabbelier
2009-02-16  0:02       ` disallowing push to currently checked-out branch Jeff King
2009-02-16 10:06         ` Sergio Callegari
2009-02-15 23:01   ` [RFC - draft] List of proposed future changes that are backward incompatible Jakub Narebski
2009-02-15 23:15     ` Johannes Schindelin
2009-02-15 23:38       ` Jakub Narebski
2009-02-16  0:35       ` david
2009-02-16  0:07   ` send-email sending shallow threads by default Jeff King
2009-02-16  0:09     ` Pieter de Bie
2009-02-16  2:43       ` Jeff King
2009-02-16  2:55         ` Brian Gernhardt
2009-02-16  9:56         ` Wincent Colaiuta
2009-02-16  7:55     ` SZEDER Gábor
2009-02-16 10:38     ` Martin Mares
2009-02-17  8:34       ` Andreas Ericsson
2009-02-17  9:06         ` Martin Mares
2009-02-17 19:28           ` Jeff King
2009-02-20  3:03             ` Eric W. Biederman
2009-02-20  3:26               ` Jeff King
2009-02-20  4:13                 ` Eric W. Biederman
2009-02-17  8:30     ` Andreas Ericsson
2009-02-16  1:27   ` [RFC - draft] List of proposed future changes that are backward incompatible Sitaram Chamarty
2009-02-16  8:04   ` Björn Steinbrink
2009-02-16  8:49     ` Junio C Hamano
2009-02-16  9:07       ` Björn Steinbrink
2009-02-16  2:42 ` [RFC - draft #2] " Junio C Hamano
2009-02-16  3:20   ` Jeff King
2009-02-16 21:10   ` Jakub Narebski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4999FFCE.3060605@gmail.com \
    --to=sergio.callegari@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).