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

Re: [PATCH] add-interactive: shortcut to add hunk and quit

From
Jeff King <peff@peff.net>
Date
May 19, 2011, 11:02 UTC
Message-ID
<20110519110259.GA11507@sigill.intra.peff.net>
In-Reply-To
<201105191216.51709.trast@student.ethz.ch>
On Thu, May 19, 2011 at 12:16:51PM +0200, Thomas Rast wrote:
Show 8 quoted lines
> Junio C Hamano wrote:
> > 
> > I think "single-key" was a poorly designed attempt to improve productivity
> > the ("y" <RET>)*5 into "y"*5
> 
> Actually for me it more often is
> 
>   y RET n RET *think* y RET s RET n RET ...

Yeah. I personally find the concept of "5y" crazy; how do you know that it is 5, and not 4 or 6, if you haven't yet seen them?

But that just means I don't have any use for it; I don't have a real objection to it.

> After my little accident I'm also considering an (optional?) safety
> question at the end when in checkout -p mode, since it's inherently
> destructive.  Of course that first requires changing the whole
> operation to be atomic.

I think a confirmation question is a bad idea. It helps with fat-fingering, but not much else. 99% of the time you will say "yes", because of course you just looked through the changes and want to finalize them. So you will start to hit "y" without looking or thinking, and it becomes a mere annoyance, until the time you _do_ actually lose some data by hitting "y" without thinking.

At least that's what would happen to me. :)

I think a much better safety valve is to store the user's worktree state that we are about to destroy. Then when they accidentally erase something, whether they realize it immediately, or even 5 minutes later, it is recoverable. And in the common case where everything goes well, they needn't be bothered at all.

This fits much better with other git recovery mechanisms, too, which tend to be one of:

  1. Store the previous state, and optionally instruct the user on how
     to recover in the case of error (e.g., reflogs, the new orphan
     checkout warning).
  2. Force the user to give confirmation (e.g., "branch -D"), but _only_
     if we have detected some abnormally dangerous situation (e.g., you
     are deleting a branch that hasn't been merged anywhere). The user
     is more likely to pay attention and think about the confirmation
     because we _don't_ ask every time, and because we are giving them
     additional information that will help in making the decision.
-Peff
Previous: Thomas RastNext: Junio C Hamano
Message 12 of 15 in “add-interactive: shortcut for add hunk and quit”
  1. add-interactive: shortcut for add hunk and quitHermann Gausterer, May 15, 2011
  2. Junio C HamanoMay 15, 2011
  3. add-interactive: shortcut to add hunk and quitHermann Gausterer, May 16, 2011
  4. Matthieu MoyMay 16, 2011
  5. Junio C HamanoMay 17, 2011
  6. add-interactive: shortcut to add hunk and quitHermann Gausterer, May 17, 2011
  7. Pete HarlanMay 18, 2011
  8. Jeff KingMay 18, 2011
  9. Michael J GruberMay 18, 2011
  10. Junio C HamanoMay 18, 2011
  11. Thomas RastMay 19, 2011
  12. Jeff KingMay 19, 2011
  13. Junio C HamanoMay 19, 2011
  14. Jeff KingMay 19, 2011
  15. Hermann GaustererMay 18, 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.