2

I want to retrieve a list of all the files that really changed between two commits. So, I want to ignore files where the only things that changed are part of the following list:

  • empty line added / removed
  • line containing just an * (and possibly whitespace) added / removed
  • indentation changed or whitespace added after lines
  • breaks inserted into any line, e.g.:

Before:

System.out.println("bar" + "foo");

After:

System.out.println("bar" + 
    "foo");

These kinds of changes should be ignored. I know that this may be a very complicated task, but I don't think I'm the first person needing this kind of thing.

Update

After some help in the comments I came up with

git diff --word-diff-regex='^\*|[^[:space:]]' --ignore-space-at-eol --ignore-blank-lines --ignore-space-change --ignore-all-space hash1..hash2 --name-only

But I am not quite sure if that actually does everything I want. Can someone verify that?

spilot
  • 625
  • 1
  • 7
  • 20
  • `git diff -w` ? (won't handle the `*` though) – assylias Mar 31 '16 at 10:20
  • This does provide the condition of the first bulletpoint, but not any of the other three. – spilot Mar 31 '16 at 10:22
  • what do you have tried ? you should give a look first on https://git-scm.com/docs/git-diff – nnunes10 Mar 31 '16 at 10:23
  • My best try is `git diff --name-only --ignore-blank-lines --ignore-blank-lines --ignore-space-change --ignore-space-at-eol hash1 hash2` – spilot Mar 31 '16 at 10:24
  • You could try with the `--word-diff-regex=` option. Example: http://stackoverflow.com/questions/32140915/git-word-diff-regex-that-works-with-multiline-changes – assylias Mar 31 '16 at 10:25
  • `git diff --name-only --word-diff-regex='^\*|[^[:space:]]' --ignore-space-at-eol --ignore-blank-lines --ignore-space-change --ignore-all-space hash1..hash2` is actually quite good. I'm not quite sure if it really ignores everything I want, though. – spilot Mar 31 '16 at 10:39

1 Answers1

0

The only answer that i come up with, but it´s not so good it´s to make a local branch of the previous commit format them the same way as the new, and compare in the normal way the branch and the head version.