Skip to content

Git diff path doesn't tolerate dangling slashes ('/') when using pathspec #5836

@pasisavolainen

Description

@pasisavolainen

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.51.0.windows.1
cpu: x86_64
built from commit: 4d21a77b98af5cf479d8b6f863c2aa94257cd4e1
sizeof-long: 4
sizeof-size_t: 8
shell-path: D:/git-sdk-64-build-installers/usr/bin/sh
feature: fsmonitor--daemon
libcurl: 8.15.0
OpenSSL: OpenSSL 3.2.4 11 Feb 2025
zlib: 1.3.1
SHA-1: SHA1_DC
SHA-256: SHA256_BLK
default-ref-format: files
default-hash: sha1

Windows version

Windows 11

Windows CPU architecture

x86_64 (64-bit)

Additional Windows version information

Microsoft Windows [Version 10.0.26100.6584]

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: CRLFAlways
Bash Terminal Option: MinTTY
Git Pull Behavior Option: Rebase
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Disabled
Enable FSMonitor: Disabled

Other interesting things

If I use a dangling slash ('/') in path for git diff --no-index ... <pathspec>, it fails with error fatal: `pos + len' is too far after the end of the buffer

Example:

# works:
PS C:\Users\PasiSavolainen> git diff --no-index -- C:\temp\testiconf C:\temp\t\ ':!'
# fails:
PS C:\Users\PasiSavolainen> git diff --no-index -- C:\temp\testiconf C:\temp\t/ ':!'
fatal: `pos + len' is too far after the end of the buffer

Terminal/shell

powershell

Commands that trigger the issue

git diff --no-index -- . ./ ':!'

Expected behaviour

No error and diff shown, limited by given pathspec.

Actual behaviour

Error is shown:
fatal: `pos + len' is too far after the end of the buffer

Repository

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions