Comparision of nested directory vs file fails
Real world reproduction
Compare git worktrees, in main one .git
is a directory, in additional one .git
is a file.
Minimal reproduction
mkdir -p a/b
mkdir -p x
touch x/y
diffoscope a x
Actual behavior
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/diffoscope/main.py", line 752, in main
sys.exit(run_diffoscope(parsed_args))
File "/usr/lib/python3.10/site-packages/diffoscope/main.py", line 707, in run_diffoscope
difference = compare_root_paths(path1, path2)
File "/usr/lib/python3.10/site-packages/diffoscope/comparators/utils/compare.py", line 63, in compare_root_paths
return compare_directories(path1, path2)
File "/usr/lib/python3.10/site-packages/diffoscope/comparators/directory.py", line 208, in compare_directories
return FilesystemDirectory(path1).compare(FilesystemDirectory(path2))
File "/usr/lib/python3.10/site-packages/diffoscope/comparators/directory.py", line 276, in compare
differences.extend(my_container.compare(other_container))
File "/usr/lib/python3.10/site-packages/diffoscope/comparators/utils/container.py", line 191, in compare_pair
difference = compare_files(
File "/usr/lib/python3.10/site-packages/diffoscope/comparators/utils/compare.py", line 124, in compare_files
return file1.compare_bytes(file2, source)
AttributeError: 'FilesystemDirectory' object has no attribute 'compare_bytes'
Expected behavior
There is some diff, like a non-nested comparision: diffoscope a/b x/y
of minimal case, that is
--- a/b
+++ x/y
@@ -1 +1 @@
-type: directory
+type: file