File tree 1 file changed +12
-14
lines changed
1 file changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -1572,20 +1572,18 @@ let internal_patch ~patch_filename ~dir diffs =
1572
1572
raise (Internal_patch_error (fmt " Patch %S does not apply cleanly." patch_filename))
1573
1573
in
1574
1574
let apply diff = match diff.Patch. operation with
1575
- | Patch. Edit (src , dst ) ->
1576
- let src = get_path src in
1577
- let dst = get_path dst in
1578
- if Sys. file_exists src then
1579
- let content = read src in
1580
- let content = patch ~file: src (Some content) diff in
1581
- write dst content;
1582
- if not (String. equal src dst) then
1583
- Unix. unlink src;
1584
- else
1585
- (* NOTE: GNU patch ignores when a file doesn't exist *)
1586
- let content = read dst in
1587
- let content = patch ~file: dst (Some content) diff in
1588
- write dst content
1575
+ | Patch. Edit (file1 , file2 ) ->
1576
+ (* That seems to be the GNU patch behaviour *)
1577
+ let file =
1578
+ let file1 = get_path file1 in
1579
+ if Sys. file_exists file1 then
1580
+ file1
1581
+ else
1582
+ get_path file2
1583
+ in
1584
+ let content = read file in
1585
+ let content = patch ~file: file (Some content) diff in
1586
+ write file content;
1589
1587
| Patch. Delete file ->
1590
1588
let file = get_path file in
1591
1589
(* TODO: apply the patch and check the file is empty *)
You can’t perform that action at this time.
0 commit comments