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
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Nov 12, 2019, 20:16 UTC
Message-ID
<nycvar.QRO.7.76.6.1911122114380.46@tvgsbejvaqbjf.bet>
In-Reply-To
<20191112184720.GB38770@google.com>
Hi Emily,
On Tue, 12 Nov 2019, Emily Shaffer wrote:
Show 34 quoted lines
> On Sat, Nov 09, 2019 at 01:27:16PM +0900, Junio C Hamano wrote:
> > 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>'?
> >
> > Probably.
> >
> > I originally wrote "git add -i" with the intention that the
> > interactive mode is _the_ primary interface to the machinery, so the
> > expected way to work with a new file was "git add -i", tell the
> > command to add that <newly-added-file>, and do the "patch" thing
> > using the interactive subcommand to do so within the "git add -i"
> > session.
> >
> > Later people liked (only) the patch part, and "git add -p" (and
> > various "--patch" options that invoke "add -p" internally from other
> > commands like "checkout", "reset" were added) was born.  I think
> > nobody thought things through when they did so.
> >
> > If I were designing "git add -p" from scratch and explicitly asked
> > not to do the other parts of the "--interactive" feature, I would
> > imagine "add -N && add -p" combination is what I would make it
> > mimic.
> >
> > 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.
>
> Ah, this is a compelling point. I imagine the landscape will be fairly
> different when that effort is finished.
>
>
> From the replies, it sounds like it's a favorable change, but it makes
> sense to wait on it considering the refactor to use C. Thanks, all.

The patch series can already be viewed at PRs #170-175 on https://github.com/gitgitgadget/git; maybe you want to have a look at implementing this feature on top of https://github.com/dscho/git/tree/add-p-in-c-config-settings?

Ciao, Dscho

Previous: Emily ShafferNext: Junio C Hamano
Message 5 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.