Skip to content

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

Closed

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

Activity

  1. dscho commented on Sep 23, 2025

    @dscho
    Member

    I investigated, and this is not Windows-specific. Moving it to the Git mailing list: https://lore.kernel.org/git/c75ec5f9-407a-6555-d4fb-bb629d54ec61@gmx.de/.

  2. added this to the v2.51.0(2) milestone on Sep 26, 2025
  3. linked a pull request that will close this issuePrepare for v2.51.0(2) #5840on Sep 26, 2025
  4. dscho commented on Sep 26, 2025

    @dscho
    Member

    I plan on releasing Git for Windows v2.51.0(2) on this coming Monday, September 29th 2025, with a fix for this problem.

  5. dscho commented on Sep 26, 2025

    @dscho
    Member

    Here is a snapshot installer/Portable Git/MinGit of this revision: https://github.com/git-for-windows/git-for-windows-automation/actions/runs/18030062242. Would you kindly confirm the fix @pasisavolainen ?

  6. pasisavolainen commented on Sep 28, 2025

    @pasisavolainen
    Author

    @dscho Sorry for delay, the fix appears like it works for me, thank you!

  7. dscho commented on Sep 29, 2025

    @dscho
    Member

    @pasisavolainen thanks for confirming!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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