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

Different diff strategies in add --interactive

From
John Keeping <john@keeping.me.uk>
Date
Jun 10, 2013, 14:28 UTC
Message-ID
<20130610142825.GI22905@serenity.lan>

I've just been trying to use "add -p" to stage some changes which happen to be textually entangled with other changes that I do not want to stage.

It turns out that "git diff --patience" does a really good job splitting this into exactly the hunks I want, but "add --interactive" doesn't let me change the diff algorithm it uses. I tried setting "diff.algorithm" to "patience", but of course add--interactive uses plumbing diff commands that ignore configuration settings.

As a one off, I locally modified add--interactive to unconditionally use patience diff and it has worked perfectly in this case, but I don't want to have to apply a patch if I ever want this behaviour in the future.

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?

Next: Junio C Hamano
Message 1 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.