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

Missing “git diff” functionality

From
Thorsten Glaser <tg@debian.org>
Date
Apr 21, 2020, 20:17 UTC
Message-ID
<Pine.BSM.4.64L.2004212007350.25168@herc.mirbsd.org>
Hi,

I’d like to ask whether adding two, if not three, functionalities to “git diff” is possible and has any takers.

The first two are relatively straightforward and already exist in at least GNU diff (as incorporated in GNU CVS, for example).

       -I, --ignore-matching-lines=RE
              ignore changes where all lines match RE
I use this like
	cvs diff -uprOLDTAG -I '[$]OtherBSD:.*[$]'
and missed this in git dearly.
       -x, --exclude=PAT
              exclude files that match PAT
       -X, --exclude-from=FILE
              exclude files that match any pattern in FILE
I used to do 'diff -pruN -x CVS -x .git cvscheckout gitcheckout | less'
but have recently become accustomed to…
  alias cdiff='git diff --color=always --no-index --no-prefix'
  alias cwdiff='git diff --color=always --no-index --no-prefix --word-diff'
  alias cwdiffc='git diff --color=always --no-index --no-prefix --word-diff-regex=.'
… and doing a 'cdiff cvscheckout gitcheckout' lacks this exclusion.

Thirdly, there’s some functionality in GNU diff to make the content not begin at the second/third column but at the eigth, so tabs don’t break in the output. The resulting diff is obviously not a valid unidiff, but…

@@ foo @@
     if (bar)
-	baz(1);
+        baz(2);
… reads different from…
@@ foo @@
	    if (bar)
-		baz(1);
+	        baz(2);

… and while only the first one is unidiff, the second one has its uses (especially in plaintext files with tab-formatted tables) for human consumption. Basically, you replace the leading space with a HT for unchanged lines and add one after the +/- for the others.

Thanks for your consideration, //mirabilos

PS: https://github.com/mirabilos/git-find still wishes to be
    merged into git.git (I asked for this… years ago?), and
    https://github.com/mirabilos/recvhook/tree/standalone is
    my merge-back-able attempt at improving post-receive-email
    which got neglected upstream and wants back…
-- 
„Cool, /usr/share/doc/mksh/examples/uhr.gz ist ja ein Grund,
mksh auf jedem System zu installieren.“
	-- XTaran auf der OpenRheinRuhr, ganz begeistert
(EN: “[…]uhr.gz is a reason to install mksh on every system.”)
Message 1 of 1 in “Missing “git diff” functionality”
  1. Thorsten GlaserApr 21, 2020

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.