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

Discussion for interactive --patch commands to get --unified support

From
Leon Michalak <leonmichalak6@gmail.com>
Date
Apr 29, 2025, 09:16 UTC
Message-ID
<CAP9jKjGb-Rcr=RLJEzeFdtrekYM+qmHy+1T1fykU3n9cV4GhGw@mail.gmail.com>
Hi everyone!

I am a big fan of `git diff` with a custom `diff.context` setting to increase the context lines (which also extends to other commands like `git show` which I really like). As well as this, I am also a frequent user of `git add --patch` (and also the other interactive `--patch` variants such as reset).

As I've grown to use and appreciate these features even more, I have noticed and been bothered that `git add --patch` doesn't have a (easy) way of configuring how many context lines you see. There is a stackoverflow post (https://stackoverflow.com/questions/6711670/git-show-more-context-when-using-git-add-i-or-git-add-e) which mentions you can do `GIT_DIFF_OPTS=-u<number> git add -p` which does work however isn't very user friendly or convenient.

It would be great if it was possible to start a discussion how this
could be made better (and I would be happy to submit a patch if all is
good). Whilst brainstorming briefly, here are a few options I have
thought of that could solve this pain point, some not mutually
exclusive:
- `-U<number>/--unified=<number>` command line options to the
interactive patch commands (all builtins who call `run_add_p`)
- make `diff.context` setting extend to the interactive patch commands
(not sure how a change like this would be welcomed considering it
could change users command outputs seemingly out of nowhere)
- add an `interactive.context` setting that would work like the
existing `diff.context` setting but apply only to the interactive
patch commands
Is this feature something people would welcome, and what are your thoughts?
Thanks!
Next: Junio C Hamano
Message 1 of 12 in “Discussion for interactive --patch commands to get --unified support”
  1. Leon MichalakApr 29, 2025
  2. Junio C HamanoApr 29, 2025
  3. Jeff KingApr 29, 2025
  4. Leon MichalakApr 30, 2025
  5. Junio C HamanoApr 30, 2025
  6. Phillip WoodMay 2, 2025
  7. Phillip WoodMay 2, 2025
  8. Leon MichalakMay 2, 2025
  9. Leon MichalakMay 2, 2025
  10. Junio C HamanoMay 2, 2025
  11. Leon MichalakMay 2, 2025
  12. Junio C HamanoMay 2, 2025

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.