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

Re: [PATCH v1 1/3] Introduce config variable "diff.primer"

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 25, 2009, 20:34 UTC
Message-ID
<7v1vurf7lq.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1232904657-31831-2-git-send-email-keith@cs.ucla.edu>
Keith Cascio <keith@cs.ucla.edu> writes:
Show 12 quoted lines
> Introduce config variable "diff.primer".
> Allows user to specify arbitrary options
> to pass to diff on every invocation,
> including internal invocations from other
> programs, e.g. git-gui.
> Introduce diff command-line options:
> --no-primer, --machine-friendly
> Protect git-format-patch, git-apply,
> git-am, git-rebase, git-gui and gitk
> from inapplicable options.
>
> Signed-off-by: Keith Cascio <keith@cs.ucla.edu>

Your Subject is good; in a shortlog output that will be taken 3 months down the road, it will still tell us what this patch was about, among 100 other patches that are about different topics.

The proposed commit log message describes what the patch does, but it does not explain what problem it solves, nor why the approach the patch takes to solve that problem is good. Lines that are too short and too dense without paragraph breaks do not help readability either.

Show 10 quoted lines
> ---
>  Documentation/config.txt       |   14 +++++++
>  Documentation/diff-options.txt |   13 ++++++
>  Makefile                       |    2 +
>  builtin-log.c                  |    1 +
>  diff.c                         |   83 +++++++++++++++++++++++++++++++++++-----
>  diff.h                         |   15 ++++++-
>  git-gui/lib/diff.tcl           |    8 +++-
>  gitk-git/gitk                  |   16 ++++----
>  8 files changed, 129 insertions(+), 23 deletions(-)

You can work around the backward incompatibility you are introducing for known users that you broke with your patch, by including updates to them, and that is what your patches to git-gui and gitk are, but that is a sure sign that the approach is flawed.

The point of lowlevel plumbing (e.g. diff-{files,index,tree}) is to give people's scripts an interface that they can rely on. It is not about giving a magic interface that all the users are somehow magically upgraded without change, when the underlying git is upgraded.

If a script X does not use "ignore whitespace" without an explicit request from the end user when it runs diff-tree internally, installing a new version of diff-tree should *NOT* magically make script X to run it with "ignore whitespace", because you do not know what the script X uses diff-tree output for and how, even when the end user sets diff.primer to get "ignore whitespace" applied to his command line invocation of "git diff" Porcelain. Imagine a case where the operation of that script X relies on seeing at least two context lines around the hunk in order to correctly parse textual diff output from "diff-index -p", and the user sets "-U1" in diff.primer --- you would break the script and it is not fair to blame the script for not explicitly passing -U3 and relying on the default.

Scriptability by definition means you do not know how scripts written by people around plumbing use the output; I do not think you can sensibly say "this should not be turned on in a machine friendly output, but this is safe to use".

I would not be opposed to an enhancement to the plumbing that the scripts can use to say "I am willing to take any option (or perhaps "these options") given to me via diff.primer". Some scripts may want to be just a pass-thru of whatever the underlying git-diff-* command outputs, and it may be a handy way to magically upgrade them to allow their invocation of lowlevel plumbing to be affected by what the end-user configured. But that magic upgrade has to be an opt/in process.

There are funny indentation to align the same variable names on two adjacent lines and such; please don't.

Previous: Jeff KingNext: Junio C Hamano
Message 14 of 41 in “Introduce config variable "diff.primer"”
  1. 0/3 Introduce config variable "diff.primer"Keith Cascio, Jan 25, 2009
  2. 1/3 Introduce config variable "diff.primer"Keith Cascio, Jan 25, 2009
  3. 2/3 Test functionality of new config variable "diff.primer"Keith Cascio, Jan 25, 2009
  4. 3/3 git-gui hooks for new config variable "diff.primer"Keith Cascio, Jan 25, 2009
  5. Johannes SchindelinJan 25, 2009
  6. Keith CascioJan 25, 2009
  7. Johannes SchindelinJan 25, 2009
  8. Keith CascioJan 25, 2009
  9. Johannes SchindelinJan 25, 2009
  10. Keith CascioJan 25, 2009
  11. Jeff KingJan 25, 2009
  12. Keith CascioJan 25, 2009
  13. Jeff KingJan 25, 2009
  14. Junio C HamanoJan 25, 2009
  15. Junio C HamanoJan 26, 2009
  16. Keith CascioJan 26, 2009
  17. Jeff KingJan 26, 2009
  18. Junio C HamanoJan 26, 2009
  19. Keith CascioJan 26, 2009
  20. Jeff KingJan 26, 2009
  21. Junio C HamanoJan 26, 2009
  22. Jeff KingJan 26, 2009
  23. Johannes SchindelinJan 26, 2009
  24. Jeff KingJan 26, 2009
  25. backwards compatibility, was Re: [PATCH v1 1/3] Introduce config variable "diff.primer"Johannes Schindelin, Jan 26, 2009
  26. Jeff KingJan 26, 2009
  27. Johannes SchindelinJan 26, 2009
  28. Jeff KingJan 26, 2009
  29. Keith CascioJan 27, 2009
  30. Jay SoffianJan 26, 2009
  31. Jeff KingJan 26, 2009
  32. Jay SoffianJan 26, 2009
  33. Junio C HamanoJan 26, 2009
  34. Jay SoffianJan 26, 2009
  35. Jeff KingJan 26, 2009
  36. Junio C HamanoJan 26, 2009
  37. Junio C HamanoJan 25, 2009
  38. Keith CascioJan 25, 2009
  39. Jeff KingJan 25, 2009
  40. Keith CascioJan 27, 2009
  41. Jeff KingJan 27, 2009

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.