Skip to content

git last-modified cannot recognize hidden paths in a sparse-checkout repository #5978

@elpiekay

Description

@elpiekay

Existing issues matching what you're seeing

  • I was not able to find an open or closed issue matching what I'm seeing

Git for Windows 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

Windows version

Windows 10

Windows CPU architecture

x86_64 (64-bit)

Additional Windows version information

Microsoft Windows [Version 10.0.19042.1586]

Options set during installation

Editor Option: VisualStudioCode
Custom Editor Path:
Default Branch Option:
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: OpenSSL
CRLF Option: LFOnly
Bash Terminal Option: MinTTY
Git Pull Behavior Option: Merge
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Enabled
Enable FSMonitor: Disabled

Other interesting things

No response

Terminal/shell

Bash/CMD

Commands that trigger the issue

cd /e/
git init foo
cd foo
mkdir aaa bbb
echo hello > aaa/a.txt
echo world > bbb/b.txt
git add .
git commit -minit
git last-modified
git last-modified aaa
git last-modified -- aaa
git last-modified -- bbb
git sparse-checkout set bbb
ls
git last-modified
git last-modified -- bbb
git last-modified aaa
git last-modified -- aaa

Expected behaviour

After git sparse-checkout set bbb, aaa is hidden from the worktree. git last-modified -- aaa is expected to print a line like

b0af4271bafe62fbb80bc2e424c6d2f4aae65d58        aaa

I think it should work as how git log -- aaa does. git log -- aaa prints the commits that touch aaa. If aaa has never existed in the history, it prints nothing.

Actual behaviour

It raises a fatal error

fatal: ambiguous argument 'aaa': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

Repository

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions