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

`git diff --max-depth` results in fatal error when comparing a merge commit with its parents

From
Han Jiang <jhcarl0814@gmail.com>
Date
Nov 30, 2025, 02:30 UTC
Message-ID
<CANrWfmRk-S1vF+pMH-cK6gUcDK_yeDpxvLOmGMFFZsGBATSSGQ@mail.gmail.com>
What did you do before the bug happened? (Steps to reproduce your issue)

git init './repo' cd './repo' mkdir --parents -- './1/2/3/4/5/6' echo '1' >'./1/2/3/4/5/6/7'; git add './1/2/3/4/5/6/7'; git commit --message="$((++number))"; git branch branch2 git checkout -b branch1; echo '2' >'./1/2/3/4/5/6/7'; git add './1/2/3/4/5/6/7'; git commit --message="$((++number))" git checkout branch2; echo '3' >'./1/2/3/4/5/6/7'; git add './1/2/3/4/5/6/7'; git commit --message="$((++number))" git checkout branch1 git merge --message="$((++number))" branch2 echo '4' >'./1/2/3/4/5/6/7'; git add './1/2/3/4/5/6/7'; git -c 'core.editor=:' merge --continue git lg --all --patch --diff-merges=separate

git diff HEAD 'HEAD^1' 'HEAD^2' git diff --max-depth=5 HEAD 'HEAD^1' 'HEAD^2' # fatal: object '...' is not a blob! # $?=128 git diff --max-depth=6 HEAD 'HEAD^1' 'HEAD^2'

git diff HEAD 'HEAD^1' 'HEAD^2' './1' git diff --max-depth=5 HEAD 'HEAD^1' 'HEAD^2' './1' # fatal: object '...' is not a blob! # $?=128 git diff --max-depth=6 HEAD 'HEAD^1' 'HEAD^2' './1'

git diff HEAD 'HEAD^1' 'HEAD^2' './1/2' git diff --max-depth=4 HEAD 'HEAD^1' 'HEAD^2' './1/2' # fatal: object '...' is not a blob! # $?=128 git diff --max-depth=5 HEAD 'HEAD^1' 'HEAD^2' './1/2' # fatal: object '...' is not a blob! # $?=128

What did you expect to happen? (Expected behavior)

`git diff --max-depth=5 HEAD 'HEAD^1' 'HEAD^2'` and `git diff --max-depth=5 HEAD 'HEAD^1' 'HEAD^2' './1'` and `git diff --max-depth=4 HEAD 'HEAD^1' 'HEAD^2' './1/2'` all output nothing.

`git diff --max-depth=5 HEAD 'HEAD^1' 'HEAD^2' './1/2'` outputs a combined diff.
What happened instead? (Actual behavior)

`git diff --max-depth=5 HEAD 'HEAD^1' 'HEAD^2'` and `git diff --max-depth=5 HEAD 'HEAD^1' 'HEAD^2' './1'` and `git diff --max-depth=4 HEAD 'HEAD^1' 'HEAD^2' './1/2'` all output "fatal: object '...' is not a blob!", $?=128.

`git diff --max-depth=5 HEAD 'HEAD^1' 'HEAD^2' './1/2'` outputs "fatal: object '...' is not a blob!", $?=128.

What's different between what you expected and what actually happened?
Anything else you want to add:

Please review the rest of the bug report below. You can delete any lines you don't wish to share.

[System Info]
git version:
git version 2.52.0.windows.1
cpu: x86_64
built from commit: 2912d8e9b8253723974b7baf1c890273b1a1c5bd
sizeof-long: 4
sizeof-size_t: 8
shell-path: D:/git-sdk-64-build-installers/usr/bin/sh
rust: disabled
feature: fsmonitor--daemon
libcurl: 8.17.0
OpenSSL: OpenSSL 3.5.4 30 Sep 2025
zlib: 1.3.1
SHA-1: SHA1_DC
SHA-256: SHA256_BLK
default-ref-format: files
default-hash: sha1
uname: Windows 10.0 26200
compiler info: gnuc: 15.2
libc info: no libc information available
$SHELL (typically, interactive shell): C:\Program Files\Git\usr\bin\bash.exe

[Enabled Hooks] not run from a git repository - no hooks to show

Message 1 of 1 in “`git diff --max-depth` results in fatal error when comparing a merge commit with its parents”
  1. Han JiangNov 30, 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.