Re Behavior of git log --diff-filter=d

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Eric,

Nice question

Yes, this is expected behavior
You're seeing a difference because

--diff-filter=d tells Git to exclude commits that have deleted files in their diffs.
However, this filter only applies if there is a diff to filter.

In other words, 
if you run git log --format="%H" --diff-filter=d, 
Git doesn't show any output unless 
the diff logic is actually invoked. 
But --format="%H" alone does not invoke diff generation...
so --diff-filter silently does nothing.

When you add --stat or --name-only, 
you're explicitly telling Git: 
"Please compute the diff". 

Now Git has something to filter, 
and it applies --diff-filter=d 
to exclude those diffs that involve deletions.

If you want to exclude deletion commits and get just commit hashes
This is something I think should work
probably set this up with an alias if you use this many times

git log --format="%H" --diff-filter=d --name-only | grep -v '^$'

This should work just fine...

Or perhaps if you wanna tinker more
git log --format="%H" --diff-filter=d --stat | grep -B1 -v "delete mode"

But if you're just trying to filter commits 
by file change type and want to see 
only those hashes where a deleted file is not present, 
you'll need some way to trigger the diff 
even if you discard the output later.

Hope that helps :)

Thank you,

- Jayatheerth




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux