-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
diff: consider uncommon words to match only if they have the same count
Patience diff starts by lining up unique elements (e.g. lines) to find matching segments of the inputs. After that, it refines the non-matching segments by repeating the process. Histogram expands on that by not just considering unique elements but by continuing with elements of count 2, then 3, etc. Before this commit, when diffing "a b a b b" against "a b a b a b", we would match the two "a"s in the first input against the first two "a"s in the second input. After this patch, we ignore the "a"s because their counts differ, so we try to align the "b"s instead. I have had this commit lying around since I wrote the histogram diff implementation in 1e657c5. I vaguely remember thinking that the way I had implemented it (without this commit) was a bit weird, but I wasn't sure if this commit would be an improvement or not. The bug report from @chooglen today of a case where we behave differently from Git is enough to make me think that we make this change after all. Many unit tests of the diff algorithm are affected, mostly because we no longer match the leading space in " a " against the space in " b" and similar.
- Loading branch information
1 parent
179cff7
commit 72e1399
Showing
4 changed files
with
63 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,12 +61,13 @@ fn test_obslog_with_or_without_diff() { | |
@ rlvkpnrzqnoo [email protected] 2001-02-03 04:05:10.000 +07:00 66b42ad36073 | ||
│ my description | ||
│ Resolved conflict in file1: | ||
│ 1 1: <<<<<<<resolved | ||
│ 1 : <<<<<<< | ||
│ 2 : %%%%%%% | ||
│ 3 : foo | ||
│ 4 : +bar | ||
│ 5 : +++++++ | ||
│ 6 : >>>>>>> | ||
│ 1: resolved | ||
◉ rlvkpnrzqnoo hidden [email protected] 2001-02-03 04:05:09.000 +07:00 af536e5af67e conflict | ||
│ my description | ||
◉ rlvkpnrzqnoo hidden [email protected] 2001-02-03 04:05:09.000 +07:00 6fbba7bcb590 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters