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

Re: Different diff strategies in add --interactive

From
Jeff King <peff@peff.net>
Date
Jun 10, 2013, 21:11 UTC
Message-ID
<20130610211140.GD13333@sigill.intra.peff.net>
In-Reply-To
<7v38sphiiw.fsf@alter.siamese.dyndns.org>
On Mon, Jun 10, 2013 at 12:28:55PM -0700, Junio C Hamano wrote:
Show 21 quoted lines
> John Keeping <john@keeping.me.uk> writes:
> 
> > I think the first thing to do is read the "diff.algorithm" setting in
> > git-add--interactive and pass its value to the underlying diff-index and
> > diff-files commands, but should we also have a command line parameter to
> > git-add to specify the diff algorithm in interactive mode?  And if so,
> > can we simply add "--diff-algorithm" to git-add, or is that too
> > confusing?
> 
> Making "git add--interactive" read from diff.algorithm is probably a
> good idea, because the command itself definitely is a Porcelain.  We
> would probably need a way to defeat the configured default for
> completeness, either:
> 
>     git add -p --diff-algorithm=default
>     git -c diff.algorithm=default add -p
> 
> but I suspect that a new option to "git add" that only takes effect
> together with "-p" is probably an overkill, only in order to support
> the former and not having to say the latter, but I can be persuaded
> either way.

Worse than that, you would need to add such an option to "checkout -p", "reset -p", "stash -p", etc. I think the latter form you suggest is probably acceptable in this case.

Overall, I think respecting diff.algorithm in add--interactive is a very sane thing to do. I would even be tempted to say we should allow a few other select diff options (e.g., fewer or more context lines). If you allowed diff options like this:

  git add --patch="--patience -U5"

that is very flexible, but I would not want to think about what the code does when you pass --patch="--raw" or equal nonsense.

But I cannot off the top of my head think of other options besides -U that would be helpful. I have never particularly wanted it for "add -p", either, though I sometimes generate patches to the list with a greater number of context lines when I think it makes the changes to a short function more readable.

-Peff
Previous: Junio C HamanoNext: John Keeping
Message 3 of 10 in “Different diff strategies in add --interactive”
  1. John KeepingJun 10, 2013
  2. Junio C HamanoJun 10, 2013
  3. Jeff KingJun 10, 2013
  4. John KeepingJun 10, 2013
  5. Jeff KingJun 10, 2013
  6. add--interactive: respect diff.algorithmJohn Keeping, Jun 12, 2013
  7. Jeff KingJun 12, 2013
  8. Junio C HamanoJun 23, 2013
  9. John KeepingJun 23, 2013
  10. Junio C HamanoJun 23, 2013

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.