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

Re: Change behavior of git add --patch on newly added file?

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 9, 2019, 07:14 UTC
Message-ID
<xmqqpni1ldw2.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<xmqq5zjtn07v.fsf@gitster-ct.c.googlers.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 7 quoted lines
> Emily Shaffer <emilyshaffer@google.com> writes:
>
>> Should 'git add -p <newly-added-file>' do the same thing as 'git add -N
>> <newly-added-file && git add -p <newly-added-file>'?
> ...
> Patches welcome, but you may want to check with Dscho as there is an
> effort going on to reimplement the entire "add -i" machinery in C.

Oh, having said all that, for a newly added file, all you have is a hunk that is full of added lines and nothing else, so even 's'plit interactive subcommand of "add -p" interface would not do anything.

So I am not sure if performing an implicit "add -N" upfront would help your use case that much. For that, you'd need to extend hunk splitting UI a bit more, so that the user can split a hunk that only adds lines into two at a desired point in the hunk.

Previous: Junio C HamanoNext: Emily Shaffer
Message 3 of 7 in “Change behavior of git add --patch on newly added file?”
  1. Emily ShafferNov 8, 2019
  2. Junio C HamanoNov 9, 2019
  3. Junio C HamanoNov 9, 2019
  4. Emily ShafferNov 12, 2019
  5. Johannes SchindelinNov 12, 2019
  6. Junio C HamanoNov 13, 2019
  7. Jeff KingNov 11, 2019

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.