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

Re: [PATCH] git-add: introduce --edit (to edit the diff vs. the index)

From
Ping Yin <pkufranky@gmail.com>
Date
Apr 11, 2009, 01:11 UTC
Message-ID
<46dff0320904101811g3b5dcc8ag195d40005b181c52@mail.gmail.com>
In-Reply-To
<alpine.DEB.1.00.0904102009440.10279@pacific.mpi-cbg.de>

On Sat, Apr 11, 2009 at 2:10 AM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

Show 43 quoted lines
> Hi,
>
> On Fri, 10 Apr 2009, Ping Yin wrote:
>
>> On Thu, Apr 9, 2009 at 10:00 AM, Ping Yin <pkufranky@gmail.com> wrote:
>> > On Thu, Apr 9, 2009 at 5:30 AM, Johannes Schindelin
>> > <johannes.schindelin@gmx.de> wrote:
>> >> With "git add -e [<files>]", Git will fire up an editor with the current
>> >> diff relative to the index (i.e. what you would get with "git diff
>> >> [<files>]").
>> >>
>> >> Now you can edit the patch as much as you like, including adding/removing
>> >> lines, editing the text, whatever.  Make sure, though, that the first
>> >> character of the hunk lines is still a space, a plus or a minus.
>> >>
>> >> After you closed the editor, Git will adjust the line counts of the hunks
>> >> if necessary, thanks to the --recount option of apply, and commit the
>> >> patch.  Except if you deleted everything, in which case nothing happens
>> >> (for obvious reasons).
>> >>
>> >> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
>> >> ---
>> >>
>> >>        I actually promised myself not to resend this patch, but a
>> >>        certain guy who has a hat now asked for it.
>> >>
>> >
>> > I am that guy :-). Thanks. Sometimes "add -e" is more useful than "add
>> > -p" since i can see the full context when editing the patch. However,
>> > sometimes the ability to edit the index directly is even more useful.
>> > For example, if it's a big change (or rewritten), it is hard to edit
>> > the patch instead of the index (in diff mode with the worktree file
>> > side by side). I even encounter a case that i can't beat the patch
>> > into a shape i want when using 'add -p'  ( it will fail to apply)
>> >
>>
>> How about this?
>>  'add --edit=patch' to edit the patch and "add --edit=index" to edit the index
>
> As others have mentioned, there _is_ a reason we have a working directory.
> Please understand this as a "I do not like the idea of editing the index
> directly at all".
>

When doing "add --edit" to edit the patch, do you work on the working directory? I think they are just different ways to change the index?

Previous: Sverre RabbelierNext: Johannes Schindelin
Message 10 of 11 in “git-add: introduce --edit (to edit the diff vs. the index)”
  1. git-add: introduce --edit (to edit the diff vs. the index)Johannes Schindelin, Apr 8, 2009
  2. Sverre RabbelierApr 8, 2009
  3. Ping YinApr 9, 2009
  4. Ping YinApr 10, 2009
  5. Ping YinApr 10, 2009
  6. Johannes SchindelinApr 10, 2009
  7. Sverre RabbelierApr 10, 2009
  8. Johannes SchindelinApr 13, 2009
  9. Sverre RabbelierApr 13, 2009
  10. Ping YinApr 11, 2009
  11. Johannes SchindelinApr 13, 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.