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

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

From
Jeff King <peff@peff.net>
Date
Jul 3, 2025, 15:34 UTC
Message-ID
<20250703153438.GA1309870@coredump.intra.peff.net>
In-Reply-To
<64308d3f-281b-49a3-bc10-57878903bf4c@gmail.com>
On Wed, Jul 02, 2025 at 03:28:43PM -0500, Eric Salem wrote:
Show 12 quoted lines
> The git log --diff-filter documentation[1] for deleted files says:
> 
> > Select only files that are Added (A), Copied (C), Deleted (D)...
> 
> > Also, these upper-case letters can be downcased to exclude.
> > E.g. --diff-filter=ad excludes added and deleted paths.
> 
> A simple test:
> [...]
> --diff-filter=D behaves as expected, but when using "d" instead, I don't
> get any output unless I add another option (such as --stat or
> --name-only).

Looks like a bug. This used to produce the output I'd expect (i.e., commits "first" and "third", which do not have deletions), but that changed in 75408ca949 (diff-filter: be more careful when looking for negative bits, 2022-01-28).

I don't have time to dig into it now, but I've cc'd the author (and left your whole reproduction recipe quoted below).

-Peff
Show 39 quoted lines
> $ cd $(mktemp -d)
> $ git init
> Initialized empty Git repository in /tmp/tmp.xnvNav956B/.git/
> $ echo test1 > file1.txt
> $ git add file1.txt 
> $ git commit -m "first"
> [master (root-commit) 71288dd00aff] first
>  1 file changed, 1 insertion(+)
>  create mode 100644 file1.txt
> $ git rm file1.txt 
> rm 'file1.txt'
> $ git commit -m "second"
> [master 6ff8f522b744] second
>  1 file changed, 1 deletion(-)
>  delete mode 100644 file1.txt
> $ echo test2 > file2.txt
> $ git add file2.txt 
> $ git commit -m "third"
> [master 41498d26ea5e] third
>  1 file changed, 1 insertion(+)
>  create mode 100644 file2.txt
> $ git log --format="%H"
> 41498d26ea5ee6820834aa51351e1e7ce6ce8733
> 6ff8f522b744dfbc7c2201c5bf77cf5acc3028ce
> 71288dd00afff60f3a6576f93930aeb0130e5cd1
> $ git log --format="%H" --diff-filter=D
> 6ff8f522b744dfbc7c2201c5bf77cf5acc3028ce
> $ git log --format="%H" --diff-filter=d
> $ git log --format="%H" --diff-filter=d --stat
> 41498d26ea5ee6820834aa51351e1e7ce6ce8733
> 
>  file2.txt | 1 +
>  1 file changed, 1 insertion(+)
> 71288dd00afff60f3a6576f93930aeb0130e5cd1
> 
>  file1.txt | 1 +
>  1 file changed, 1 insertion(+)
> $ git version
> git version 2.50.0
Previous: Eric SalemNext: Jeff King
Message 5 of 9 in “Behavior of git log --diff-filter=d”
  1. Eric SalemJul 2, 2025
  2. Re Behavior of git log --diff-filter=dK Jayatheerth, Jul 3, 2025
  3. Jeff KingJul 3, 2025
  4. Eric SalemJul 3, 2025
  5. Jeff KingJul 3, 2025
  6. setup_revisions(): turn on diffs for all-negative diff filterJeff King, Jul 3, 2025
  7. Eric SalemJul 3, 2025
  8. Karthik NayakJul 4, 2025
  9. Junio C HamanoJul 7, 2025

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.