threads / discuss / 64554

`--max-depth` produces no output when <path> is '.' or ends with slash

Subject: `--max-depth` produces no output when <path> is '.' or ends with slash

## tl;dr

One message between Nov 29, 2025 and Nov 29, 2025.

replies: 0people: 1as markdown or json

Han Jiang· Nov 29, 2025, 22:45 UTC · lore
What did you do before the bug happened? (Steps to reproduce your issue)

mkdir --parents -- './repo/1/2/3/4/5/6' cd './repo' git init '.' echo '1' >'./1/2/3/4/5/6/7'; git add './1/2/3/4/5/6/7'; git commit --message="$((++number))" echo '2' >'./1/2/3/4/5/6/7'; git add './1/2/3/4/5/6/7'; git commit --message="$((++number))"

git diff 'HEAD~1' HEAD -- '.' git diff --max-depth=6 'HEAD~1' HEAD -- '.' git diff --max-depth=7 'HEAD~1' HEAD -- '.' # wrong, should produce some output git diff --max-depth=100 'HEAD~1' HEAD -- '.' # wrong, should produce some output git diff --max-depth=-1 'HEAD~1' HEAD -- '.'

git diff 'HEAD~1' HEAD -- './' git diff --max-depth=6 'HEAD~1' HEAD -- './' git diff --max-depth=7 'HEAD~1' HEAD -- './' # wrong, should produce some output git diff --max-depth=100 'HEAD~1' HEAD -- './' # wrong, should produce some output git diff --max-depth=-1 'HEAD~1' HEAD -- './'

git diff 'HEAD~1' HEAD -- './1' git diff --max-depth=5 'HEAD~1' HEAD -- './1' git diff --max-depth=6 'HEAD~1' HEAD -- './1'

git diff 'HEAD~1' HEAD -- './1/' git diff --max-depth=5 'HEAD~1' HEAD -- './1/' git diff --max-depth=6 'HEAD~1' HEAD -- './1/' # wrong, should produce some output git diff --max-depth=100 'HEAD~1' HEAD -- './1/' # wrong, should produce some output git diff --max-depth=-1 'HEAD~1' HEAD -- './1/'

git diff 'HEAD~1' HEAD -- './1/2' git diff --max-depth=4 'HEAD~1' HEAD -- './1/2' git diff --max-depth=5 'HEAD~1' HEAD -- './1/2'

git diff 'HEAD~1' HEAD -- './1/2/' git diff --max-depth=4 'HEAD~1' HEAD -- './1/2/' git diff --max-depth=5 'HEAD~1' HEAD -- './1/2/' # wrong, should produce some output git diff --max-depth=100 'HEAD~1' HEAD -- './1/2/' # wrong, should produce some output git diff --max-depth=-1 'HEAD~1' HEAD -- './1/2/'

What did you expect to happen? (Expected behavior)

Using `--max-depth=nonnegative_number` with '.' and './path_ending_in_slash/' should produce same output as with './path_not_ending_in_slash' instead of producing no output.

What happened instead? (Actual behavior)
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

← back to recent threads