Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply patches when dealing with repositories via an OCaml implementation of patch #5892

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix edition behaviour (fixup frama-c.9.1)
  • Loading branch information
kit-ty-kate committed Feb 14, 2025
commit 50f3375421dce97b4b1b1c9729a830b5c21ed342
26 changes: 12 additions & 14 deletions src/core/opamSystem.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1613,20 +1613,18 @@ let internal_patch ~patch_filename ~dir diffs =
raise (Internal_patch_error (fmt "Patch %S does not apply cleanly." patch_filename))
in
let apply diff = match diff.Patch.operation with
| Patch.Edit (src, dst) ->
let src = get_path src in
let dst = get_path dst in
if Sys.file_exists src then
let content = read src in
let content = patch ~file:src (Some content) diff in
write dst content;
if not (String.equal src dst) then
Unix.unlink src;
else
(* NOTE: GNU patch ignores when a file doesn't exist *)
let content = read dst in
let content = patch ~file:dst (Some content) diff in
write dst content
| Patch.Edit (file1, file2) ->
(* That seems to be the GNU patch behaviour *)
let file =
let file1 = get_path file1 in
if Sys.file_exists file1 then
file1
else
get_path file2
in
let content = read file in
let content = patch ~file:file (Some content) diff in
write file content;
| Patch.Delete file ->
let file = get_path file in
(* TODO: apply the patch and check the file is empty *)
Expand Down