diff options
author | peter <peter@FreeBSD.org> | 2001-08-10 09:53:06 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2001-08-10 09:53:06 +0000 |
commit | 75f7ac20d05fc07bd23bbbaa37a5066b87ca87bb (patch) | |
tree | 9d465dbd69e6033ab4d69e284056926039b7890c /contrib/cvs/diff | |
parent | c132709d1892a50d7915da8685face38ada32e4f (diff) | |
download | FreeBSD-src-75f7ac20d05fc07bd23bbbaa37a5066b87ca87bb.zip FreeBSD-src-75f7ac20d05fc07bd23bbbaa37a5066b87ca87bb.tar.gz |
Initial merge of cvs-1.11 -> 1.11.1p1 changes onto mainline. There is
still some suspicious and/or broken stuff to fix yet.
Diffstat (limited to 'contrib/cvs/diff')
-rw-r--r-- | contrib/cvs/diff/diff3.c | 67 |
1 files changed, 44 insertions, 23 deletions
diff --git a/contrib/cvs/diff/diff3.c b/contrib/cvs/diff/diff3.c index ab68eaf..dc89606 100644 --- a/contrib/cvs/diff/diff3.c +++ b/contrib/cvs/diff/diff3.c @@ -174,7 +174,7 @@ static int edscript; static int flagging; /* Number of lines to keep in identical prefix and suffix. */ -static int horizon_lines = 10; +static int const horizon_lines = 10; /* Use a tab to align output lines (-T). */ static int tab_align_flag; @@ -373,28 +373,44 @@ diff3_run (argc, argv, out, callbacks_arg) file0-file1 diffs didn't line up with the file0-file2 diffs (which is entirely possible since we don't use diff's -n option), diff3 might report phantom changes from file1 to file2. */ + /* Also try to compare file0 to file1 because this is the where + changes are expected to come from. Diffing between these pairs + of files is is most likely to return the intended changes. There + can also be the same problem with phantom changes from file0 to + file1. */ + /* Historically, the default common file was file2. Ediff for emacs + and possibly other applications, have therefore made file2 the + ancestor. So, for compatibility, if this is simply a three + way diff (not a merge or edscript) then use the old way with + file2 as the common file. */ + + { + int common; + if (edscript || merge ) + { + common = 1; + } + else + { + common = 2; + } + if (strcmp (file[common], "-") == 0) + { + /* Sigh. We've got standard input as the arg corresponding to + the desired common file. We can't call diff twice on + stdin. Use another arg as the common file instead. */ + common = 3 - common; + if (strcmp (file[0], "-") == 0 || strcmp (file[common], "-") == 0) + { + diff_error ("%s", "`-' specified for more than one input file", 0); + return 2; + } + } - if (strcmp (file[2], "-") == 0) - { - /* Sigh. We've got standard input as the last arg. We can't - call diff twice on stdin. Use the middle arg as the common - file instead. */ - if (strcmp (file[0], "-") == 0 || strcmp (file[1], "-") == 0) - { - diff_error ("%s", "`-' specified for more than one input file", 0); - return 2; - } - mapping[0] = 0; - mapping[1] = 2; - mapping[2] = 1; - } - else - { - /* Normal, what you'd expect */ - mapping[0] = 0; - mapping[1] = 1; - mapping[2] = 2; - } + mapping[0] = 0; + mapping[1] = 3 - common; + mapping[2] = common; + } for (i = 0; i < 3; i++) rev_mapping[mapping[i]] = i; @@ -447,12 +463,18 @@ diff3_run (argc, argv, out, callbacks_arg) commonname = file[rev_mapping[FILEC]]; thread1 = process_diff (file[rev_mapping[FILE1]], commonname, &last_block, &content1); + /* What is the intention behind determining horizon_lines from first + diff? I think it is better to use the same parameters for each + diff so that equal differences in each diff will appear the + same. */ + /* if (thread1) for (i = 0; i < 2; i++) { horizon_lines = max (horizon_lines, D_NUMLINES (thread1, i)); horizon_lines = max (horizon_lines, D_NUMLINES (last_block, i)); } + */ thread0 = process_diff (file[rev_mapping[FILE0]], commonname, &last_block, &content0); diff3 = make_3way_diff (thread0, thread1); @@ -1858,7 +1880,6 @@ initialize_main (argcp, argvp) always_text = 0; edscript = 0; flagging = 0; - horizon_lines = 10; tab_align_flag = 0; simple_only = 0; overlap_only = 0; |