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

Re: git add intent-to-add then git add patch no longer allows edit

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 21, 2020, 16:27 UTC
Message-ID
<xmqqmu2o9d6j.fsf@gitster.c.googlers.com>
In-Reply-To
<C52FB27V04G0.2ML0PLGDE71MG@ziyou.local>
"Raymond E. Pasco" <ray@ameretat.dev> writes:
> I fixed half of this in a topic that's on master now (it errors out
> entirely if you try to stage it at all in 2.28.0), 
Yup, thanks for that one.
> but new file diffs
> still aren't splittable into hunks. Phillip Wood (on cc) is looking into
> that; the tricky part is that when split into hunks only the first hunk
> actually staged can be a "new file" patch.

Out of a change that adds a file with three parts A, B and C (in this order), you could pick the parts A and C, while leaving the change to further add B in the middle, and create a patch to add a file that has A and C, and apply that to the index alone (i.e. "add -p", pick A and C, and "add" that part by applying that "new file" diff). After that, the path is no longer i-t-a but has the real contents (i.e. part A followed by part C), so further "add -p" would see the difference between the index and the working tree as a modification patch.

So as long as you could come up with a good UI to pick parts from a single hunk "new file" diff, "the second and later application must be done as modification" should fall out naturally, no?

Previous: Raymond E. PascoNext: Phillip Wood
Message 3 of 16 in “git add intent-to-add then git add patch no longer allows edit”
  1. Thomas SullivanAug 21, 2020
  2. Raymond E. PascoAug 21, 2020
  3. Junio C HamanoAug 21, 2020
  4. Phillip WoodAug 23, 2020
  5. Raymond E. PascoAug 24, 2020
  6. Phillip WoodAug 24, 2020
  7. Raymond E. PascoAug 24, 2020
  8. Phillip WoodSep 4, 2020
  9. Johannes SchindelinSep 4, 2020
  10. Junio C HamanoSep 6, 2020
  11. Phillip WoodSep 7, 2020
  12. Junio C HamanoSep 8, 2020
  13. Johannes SchindelinSep 8, 2020
  14. Junio C HamanoSep 8, 2020
  15. Phillip WoodSep 9, 2020
  16. Raymond E. PascoSep 5, 2020

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.