Skip to content
Permalink
Browse files
[FIXED JENKINS-13007]
On Windows command prompt, '^' is an escape character (http://en.wikipedia.org/wiki/Escape_character#Windows_Command_Prompt)
This isn't a problem if 'git' we are executing is git.exe, because '^' is a special character only for the command processor,
but if 'git' we are executing is git.cmd (which is the case of msysgit), then the arguments we pass in here ends up getting
processed by the command processor, and so 'xyz^{commit}' becomes 'xyz{commit}' and fails.

Since we can't really tell if we are calling into git.exe or git.cmd, the best we can do for Windows
is not to use '^{commit}'. This reverts 13f6038
and it will not dereference tags, but it's far better than having this method completely broken.

See JENKINS-13007 where this blew up on Windows users.

I filed msysgit/msysgit#36 as a bug in msysgit.
  • Loading branch information
kohsuke committed Jun 26, 2012
1 parent 987a44a commit 8810661600f42c0ee2ce2d0352a2f01542b2c2af
Showing 1 changed file with 15 additions and 1 deletion.
@@ -257,7 +257,21 @@ public void clean() throws GitException {
}

public ObjectId revParse(String revName) throws GitException {
String rpCommit = Functions.isWindows() ? "^^{commit}" : "^{commit}";
/*
On Windows command prompt, '^' is an escape character (http://en.wikipedia.org/wiki/Escape_character#Windows_Command_Prompt)
This isn't a problem if 'git' we are executing is git.exe, because '^' is a special character only for the command processor,
but if 'git' we are executing is git.cmd (which is the case of msysgit), then the arguments we pass in here ends up getting
processed by the command processor, and so 'xyz^{commit}' becomes 'xyz{commit}' and fails.
Since we can't really tell if we are calling into git.exe or git.cmd, the best we can do for Windows
is not to use '^{commit}'. This reverts 13f6038acc4fa5b5a62413155da6fc8cfcad3fe0
and it will not dereference tags, but it's far better than having this method completely broken.
See JENKINS-13007 where this blew up on Windows users.
I filed https://github.com/msysgit/msysgit/issues/36 as a bug in msysgit.
*/
String rpCommit = Functions.isWindows() ? "" : "^{commit}";
String result = launchCommand("rev-parse", revName + rpCommit);
return ObjectId.fromString(firstLine(result).trim());
}

4 comments on commit 8810661

@dave-hansen
Copy link

@dave-hansen dave-hansen commented on 8810661 Jun 26, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kohsuke thanks!

@meowsqueak
Copy link

@meowsqueak meowsqueak commented on 8810661 Jun 26, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also a problem with Cygwin's git.exe.

@kohsuke
Copy link
Member Author

@kohsuke kohsuke commented on 8810661 Jun 27, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@meowsqueak are you saying that this fix broke something with Cygwin's git.exe?

@meowsqueak
Copy link

@meowsqueak meowsqueak commented on 8810661 Jun 27, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I'm just saying that the original problem was also an issue for Cygwin's git.exe, not just msysgit. Therefore you can't rely on the .exe vs .cmd differentiation. The changelog statement "This isn't a problem if 'git' we are executing is git.exe" is not true.

I haven't tested the fix on Cygwin yet.

Please sign in to comment.