Source code of "patch.exe"

412 views
Skip to first unread message

Sébastien Jodogne

unread,
Aug 19, 2015, 8:15:47 AM8/19/15
to git-for-windows
Dear all,

I have downloaded the "Git for Windows" installer, and I have noticed the presence of binaries of GNU patch version 2.5 [1].

I would like to know where I can find the source code of this version of GNU patch, since it might have itself been patched to compile with MinGW and MSYS.

If the source code is the vanilla version of GNU patch 2.5, where can I find the build instructions to generate the same "patch.exe" binaries?

I thank you much in advance.

Regards,
Sébastien-



Johannes Schindelin

unread,
Aug 19, 2015, 9:45:12 AM8/19/15
to Sébastien Jodogne, git-for-windows
Hi Sébastien,

On 2015-08-19 08:51, Sébastien Jodogne wrote:

> I have downloaded the "Git for Windows" installer, and I have noticed
> the
> presence of binaries of GNU patch version 2.5 [1].
>
> I would like to know where I can find the source code of this version
> of
> GNU patch, since it might have itself been patched to compile with
> MinGW
> and MSYS.
>
> If the source code is the vanilla version of GNU patch 2.5, where can I
> find the build instructions to generate the same "patch.exe" binaries?

The easiest way to find out about this is to install the Git SDK, then
run

pacman -Qu $(which patch.exe)

to find out which package contains the `patch.exe` binary. It so happens
to be patch.2.7.5-1 at the moment. Since this is an MSys2 package (not a
MinGW one, otherwise the patch utility would be in /mingw64/bin/, not
/usr/bin/), this package is built from the recipes in

https://github.com/msys2/MSYS2-packages

The `patch` package is obviously built from the subdirectory

https://github.com/Alexpux/MSYS2-packages/tree/master/patch

and the PKGBUILD file specifies that the source is fetched from
ftp://ftp.gnu.org/gnu/patch/patch-2.7.5.tar.xz:


https://github.com/Alexpux/MSYS2-packages/blob/900744becd072f687029b0f830ab6fe95cf533d6/patch/PKGBUILD#L14

and then these two patches are applied before building:


https://github.com/Alexpux/MSYS2-packages/blob/900744becd072f687029b0f830ab6fe95cf533d6/patch/msys2-patch-2.7.1.patch

and


https://github.com/Alexpux/MSYS2-packages/blob/900744becd072f687029b0f830ab6fe95cf533d6/patch/msys2-patch-manifest.patch

As you can see, some light changes are applied, i.e. `patch.exe` will
always write in binary mode with MSys2, and the executable will have a
manifest embedded that allows it to run as non-administrator.

Ciao,
Johannes

Sébastien Jodogne

unread,
Aug 19, 2015, 10:47:01 AM8/19/15
to git-for-windows, s.jo...@gmail.com
Hi Johannes,

Many thanks for this precise answer!

I will soon check out all this information.

Regards,
Sébastien-
Reply all
Reply to author
Forward
0 new messages