Skip to content

Commit 6a05509

Browse files
committed
fix edition behaviour (fixup frama-c.9.1)
1 parent 680da0d commit 6a05509

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/core/opamSystem.ml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,20 +1572,18 @@ let internal_patch ~patch_filename ~dir diffs =
15721572
raise (Internal_patch_error (fmt "Patch %S does not apply cleanly." patch_filename))
15731573
in
15741574
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;
15891587
| Patch.Delete file ->
15901588
let file = get_path file in
15911589
(* TODO: apply the patch and check the file is empty *)

0 commit comments

Comments
 (0)