Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] "instable" diff algorithms lead to wrong merge results

On Wed, Nov 24, 2010 at 12:07 AM, Christian Halstrick
<christian.halstrick@xxxxxxxxx> wrote:
>> Do you consider "lines of context" when you do this?
>
> No, I don't. I think that is the reason why we merge differently in
> JGit than in C Git. I'll add these checks to the merge algorithm and
> see if we become more compatible for cases. That's my main goal - to
> give the same results as C Git. I am glad we finally found a hint how
> to solve this.

From what Junio explained to me, it sounds like the "lines of context"
rule used by C Git is sort of an accident.  The merge algorithm is
using the hunk header line positions for the edit blocks, and the diff
algorithm computed those with the default lines of context setting.
This happened as an accident of the way the diff algorithm worked and
wasn't exactly something planned.

But I think this dates back all the way through RCS diff/merge.  RCS
merge probably executed diff, then used the hunk headers as the line
offsets when building the "edit list".  Because that was easier than
fixing the line numbers based on the lines of context presented.
Later someone realized this behavior was probably a good thing, and
started claiming it as a feature.  :-)

If its a feature, then the lines of context value should be tweakable.
 End users won't be setting it, but when an application calls your
merge implementation they should be able to influence the lines of
context just like they can set the conflict marker text for ours and
theirs.

-- 
Shawn.


Back to the top