Search code examples
gitgit-log

What flags need to be set on `git log` to make it have similar output to `git whatchanged`?


Per: Difference between git-log and git-whatchanged?

Encourage new users to use 'log' instead. These days, these commands are unified and just have different defaults.

I only recently discovered git whatchanged but found its output:

commit deadbeefdeadbeefdeadbeefdeadbeefdeadbeef
Author: Egg Sample <mail@example.com>
Date: Mon Jan 28 16:32:04 2019 -0800

    change some files

:100777 100644 abaddad1 feeb1e42 M      src/changemymode.txt
:100644 100644 1234abcd abcd1234 M      src/changemycontent.txt
:000000 100755 00000000 6600abcd A      src/addme.txt
:100755 000000 feed1bee 00000000 D      src/deleteme.txt

useful for a particular workflow I had recently (involving a branch with many file mode changes). Out of curiosity, what would I need to do to make git log behave in such a manner, i.e.:

  • show the commit information,
  • the old mode, new mode, hashes, Modified|Added|Deleted and filenames of the files that changed
  • and not the diffs themselves
  • (and exclude merges by default, which is also called out as git whatchanged behavior).

I figured it might be something in the --stat or --format options, but git log --help doesn't seem to mention anything about getting the file modes and object hashes printed in conjunction with these options, and a quick scan of said document doesn't have anything jump out at me.


Solution

  • Just so this question is not left unanswered:

    By this revised answer, newer versions of git explain this on man git-whatchanged

    The whatchanged command is essentially the same as git-log(1) but defaults to show the raw format diff output and to skip merges.

    So:

    git log --raw --no-merges