Skip to content

Commit 6457294

Browse files
committed
Work around the lack of file creation detection in the patch library when diff -N is used
See hannesm/patch#8
1 parent 5765729 commit 6457294

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/core/opamSystem.ml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,8 +1653,16 @@ let internal_patch ~dir p =
16531653
in
16541654
let apply diff = match diff.Patch.operation with
16551655
| Patch.Edit file ->
1656-
let file = get_path file in
1657-
let content = read file in
1656+
let file, content =
1657+
let file = get_path file in
1658+
let content =
1659+
if Sys.file_exists file then
1660+
Some (read file)
1661+
else
1662+
None
1663+
in
1664+
(file, content)
1665+
in
16581666
let content = patch content diff in
16591667
write file content
16601668
| Patch.Rename (src, dst) ->

0 commit comments

Comments
 (0)