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

Re: [PATCH v3] git-add--interactive: manual hunk editing mode

From
Johan Herland <johan@herland.net>
Date
Jun 9, 2008, 17:31 UTC
Message-ID
<200806091931.51221.johan@herland.net>
In-Reply-To
<20080609122938.GA12210@sigill.intra.peff.net>
On Monday 09 June 2008, Jeff King wrote:
Show 11 quoted lines
> On Mon, Jun 09, 2008 at 07:46:22AM +0200, Johan Herland wrote:
> > Is there a good reason against having *both*?
> >
> > AFAICS, there's nothing stopping us from having both a "-e"-option to
> > git-add, and an "e"-command inside git-add--interactive.
>
> I agree (and I tried to make that point in an earlier mail).
>
> And I was hoping the right way to do it was to simply build the
> interactive "e" command on top of Johannes' git-apply work. But I don't
> think that quite makes sense.
Yeah, the two approaches don't merge easily...
> His work is about fixing up the hunk header as we apply the patch, but a
> working "e" command in the hunk selection should probably not actually
> apply, but simply split into two hunks for the loop.

By "split into two hunks", you mean splitting the original "index -> worktree" hunk (#0) into one hunk that represents "index -> edited" (#1), and another hunk that represents "edited -> worktree" (#2)?

>From a technical POV this might make sense, but AFAICS, users would always 

want to answer 'y' to #1, and 'n' to #2 (see [1]), so from a user POV, git-add--interactive should simply stage #1, and drop #2.

(Side note: AFAIR, some of the original rationale for this feature was to provide a more fine-grained split than 's'. Looking at the problem from this POV: What is the reason for splitting a hunk in the first place? It must be because one part of the hunk should be staged while leaving the other unstaged. With 's', it just splits, and lets the user select which parts of the hunk to stage, using 'y'/'n'. But 'e' introduces a much more powerful notion of letting user split AND select in ONE operation (i.e. the editor). Therefore, when the user has already selected which parts of the hunk to stage (#1), it is not necessary to re-ask the user whether or not #1 should be staged (and certainly not #2).

Show 10 quoted lines
> > ("git-add -e" would open the entire diff in an editor, as would "e"
> > from the *main* menu of git-add--interactive. However, "e" from the
> > *single hunk* menu would of course open only that single hunk within
> > the editor. We could even have an "E" command to open all
> > remaining/undecided hunks in an editor.)
>
> I agree with all of this, though I think the big question is what
> happens to the edited portion. In the interactive command, I think it
> becomes a new hunk that can be staged or not. In "git add -e" it makes
> sense to simply stage the result.

Sounds acceptable to me (although I would also be ok with automatically staging the edited portion in the interactive command).

Have fun! :)
...Johan

[1]: AIUI #1 represents the hunk that the user want to stage at this moment. Conversely, #2 represents the changes that the user is NOT interested in staging at this point. Therefore, the only answers that make sense is 'y' (i.e. "stage this hunk") for #1 and 'n' (i.e. "do not stage this hunk") for #2. The only problem with this is if the user screwed up the hunk edit and wants to revert to the original hunk (#0). I don't know if this is worth supporting.

-- 
Johan Herland, <johan@herland.net>
www.herland.net
Previous: Junio C HamanoNext: Jeff King
Message 39 of 62 in “git-add--interactive: manual hunk editing mode”
  1. git-add--interactive: manual hunk editing modeThomas Rast, May 23, 2008
  2. Ping YinMay 24, 2008
  3. Thomas RastMay 29, 2008
  4. Johannes SchindelinMay 29, 2008
  5. Thomas RastMay 29, 2008
  6. Thomas RastMay 29, 2008
  7. Jeff KingMay 29, 2008
  8. Johannes SchindelinMay 30, 2008
  9. Jakub NarebskiMay 30, 2008
  10. Thomas RastMay 30, 2008
  11. Junio C HamanoMay 30, 2008
  12. git-add--interactive: manual hunk editing mode v2Thomas Rast, Jun 1, 2008
  13. Thomas RastJun 1, 2008
  14. Jeff KingJun 1, 2008
  15. Jeff KingJun 5, 2008
  16. Thomas RastJun 5, 2008
  17. Jeff KingJun 5, 2008
  18. Thomas RastJun 5, 2008
  19. Jeff KingJun 5, 2008
  20. Thomas RastJun 5, 2008
  21. Jeff KingJun 5, 2008
  22. Junio C HamanoJun 5, 2008
  23. Jeff KingJun 5, 2008
  24. Johannes SchindelinJun 5, 2008
  25. Jeff KingJun 6, 2008
  26. Jeff KingJun 6, 2008
  27. Thomas RastJun 8, 2008
  28. Johannes SchindelinJun 8, 2008
  29. Johannes SchindelinJun 6, 2008
  30. Thomas RastJun 8, 2008
  31. Johannes SchindelinJun 8, 2008
  32. git-add--interactive: manual hunk editing modeThomas Rast, Jun 5, 2008
  33. git-add--interactive: manual hunk editing modeThomas Rast, Jun 8, 2008
  34. Johannes SchindelinJun 8, 2008
  35. Johan HerlandJun 9, 2008
  36. Jeff KingJun 9, 2008
  37. Johannes SchindelinJun 9, 2008
  38. Junio C HamanoJun 9, 2008
  39. Johan HerlandJun 9, 2008
  40. Jeff KingJun 9, 2008
  41. Johan HerlandJun 9, 2008
  42. Jeff KingJun 10, 2008
  43. Thomas RastJun 11, 2008
  44. Jeff KingJun 12, 2008
  45. Thomas RastJun 12, 2008
  46. Jeff KingJun 12, 2008
  47. git-add--interactive: manual hunk editing modeThomas Rast, Jun 13, 2008
  48. Jeff KingJun 23, 2008
  49. Johannes SchindelinJun 23, 2008
  50. Jeff KingJun 23, 2008
  51. apply --recount, was Re: [PATCH v4] git-add--interactive: manual hunk editing modeJohannes Schindelin, Jun 23, 2008
  52. Jeff KingJun 24, 2008
  53. 0/3 Manual editing for 'add' and 'add -p'Thomas Rast, Jun 24, 2008
  54. Miklos VajnaJun 24, 2008
  55. 1/3 Allow git-apply to ignore the hunk headers (AKA recountdiff)Thomas Rast, Jun 24, 2008
  56. Junio C HamanoJun 24, 2008
  57. Jeff KingJun 25, 2008
  58. Johannes SchindelinJun 27, 2008
  59. 2/3 git-add: introduce --edit (to edit the diff vs. the index)Thomas Rast, Jun 24, 2008
  60. 3/3 git-add--interactive: manual hunk editing modeThomas Rast, Jun 24, 2008
  61. Andreas EricssonJun 10, 2008
  62. Thomas RastJun 5, 2008

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.