Skip to content

diff -r: every file reported as 'Only in' on BOTH sides (even identical files); contents never compared #1344

Closed

Description

@caomengxuan666

Summary

diff -r (directory recursion) is fundamentally broken on Windows paths: every file present in both directories — even byte-identical ones — is reported as Only in <dirA> AND Only in <dirB>, and file contents are never compared. Single-file diff works correctly.

Environment

  • diff (WinuxCmd) 1.1.17 shipped with Niubash 1.4.4 (C:/Users/<user>/AppData/Local/Programs/Niubash/winuxcmd/usr/bin/diff.exe)
  • Windows 10 19045 x64

Minimal repro

set T=%TEMP%\difr
mkdir "%T%\A" "%T%\B"
echo hello > "%T%\A\f.txt"
echo world > "%T%\B\f.txt"
echo same  > "%T%\A\g.txt"
echo same  > "%T%\B\g.txt"
"%LOCALAPPDATA%\Programs\Niubash\winuxcmd\usr\bin\diff.exe" -r "%T%\A" "%T%\B"

Actual output

Only in C:/Users/<user>/AppData/Local/Temp/difr/A: f.txt
Only in C:/Users/<user>/AppData/Local/Temp/difr/B: f.txt
Only in C:/Users/<user>/AppData/Local/Temp/difr/A: g.txt
Only in C:/Users/<user>/AppData/Local/Temp/difr/B: g.txt

exit code 1

Expected (GNU diff behavior)

diff -r A/f.txt B/f.txt
1c1
< hello
---
> world

(g.txt identical → no output, exit 0)

Notes

  • Single-file comparison (diff A/f.txt B/f.txt) produces a correct content diff, so the content-diff engine works; the directory walker fails to match same-named entries between the two trees (possibly a path-normalization issue — note the Only in lines print forward-slash mixed paths while the input was backslash).
  • diff -r with an MSYS-style path (/tmp/...) fails differently: diff: cannot read directory '/tmp/difr/A' (rc=2), same for /usr/bin/diff inside Niubash.
  • Workaround we use: compare via md5sum listings + join/comm.

Found during a real two-tree source audit where this produced ~1000 false "Only in" lines and masked nothing being content-compared.

Activity

  1. added
    bug
    compat-gap
    on Oct 26, 2026
  2. added a commit that references this issue on Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugcompat-gap

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions