Community
Participate
Working Groups
Created attachment 281310 [details] git hooks commit-msg: command not found Hello, We have "commit-msg" hook that is working in 2019-09 and after upgrading to eclipse 2019-12, it gives a pop-up warning that "Commit was aborted by hook "commit-msg" even if the commit message format is correct. Warning (see also screenshot attached): C:\opt\git-repos\repo-name\.git\hooks\commit-msg: C:optgit-reposrepo-name.githookscommit-msg: command not found. In the warning message, it seems that "\" was removed in the path which cause the error. I tried to use core.hooksPath and change "\" with "/" or "\\" but no luck. Any idea how to fix this? Thanks, Lea
*** Bug 558578 has been marked as a duplicate of this bug. ***
That would be Windows with cygwin, I guess. We did make some changes in JGit to support core.hooksPath. Apparently that has the side-effect that cygwin's sh.exe now gets a command with a path containing backslashes... I don't have Windows or cygwin, but I can reproduce easily enough by creating a file named "writ\e.sh" (yes, including the backslash) with content echo "$1 $2 $3" Calling that the way JGit does gives $ sh -c './writ\e.sh "$@"' './writ\e.sh' 'foo' ./writ\e.sh: ./write.sh: No such file or directory $ But calling it as follows works: $ sh -c '$0 "$@"' './writ\e.sh' 'foo' foo $ So there we have a work-around. But why that should suddenly be necessary eludes me. Probably pre-5.6, the path used / as separator, and now it uses \. But I don't see where this difference would come from...
Do we use some ant library to parse git paths? I remember we had recently fun to find out that this library was system dependent.
(In reply to Andrey Loskutov from comment #3) > Do we use some ant library to parse git paths? I remember we had recently > fun to find out that this library was system dependent. No. That was only in the ref filter dialog in EGit. Here we're doing file paths, using File and java.nio.file.Path. I'm not surprised we have \ in there on Windows, but I _am_ surprised that either * we either didn't before, or * somehow it worked all the same, and for both I don't see why from looking at the code. The commit that caused the difference is most likely https://git.eclipse.org/r/#/c/149912/ .
New Gerrit change created: https://git.eclipse.org/r/155010
(In reply to Eclipse Genie from comment #5) > New Gerrit change created: https://git.eclipse.org/r/155010 @Andrey, do you have a Windows/Cygwin environment to test this?
New Gerrit change created: https://git.eclipse.org/r/155014
Gerrit change https://git.eclipse.org/r/155014 was merged to [stable-5.6]. Commit: http://git.eclipse.org/c/jgit/jgit.git/commit/?id=2323d7a1ef909f9deb3f21329cf30bd1173ee9cf
@lea: the fix is available in the stable-nightly update site: https://download.eclipse.org/egit/updates-stable-nightly/ Could you please try and confirm that it works now?
Created attachment 281333 [details] Blank hook waning message
Comment on attachment 281333 [details] Blank hook waning message Tested that version 5.6.1 fixed the issue on path. The hook works now. Thank you so much. One thing i noticed is the blank message of the hook warning. But i believe this is not related to this issue. Would you like me to report this? Thanks, Lea
Yes, please open a new bug report for that empty message.
I created new bug for the empty message - https://bugs.eclipse.org/bugs/show_bug.cgi?id=558629 Thank You!
(In reply to Thomas Wolf from comment #9) > @lea: the fix is available in the stable-nightly update site: > https://download.eclipse.org/egit/updates-stable-nightly/ Could you please > try and confirm that it works now? Hi @Thomas, may i know when will the fix be part of the official release/update site?
Hi, I'm using JGit 5.6.1.202002131546-r on Windows. Git hooks were working in 5.4.2 but aren't anymore. Cygwin is added in the path. I get errors like this: org.eclipse.jgit.api.errors.AbortedByHookException: Rejected by "pre-commit" hook. C:\Users\alex_jitianu\Documents\Git-workspace\git-hooks-sample\.git\hooks\pre-commit: C:\Users\alex_jitianu\Documents\Git-workspace\git-hooks-sample\.git\hooks\pre-commit: command not found I think it has something to do with the backslashes. In 5.4.2, as opposed to 5.6.1, the cmd was passed through FS_Win32_Cygwin.relativize(String, String) which also replaced backslashes with slashes. I've made a test case that uses org.eclipse.jgit.util.FS.runProcess() in a Cygwin environment and fails with the same error message. Again, if I replace backslashes with slashes, the script is invoked. @Test public void testRunCygwinProcess() throws Exception { Assert.assertTrue(FS_Win32_Cygwin.isCygwin()); File script = new File("target/script"); String content = "#!/bin/sh\n" + "set -x\n" + "\n" + "echo \"Script run\"\n" + "\n" + "exit 0"; write(script, content); String cmd = script.getAbsolutePath(); FS_Win32_Cygwin fs_Win32_Cygwin = new FS_Win32_Cygwin(); ProcessBuilder runInShell = fs_Win32_Cygwin.runInShell(cmd, new String[] {}); ByteArrayOutputStream errRedirect = new ByteArrayOutputStream(); ByteArrayOutputStream outRedirect = new ByteArrayOutputStream(); int runProcess = fs_Win32_Cygwin.runProcess(runInShell, outRedirect, errRedirect, (String) null); String out = new String(outRedirect.toByteArray(), "UTF-8");; String err = new String(errRedirect.toByteArray(), "UTF-8"); Assert.assertEquals( "+ echo 'Script run'\n" + "+ exit 0\n" + "", err); Assert.assertEquals("Script run\n" + "", out); }
(In reply to Alex Jitianu from comment #15) > ... FS_Win32_Cygwin.relativize(String, String) which also replaced backslashes with slashes. Thanks for finding this. As you can see from the previous comments, I had completely overlooked that side-effect.
New Gerrit change created: https://git.eclipse.org/r/158538
Gerrit change https://git.eclipse.org/r/158538 was merged to [stable-5.6]. Commit: http://git.eclipse.org/c/jgit/jgit.git/commit/?id=6f268f8cebbc53a9810f0fe6ca1a961a32d8b074