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

Re: git diff bug?

From
Jeff King <peff@peff.net>
Date
Apr 6, 2009, 18:48 UTC
Message-ID
<20090406184830.GA28120@coredump.intra.peff.net>
In-Reply-To
<D4B0EDF7-E1BD-44E3-858F-002CFF2C496A@boostpro.com>
On Mon, Apr 06, 2009 at 01:58:08PM -0400, David Abrahams wrote:
Show 7 quoted lines
>> The "*.el" line goes into .gitattributes (or .git/info/a...), the other
>> lines are config lines and thus goe into .git/config or .gitconfig.
>
> Aha, thanks.  The hunk header section in the gitattributes manpage turns 
> out to be the only one that shows config stuff without mentioning a config 
> file, thus my confusion.  I suggest a tiny patch ('cept I don't know how 
> to write manpage format)
Neither do I, but fortunately the git docs are all written in asciidoc. :)
Junio, does the patch below make sense to you?
-- >8 --
Subject: [PATCH] doc/gitattributes: clarify location of config text

The gitattributes documentation has a section on the "diff" attribute, with subsections for each of the things you might want to configure in your diff config section (external diff, hunk headers, etc). The first such subsection specifically notes that the definition of the diff driver should go into $GIT_DIR/config, but subsequent sections do not.

This location is implied if you are reading the documentation sequentially, but it is not uncommon for a new user to jump to (or be referred to) a specific section. For a new user who does not know git well enough to recognize the config syntax, it is not clear that those directives don't also go into the gitattributes file.

This patch just mentions the config file in each subsection, similar to the way it is mentioned in the first.

Signed-off-by: Jeff King <peff@peff.net>
---
Mentioning $GIT_DIR/config _and_ $HOME/.gitconfig in each subsection may
seem like overkill, but I really think we shouldn't make any assumption
that a reader has seen the previous sections. They otherwise stand alone
very well.

I arrived at these three sections by grepping for '^[' to find example config file syntax.

 Documentation/gitattributes.txt |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
index 55668e3..b6260b1 100644
--- a/Documentation/gitattributes.txt
+++ b/Documentation/gitattributes.txt
@@ -297,7 +297,8 @@ for paths.
 
 Then, you would define a "diff.tex.xfuncname" configuration to
 specify a regular expression that matches a line that you would
-want to appear as the hunk header "TEXT", like this:
+want to appear as the hunk header "TEXT". Add a section to your
+`$GIT_DIR/config` file (or `$HOME/.gitconfig` file) like this:
 
 ------------------------
 [diff "tex"]
@@ -345,7 +346,8 @@ split words in a line, by specifying an appropriate regular expression
 in the "diff.*.wordRegex" configuration variable.  For example, in TeX
 a backslash followed by a sequence of letters forms a command, but
 several such commands can be run together without intervening
-whitespace.  To separate them, use a regular expression such as
+whitespace.  To separate them, use a regular expression in your
+`$GIT_DIR/config` file (or `$HOME/.gitconfig` file) like this:
 
 ------------------------
 [diff "tex"]
@@ -373,7 +375,8 @@ resulting text on stdout.
 
 For example, to show the diff of the exif information of a
 file instead of the binary information (assuming you have the
-exif tool installed):
+exif tool installed), add the following section to your
+`$GIT_DIR/config` file (or `$HOME/.gitconfig` file):
 
 ------------------------
 [diff "jpg"]
-- 
1.6.2.2.585.g1e067
Previous: David AbrahamsNext: Jeff King
Message 7 of 13 in “git diff bug?”
  1. David AbrahamsApr 4, 2009
  2. Jeff KingApr 4, 2009
  3. Jeff KingApr 4, 2009
  4. David AbrahamsApr 6, 2009
  5. Michael J GruberApr 6, 2009
  6. David AbrahamsApr 6, 2009
  7. Jeff KingApr 6, 2009
  8. Jeff KingApr 6, 2009
  9. Matthieu MoyApr 6, 2009
  10. Junio C HamanoApr 6, 2009
  11. Matthieu MoyApr 6, 2009
  12. David AbrahamsApr 6, 2009
  13. Antriksh PanyApr 7, 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.