[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-diffutils] bug#31577: Using -S / --starting-file causes diff to mis
From: |
Maxim Baz |
Subject: |
[bug-diffutils] bug#31577: Using -S / --starting-file causes diff to miss some files |
Date: |
Thu, 24 May 2018 01:56:06 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 |
Hello,
The manual describes -S option as "start with FILE when comparing directories".
My intuition is that this should behave like -O option in git-diff [1]: show
differences in FILE first, then show differences in all other files. However,
it appears that diff behaves in a different (and quite weird) way: it first
composes an ordered list of files to compare, then cuts off the beginning of
this list until FILE, and only then starts comparing the remaining files. This
is extremely unintuitive and I consider this a bug (and if happens to be "by
design", then I propose a new feature request for -O option 🙂)
Specific example:
Create file structure as below, all files in the directory "one" should have
word "one" as the contents, all files in the directory "two" should word "two"
as the contents (so all files are different).
❯ tree -a
.
├── one
│ ├── dir
│ │ └── file
│ ├── .hidden-dir
│ │ └── file
│ ├── .hidden-file
│ └── zfile
└── two
├── dir
│ └── file
├── .hidden-dir
│ └── file
├── .hidden-file
└── zfile
6 directories, 8 files
❯ diff -ur one two | grep '+++' | wc -l
4
❯ diff -ur -S zfile one two | grep '+++' | wc -l
1
❯ diff -ur -S zfile one two
diff --color --unified -ur -S zfile one/zfile two/zfile
--- one/zfile 2018-05-24 01:23:49.237899164 +0200
+++ two/zfile 2018-05-24 01:24:58.260920662 +0200
@@ -1 +1 @@
-one
+two
I expect both diff calls to output differences in 4 files, only the second call
to print differences in the file "zfile" first.
[1]: https://git-scm.com/docs/git-diff#git-diff--Oltorderfilegt
Regards,
Maxim Baz
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [bug-diffutils] bug#31577: Using -S / --starting-file causes diff to miss some files,
Maxim Baz <=