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

Re: What's cooking in git.git (Feb 2011, #06; Sun, 27)

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 28, 2011, 16:52 UTC
Message-ID
<7v7hckje4n.fsf@alter.siamese.dyndns.org>
In-Reply-To
<AANLkTikW1GVzFoq=zUxvi7MTcUYBLO6fbjJPVZziLUk8@mail.gmail.com>
Sverre Rabbelier <srabbelier@gmail.com> writes:
Show 10 quoted lines
> Heya,
>
> On Mon, Feb 28, 2011 at 07:48, Junio C Hamano <gitster@pobox.com> wrote:
>> * jc/checkout-orphan-warning (2011-02-18) 1 commit
>>  - commit: give final warning when reattaching HEAD to leave commits behind
>>
>> Likes, dislikes?
>
> I can't find a message containing this commit title, can you link to
> the relevant thread?
This is a re-roll of a fallout from this thread:
    http://thread.gmane.org/gmane.comp.version-control.git/166595/focus=167133

I do think the safety net for detached HEAD is a bit too flimsy, and that is the motivation behind this.

As I don't think it is necessarily a good idea to attempt to make every possible operation revertible (e.g., I do not think "oops, I did 'git add' and I have only "git lost-and-found" to find the old index entry" is a problem worth solving with extra complexity and storage cost), we should strike a good balance by adding safety only at key places in reasonable workflows (as opposed to every step to clutter the "undo log").

I am not convinced that this patch nailed that balance at exactly the right place, even though I think we are getting closer than before. In this sequence:

    $ git checkout somewhere^0
    $ git commit
    $ git reset --hard somewhere_else
    $ git commit
    $ git checkout master

The second commit is protected with the patch, but not the first one, which is still protected by the reflog on HEAD (i.e. "git log -g HEAD"). You have to know the reflog on HEAD if you _intend to_ work on detached HEAD anyway, and you don't need this patch if you do---the second commit can also be recovered from the reflog on HEAD.

So this patch is not about helping people who _chose to_ work on detached HEAD; instead the patch in its current form is about helping sightseers who has become _only_ a bit adventurous. To help people who accidentally started from a detached state (i.e. starting from sightseeing but then got very adventurous, forgetting that they are not on any branch) and spent significant amount of time committing and resetting, the advice message should teach them to use "log -g HEAD" more explicitly, instead of giving details of the last state (i.e. "you are leaving %n commits behind...").

Previous: Sverre RabbelierNext: Jeff King
Message 3 of 12 in “What's cooking in git.git (Feb 2011, #06; Sun, 27)”
  1. Junio C HamanoFeb 28, 2011
  2. Sverre RabbelierFeb 28, 2011
  3. Junio C HamanoFeb 28, 2011
  4. Jeff KingMar 1, 2011
  5. Junio C HamanoMar 2, 2011
  6. Jeff KingMar 2, 2011
  7. Junio C HamanoMar 2, 2011
  8. Piotr KrukowieckiMar 2, 2011
  9. Jakub NarebskiMar 2, 2011
  10. Ævar Arnfjörð BjarmasonMar 10, 2011
  11. Jakub NarebskiMar 10, 2011
  12. Jeff KingMar 2, 2011

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.