From 6f268f8cebbc53a9810f0fe6ca1a961a32d8b074 Mon Sep 17 00:00:00 2001 From: Thomas Wolf Date: Thu, 27 Feb 2020 20:04:47 +0100 Subject: [PATCH] Cygwin expects forward slashes for commands to be run via sh.exe FS_Win32_Cygwin replaces backslashes by / as a side-effect of relativize(). When support for core.hooksPath was added, paths were relativized in a different place using Path.resolve(), which doesn't do that transformation. As a result hooks could not be run on Cygwin in some cases. Do the transformation in FS_Win32_Cygwin.runInShell(). In all other places, File or Path objects are used, which give no guarantee about the file separator (typically the system-dependent default separator), so doing the transformation earlier still wouldn't guarantee that sh.exe indeed gets a command string using forward slashes. Bug: 558577 Change-Id: I3c07eb85f0ac7c5628a2e92f990e5cdb7ecf532f Signed-off-by: Thomas Wolf --- org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java index 10be26f79..41c239f1a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java @@ -150,7 +150,7 @@ public class FS_Win32_Cygwin extends FS_Win32 { argv.add("sh.exe"); //$NON-NLS-1$ argv.add("-c"); //$NON-NLS-1$ argv.add("$0 \"$@\""); //$NON-NLS-1$ - argv.add(cmd); + argv.add(cmd.replace(File.separatorChar, '/')); argv.addAll(Arrays.asList(args)); ProcessBuilder proc = new ProcessBuilder(); proc.command(argv);