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

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

From
Thomas Rast <trast@student.ethz.ch>
Date
Jul 2, 2008, 09:03 UTC
Message-ID
<200807021103.56570.trast@student.ethz.ch>
[Wrong button at first, sorry for the double mail Junio]
Junio C Hamano wrote:
Show 5 quoted lines
> 
> If you change '-' to ' ', or remove '+', then you are temporarily
> reverting the change you have made since HEAD to your working tree copy.
> If you do not change anything, you are taking something that was in your
> working tree copy.  Both are simpler and easier to explain operations.
[...]
Show 12 quoted lines
> Once you start to [support truly free editing of the hunk],
> you would need to worry about the case where
> the hunk extended to include later lines overlaps with the hunk after the
> one we are currently looking at, and run coalesce_overlapping_hunks to
> concatenate them into a larger single hunk.  But to be able to do that,
> you would need to keep track of the number of lines in a hunk yourself
> anyway, which would mean that you cannot rely on --recount anymore.  The
> extension recently made to "git apply" becomes redundant and unused code.
> 
> In short, declaring that you are supporting the use to change ' ' to '-'
> means you are opening a whole can of worms, and I asked the question
> because I did not know if you are really prepared to deal with it.

This issue is why I feed the entire patch (not just the edited hunk) to git-apply --check. That's really the only promise this feature makes: if you hand it a patch that does not apply, it will refuse. If you do hand it a hunk where you manually inserted some extra context, then added some extra changes that weren't in the original hunk, well, tough. (You asked for a gun _and_ loaded it _and_ pointed it at your foot!)

That being said, we could of course add a notice of the form
  # Do not edit in any other ways unless you know what you are doing.
if that constitutes appropriate "trigger safety".
- Thomas
-- 
Thomas Rast
trast@student.ethz.ch
Message 1 of 1 in “Re: [PATCH] git-add--interactive: manual hunk editing mode”
  1. Thomas RastJul 2, 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.