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

git: how to produce context diffs?

From
BHBruno Haible <bruno@clisp.org>
Date
Nov 27, 2006, 14:16 UTC
Message-ID
<200611271516.30425.bruno@clisp.org>
Hi,
Is this a bug in git-diff? The git-diff-files.html says:
  " When the environment variable GIT_EXTERNAL_DIFF is not set ...
    For example, if you prefer context diff:
    GIT_DIFF_OPTS=-c git-diff-index -p HEAD  "
This doesn't work for me with git-1.4.4:

$ unset GIT_EXTERNAL_DIFF $ export GIT_DIFF_OPTS=-c $ git-diff-index -p HEAD

diff --git a/configure.ac b/configure.ac
index 74901dc..d222ded 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT(hello, 2.1.1, bug-gnu-hello@gnu.org)
+AC_INIT(hello, 2.1.2, bug-gnu-hello@gnu.org)
 AC_CONFIG_SRCDIR([src/hello.c])
 
 AC_PREREQ(2.52)

Expected output:

$ git-diff-index -p HEAD
index 74901dc..d222ded 100644
diff --git a/configure.ac b/configure.ac
*** a/configure.ac
--- b/configure.ac
***************
*** 1,5 ****
  dnl Process this file with autoconf to produce a configure script.
! AC_INIT(hello, 2.1.1, bug-gnu-hello@gnu.org)
  AC_CONFIG_SRCDIR([src/hello.c])
  
  AC_PREREQ(2.52)
--- 1,5 ----
  dnl Process this file with autoconf to produce a configure script.
! AC_INIT(hello, 2.1.2, bug-gnu-hello@gnu.org)
  AC_CONFIG_SRCDIR([src/hello.c])
  
  AC_PREREQ(2.52)


(Really, while I find -u diffs fine for tiny changes, I find them unreadable
for rewrites of larger blocks, and cannot live without -c for these.)

When I look at diff.c around
       const char *diffopts = getenv("GIT_DIFF_OPTS");
it appears that only unified diffs are supported??
Next: Jakub Narebski
Message 1 of 8 in “git: how to produce context diffs?”
  1. Bruno HaibleNov 27, 2006
  2. Jakub NarebskiNov 27, 2006
  3. SeanNov 27, 2006
  4. Jakub NarebskiNov 27, 2006
  5. SeanNov 27, 2006
  6. SeanNov 27, 2006
  7. Thomas KolejkaNov 27, 2006
  8. Junio C HamanoNov 27, 2006

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.