cvs and diff maintainers:
We have discovered a diff3 problem in diff cvs. I have included a
patch to diff-2.7 and a patch to cvs-1.10.8 that fixes the problem. I
have also included our testcases.
We first found the defect while tring to merge in changes from a
branch into the main trunk. We found that in the merge, some code
that was deleted in the branch didn't get deleted in the main trunk.
1.1 -- 1.1.2.1
| |
| |
| 1.1.2.2
| |
| |
| |
| |
|
1.2
This seemed to be related to the problem that was discovered by Noah
Friedman <[EMAIL PROTECTED]> and patched by Paul Eggert
<[EMAIL PROTECTED]> back in November of 1996. Paul's patch he
in-effect turned off shift_boundaries (which optimizes the diff by
merging hunks if possible.) This fixed the problem described by Noah.
In our testcase CVS calls:
diff3 -E -am -L testcase0 -L 1.1 -L 1.1.2.2 testcase0 testcase0-1.1 testcase0-1.1.2.2
In this particular example, testcase0 and testcase0-1.1 happen to be the
same file (There were no changes on the main trunk between the time we
branched and the time we merged.) We found that diff3 from the
diffutils package merged our file successfully, but CVS did not. We
found that diff3 within CVS calls a diff between "mine" and "yours"
and again between "older" and "yours":
diff -a --horizon-lines=10 testcase0 testcase0-1.1.2.2
diff -a --horizon-lines=16 testcase0-1.1 testcase0-1.1.2.2
Because testcase0, and testcase0-1.1 are exactly the same file, these
diffs should produce the same output. We found that with different
horizon-lines, diff produced different output for the two diffs, until
the running the function shift_boundaries, which made the two diffs
look the same. Diff from the diffutils package enables the
shift_boundaries function, so diff3 merges correctly. Diff from the cvs
package has shift_boundaries in effect disabled from Paul's patch.
>From our example above, when using diff from the cvs package, the two
commands produce different diffs, because shift_boundaries is
disabled, and so diff3 merges incorrectly.
Our patch to diffutils, and cvs adds a new command-line option to diff
"--diff3-output". This option turns off shift_boundaries. We also
changed diff3 so that each diff is called with horizon-lines=10. You
might say that the defect is really in make_3way_diff, because it
doesn't handle all the types of output from diff, but we found that
the easiest way to solve our problem was to add a flag to diff that
makes it produce output that is diff3 friendly.
I have included our testcases
To test diff3, run the the command:
diff3 -E -am testcase0 testcase0-1.1 testcase0-1.1.2.2
and
diff3 -E -am testcase1 testcase1-1.2 testcase0-1.1.2.1
To test cvs:
Put the ,v files into a repository somewhere and then check them out.
rm -f testcase0
cvs update -A testcase0
cvs update -j branch testcase0
and
rm -f testcase1
cvs update -A testcase1
cvs update -j branch testcase1
--
R. Wesley Ireland <[EMAIL PROTECTED]>,
Kevin Pearson <[EMAIL PROTECTED]>
cvs-bug.tar.gz