Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 323571

Summary: URLish fails when passed file URI's
Product: [Technology] JGit Reporter: Thomas Hallgren <thomas>
Component: JGitAssignee: Christian Halstrick <christian.halstrick>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: matthias.sohn, robin.rosenberg, stefan.lay
Version: 0.9.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Thomas Hallgren CLA 2010-08-25 04:28:26 EDT
The class org.eclipse.jgit.transport.URlish is not capable of parsing a common file URL

Example:

 File x = new File("/foo/bar");
 String uriString = x.toURI().toURL().toString();

The resulting string is now:

 file:/foo/bar

If I pass this to the URlish constructor I get an URlish with the host name 'file' which leads to an UnknownHostException later on.
Comment 1 Christian Halstrick CLA 2010-10-01 03:34:11 EDT
I proposed a fix in http://egit.eclipse.org/r/#change,1690 . Let's see what the review brings.
Comment 2 Matthias Sohn CLA 2010-10-08 05:15:59 EDT
2160c09dd4f678c5f2f8e730945be637210b39de fixes part of the problem
Comment 3 Christian Halstrick CLA 2010-10-18 03:36:28 EDT
Commit be2ddff6a72cff3d28b87d038a96194a6e2bd272 has fixed this problem
Comment 4 Robin Rosenberg CLA 2011-01-12 17:39:04 EST
A few remarks. 

There is a reason we call the class URIish, rather than URI and that is because Git's URI syntax is not that of URI's, just similar. 

Not supporting file:/path was a deliberate attempt at staying compatible with Git URI(ish) syntax.
Comment 5 Thomas Hallgren CLA 2011-01-12 18:18:31 EST
So a Git URI will consider the hostname to be 'file' when passed a 'file:/path'?
Comment 6 Robin Rosenberg CLA 2011-01-12 18:36:48 EST
(In reply to comment #5)
> So a Git URI will consider the hostname to be 'file' when passed a
> 'file:/path'?

Yep... but I did not try to emulate that part of the ugliness. That's obviously a bug waiting to be fixed.
Comment 7 Christian Halstrick CLA 2011-01-14 06:38:12 EST
Robin, are you sure about that? I can use file:/path without problems now with jgit. If I use jgit command line and do 

jgit clone file:/C:/git/egit/.git

and it does what I expect. Anything I missed?
Comment 8 Robin Rosenberg CLA 2011-01-14 07:43:28 EST
(In reply to comment #7)
> Robin, are you sure about that? I can use file:/path without problems now with
> jgit. If I use jgit command line and do 
> 
> jgit clone file:/C:/git/egit/.git
> 
> and it does what I expect. Anything I missed?

Since the patch was merged (a while ago), I suppose it works, but it is a syntax that C Git does not understand.