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

Re: Unable to split then edit hunk in git interactive add

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Nov 24, 2023, 15:19 UTC
Message-ID
<b6e24bb6-a497-4d37-a938-cfbcdbe77a9d@gmail.com>
In-Reply-To
<8d7c8313-0f02-4218-ba2a-1716ada7956f@gmail.com>
On 24/11/2023 08:16, scarf wrote:
> |Thank you for filling out a Git bug report!
> Please answer the following questions to help us understand your issue.
> 
> What did you do before the bug happened? (Steps to reproduce your issue)

Thanks for taking the time to report this. While it is a known limitation of "git add -p" that editing a hunk after splitting it can cause problems (see below) I am unable to reproduce this particular bug.

When a hunk is split the resulting hunks share the context lines around the split. The trailing context lines of the first hunk are the same lines as the leading context of the second hunk. If the shared context is edited then the lines no-longer match between the hunks which means they cannot be applied. In general it is better to avoid splitting a hunk if you plan to edit it.

Best Wishes
Phillip
Previous: scarf
Message 2 of 2 in “Unable to split then edit hunk in git interactive add”
  1. scarfNov 24, 2023
  2. Phillip WoodNov 24, 2023

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.