opam icon indicating copy to clipboard operation
opam copied to clipboard

Replace the dependency on GNU patch by a strict dependency on git

Open kit-ty-kate opened this issue 2 years ago • 3 comments

Fixes https://github.com/ocaml/opam/issues/3433 Fixes https://github.com/ocaml/opam/issues/3782 Fixes https://github.com/ocaml/opam/issues/3639 for good Helps https://github.com/ocaml/opam/issues/3482

While looking at https://github.com/ocaml/opam/issues/3639 happening for many macOS users, I realized that git apply basically ships with its own version of GNU patch which works correctly.

The original issue is that macOS is a POSIX-complient OS. However POSIX-complient patch seems to be a nightmare: you can't tell it to delete files. It'll just make it empty instead. There are non-posix options (-E) that deletes empty files anyway but those have another problem where it can't distinguish between you deleting the file and emptying the file... This issue also appears on BSDs.

The solution here is to make git a required dependency. Most users will have it anyway and many features are missing without it so it's not too much of a stretch to make it mandatory.

kit-ty-kate avatar Dec 22 '22 16:12 kit-ty-kate

I have a recollection that this wasn't a silver bullet on the Windows side but I think that may have been before the patch rewriter was added. Regardless, this is well-worth revising, thanks! Even if we end up having to keep the patch pre-processing, at least there's only one patch program then to be considering...

dra27 avatar Dec 22 '22 16:12 dra27

This is great, I've had problems with GNU patch on Windows from Cygwin, which lead me to replace this code

cd ~/opam-repository \
&& (git cat-file -e $OPAM_HASH || git fetch origin master) \
&& git reset -q --hard $OPAM_HASH \
&& git --no-pager log --no-decorate -n1 --oneline \
&& opam update -u

with

cd /home/opam/opam-repository \
&& (git cat-file -e $OPAM_HASH || git fetch origin opam2) \
&& git reset -q --hard $OPAM_HASH \
&& git --no-pager log --no-decorate -n1 --oneline \
&& rsync -ar --update --exclude='.git' ./ /cygdrive/c/opam/.opam/repo/default \
&& ocaml-env exec --64 -- opam update -u

MisterDA avatar Feb 07 '23 09:02 MisterDA

done

kit-ty-kate avatar Feb 23 '24 23:02 kit-ty-kate

Reverted in #5891, see comment for explanation

rjbou avatar Mar 20 '24 17:03 rjbou