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

whitespace ignoring during diff -M

From
DMDaniel Mierswa <impulze@impulze.org>
Date
May 31, 2009, 20:28 UTC
Message-ID
<4A22E882.8020500@impulze.org>

Hi list, I was told to try it here after visiting #git/Freenode I want git to think that the diff of two branches where filenames and whitespace amount differ are the same. The following is a snippet from my terminal with output, is there a chance to make git think that those are equal?

impulze@istari ~/gittest $ git init
Initialized empty Git repository in /home/impulze/gittest/.git/
impulze@istari ~/gittest $ touch initial
impulze@istari ~/gittest $ git add initial && git commit initial -m
'initial commit'
[master (root-commit) 7b67dcd] initial commit
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 initial
impulze@istari ~/gittest $ git checkout -b another
Switched to a new branch 'another'
impulze@istari ~/gittest $ echo -e "   abcdef   \n   ghijkl " > file.cc
impulze@istari ~/gittest $ unix2dos -a -u file.cc
impulze@istari ~/gittest $ git add file.cc && git commit file.cc -m
'another commit'
[another 37826f4] another commit
 1 files changed, 2 insertions(+), 0 deletions(-)
 create mode 100644 file.cc
impulze@istari ~/gittest $ git checkout master
Switched to branch 'master'
impulze@istari ~/gittest $ echo -e "\t\tabcdef\t\n\tghijkl\t" > file.c
impulze@istari ~/gittest $ git add file.c && git commit file.c -m
'master commit'
[master f9f0ac5] master commit
 1 files changed, 2 insertions(+), 0 deletions(-)
 create mode 100644 file.c
impulze@istari ~/gittest $ git --no-pager diff another -M -w
diff --git a/file.c b/file.c
new file mode 100644
index 0000000..18364be
--- /dev/null
+++ b/file.c
@@ -0,0 +1,2 @@
+               abcdef
+       ghijkl
diff --git a/file.cc b/file.cc
deleted file mode 100644
index 1a303ea..0000000
--- a/file.cc
+++ /dev/null
@@ -1,2 +0,0 @@
-   abcdef
-   ghijkl
-- 
Mierswa, Daniel

If you still don't like it, that's ok: that's why I'm boss. I simply
know better than you do.
               --- Linus Torvalds, comp.os.linux.advocacy, 1996/07/22
Next: Jeff King
Message 1 of 2 in “whitespace ignoring during diff -M”
  1. Daniel MierswaMay 31, 2009
  2. Jeff KingJun 28, 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.