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

Re: more novice-friendly behaviour of `git add -p`

From
Junio C Hamano <gitster@pobox.com>
Date
May 20, 2016, 15:05 UTC
Message-ID
<xmqq7feohirb.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<loom.20160520T150517-391@post.gmane.org>
enrico <enrico.guiraud@gmail.com> writes:
Show 7 quoted lines
> Hello all,
> I have encountered a couple of non-necessary difficulties when editing a
> patch during a `git add -p`.
>
> Firstly, the help message says
> "To remove '-' lines, make them ' ' lines (context)."
> which is a bit confusing because that "them" refers to '-', not to 'lines'.
I think that sentence refers to a line line this in a patch:
    -This is what the line used to be

as a '-'-line. A line that does not change between preimage and postimage have SP instead of '-' at the beginning, and the sentence seems to refer to it as a ' '-line. So from that reading, "turning '-'-lines that you do not want to loes into ' '-lines" is perfectly sensible phrasing.

In any case, "edit" is about giving a low-level access and precise control to people who are familiar with (1) what each line of "diff" output means and (2) what is done to them by "patch" (rather, in Git's context, "apply").

I agree with you that "edit" mode is a too-advanced tool for those who are not comfortable with these two things. A solution would however not be to modify "edit" mode (which would affect those who are prepared to and want to use the "low-level access and precise control" to their advantage), but to introduce an easier-to-use, and perhaps a bit limited for safety, mode for those who are not the target audience for "edit" mode.

The "split" subcommand to split the hunk before applying was an attempt to go in that direction; it never allows you the user to make an arbitrary change to corrupt the patch and make it unusable. Perhaps you can mimick its spirit and come up with a new "guarded edit" command?

Previous: enricoNext: enrico
Message 2 of 3 in “more novice-friendly behaviour of `git add -p`”
  1. enricoMay 20, 2016
  2. Junio C HamanoMay 20, 2016
  3. enricoMay 20, 2016

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.