From: K Jayatheerth <jayatheerthkulkarni2005@gmail•com>
To: ericsalem@gmail•com
Cc: git@vger•kernel.org
Subject: Re Behavior of git log --diff-filter=d
Date: Thu, 3 Jul 2025 19:12:20 +0530 [thread overview]
Message-ID: <20250703134220.31638-1-jayatheerthkulkarni2005@gmail.com> (raw)
In-Reply-To: <64308d3f-281b-49a3-bc10-57878903bf4c@gmail.com>
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
next prev parent reply other threads:[~2025-07-03 13:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-02 20:28 Behavior of git log --diff-filter=d Eric Salem
2025-07-03 13:42 ` K Jayatheerth [this message]
2025-07-03 15:36 ` Re " Jeff King
2025-07-03 21:30 ` Eric Salem
2025-07-03 15:34 ` Jeff King
2025-07-03 22:44 ` [PATCH] setup_revisions(): turn on diffs for all-negative diff filter Jeff King
2025-07-03 23:42 ` Eric Salem
2025-07-04 13:30 ` Karthik Nayak
2025-07-07 5:31 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250703134220.31638-1-jayatheerthkulkarni2005@gmail.com \
--to=jayatheerthkulkarni2005@gmail$(echo .)com \
--cc=ericsalem@gmail$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox