summaryrefslogtreecommitdiff
path: root/xdiff/xdiffi.c
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2009-01-07 17:04:09 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-01-07 21:35:44 (GMT)
commit92b7de93fb7801570ddc3195f03f30b9c201a3bd (patch)
treee7113b428c97f3e6b107f1d64c74f343eda7ecf9 /xdiff/xdiffi.c
parent8104ebfe8276657ee803cca7eb8665a78cf3ef83 (diff)
downloadgit-92b7de93fb7801570ddc3195f03f30b9c201a3bd.zip
git-92b7de93fb7801570ddc3195f03f30b9c201a3bd.tar.gz
git-92b7de93fb7801570ddc3195f03f30b9c201a3bd.tar.bz2
Implement the patience diff algorithm
The patience diff algorithm produces slightly more intuitive output than the classic Myers algorithm, as it does not try to minimize the number of +/- lines first, but tries to preserve the lines that are unique. To this end, it first determines lines that are unique in both files, then the maximal sequence which preserves the order (relative to both files) is extracted. Starting from this initial set of common lines, the rest of the lines is handled recursively, with Myers' algorithm as a fallback when the patience algorithm fails (due to no common unique lines). This patch includes memory leak fixes by Pierre Habouzit. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'xdiff/xdiffi.c')
-rw-r--r--xdiff/xdiffi.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/xdiff/xdiffi.c b/xdiff/xdiffi.c
index 9d0324a..3e97462 100644
--- a/xdiff/xdiffi.c
+++ b/xdiff/xdiffi.c
@@ -329,6 +329,9 @@ int xdl_do_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
xdalgoenv_t xenv;
diffdata_t dd1, dd2;
+ if (xpp->flags & XDF_PATIENCE_DIFF)
+ return xdl_do_patience_diff(mf1, mf2, xpp, xe);
+
if (xdl_prepare_env(mf1, mf2, xpp, xe) < 0) {
return -1;