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

Re: [RFC PATCH] {checkout,reset} -p: make patch direction configurable

From
Jeff King <peff@peff.net>
Date
Nov 27, 2009, 06:41 UTC
Message-ID
<20091127064107.GC20844@coredump.intra.peff.net>
In-Reply-To
<527e9296b638eb4c9993b3fb0d1c6f51b64f4c2c.1258667920.git.trast@student.ethz.ch>
On Thu, Nov 19, 2009 at 11:03:57PM +0100, Thomas Rast wrote:
Show 14 quoted lines
> When we implemented the -p mode for checkout, reset and stash, some
> discussion revolved around the involved patch direction.
> 
> Make this configurable for reset and checkout with the following
> choices:
> 
>              index/HEAD       other
>   forward    undo addition    undo addition
>   mixed      undo addition    apply removal
>   reverse    apply removal    apply removal
> [...]
> ISTR that Peff wanted this, and maybe some others.  I'm not too
> interested because I'm still convinced 'mixed' is the Right Option,
> but it was somewhere deep on my todo stack and maybe you like it ;-)

Actually, I am pretty happy with the current "discard this hunk" most of the time. It is easy enough to see "you made this change, did you want to get rid of it?". The one exception is during patch editing. Try something simple like:

cat >file <<EOF this is a file with some content in it EOF

git add file git commit -m base

cat >file <<EOF this is a file with some other content EOF

git checkout -p

Now try to 'e'dit the patch to throw away the addition of "other", but keep the deletion of the other two lines. Do you find it easy or hard? Now try it with interactive.checkout.direction set to forward. I find editing the forward direction _much_ simpler.

Assuming you agree, I'm not sure what that tells us, though. I probably wouldn't personally set interactive.*.direction for the yes/no part. But I would find it more convenient to do patch editing always in the forward direction. I'm worried that it would be too jarring to the user, though, to see the patch presented in one direction but edit it in the opposite direction. Maybe it would be nice to have yet another interactive option to swap between the two for this particular hunk, and then you could edit the direction you prefer.

Junio raised the question of consistency in another thread. I don't see a consistency problem here. This is by definition an interactive procedure. I don't see a reason not to allow the user their preferred style. But I think if I could swap when editing, I would personally not care all that much about the other direction.

-Peff
Previous: Štěpán Němec
Message 3 of 3 in “{checkout,reset} -p: make patch direction configurable”
  1. {checkout,reset} -p: make patch direction configurableThomas Rast, Nov 19, 2009
  2. Štěpán NěmecNov 20, 2009
  3. Jeff KingNov 27, 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.