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

Re: Patch add: previous hunk across file boundaries

From
Jeff King <peff@peff.net>
Date
May 11, 2018, 17:47 UTC
Message-ID
<20180511174756.GB19670@sigill.intra.peff.net>
In-Reply-To
<CAHd499CKJTnjvPSMqoFZDWw-6PYX4_AxLr0yC6CaMi7VO9TBzQ@mail.gmail.com>
On Fri, May 11, 2018 at 09:53:52AM -0500, Robert Dailey wrote:
> I noticed that when stepping into a new file while doing `git add -p`,
> pressing `k` or `K` does not go back to the previous file. Is this a
> bug? Is there a setting for it? I googled & checked out the git docs,
> I didn't find any specific information on this.

Nope, this is just the way that "-p" is implemented. It considers each file independently (another artifact of this is that after completing the hunks in a file the changes are staged, even if you quit while looking at a hunk in another file).

I agree that it would be nicer to consider the whole set atomically, with both "save and quit" and "quit but do not save" options. The way it works now is mostly due to the way that "add -p" grew out of the whole "add -i" interactive system, where you'd invoke the patch-adder on specific files from a menu.

So no, there's not a way to do what you want right now short of writing patch.

-Peff
Previous: Robert Dailey
Message 2 of 2 in “Patch add: previous hunk across file boundaries”
  1. Robert DaileyMay 11, 2018
  2. Jeff KingMay 11, 2018

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.