Skip to content

Add windows support for file.patch by using "git apply" #44783

@poliva83

Description

@poliva83

Description of Issue/Question

file.patch state is very useful for Linux to apply a "better GNU patch". But could not get it working for windows because of the underlying execution file.patch function requiring that "patch" executable is installed.

https://github.com/saltstack/salt/blob/develop/salt/modules/file.py#L2718

There is a "Patch for Windows" executable (http://gnuwin32.sourceforge.net/packages/patch.htm) but it seems pretty old and unlikely to support newer windows versions. Thinking that file.patch could leverage "git apply" to apply a "better GNU patch" for windows (if git is installed). The --unsafe-paths option could be used to patch files outside the git working area.

--unsafe-paths
By default, a patch that affects outside the working area (either a Git controlled working tree, or the current working directory when "git apply" is used as a replacement of GNU patch) is rejected as a mistake (or a mischief).

When git apply is used as a "better GNU patch", the user can pass the --unsafe-paths option to override this safety check. This option has no effect when --index or --cached is in use.

If file.patch is not correct place for this then I'd at least like to see "git apply" be functionality added under git execution modules (https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.git.html).

Relevant link:
https://stackoverflow.com/questions/19611/how-to-patch-on-windows

Metadata

Metadata

Labels

Featurenew functionality including changes to functionality and code refactors, etc.P1Priority 1Silicon v3004.0Release code nameWindowsZDThe issue is related to a Zendesk customer support ticket.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions