diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-06-25 17:46:07 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-06-25 18:03:41 -0700 |
commit | ffe0614d4db653cbcd48c19e9f599fd87cdcfaba (patch) | |
tree | 78120cd464aa4874fd39b52e3ed500349f949193 /org.eclipse.jgit.http.server | |
parent | 8a9844b2afc4e30e60759c03a1428dc99a13619e (diff) | |
download | jgit-ffe0614d4db653cbcd48c19e9f599fd87cdcfaba.tar.gz jgit-ffe0614d4db653cbcd48c19e9f599fd87cdcfaba.zip |
Allow Repository.getDirectory() to be null
Some types of repositories might not be stored on local disk. For
these, they will most likely return null for getDirectory() as the
java.io.File type cannot describe where their storage is, its not
in the host's filesystem.
Document that getDirectory() can return null now, and update all
current non-test callers in JGit that might run into problems on
such repositories. For the most part, just act like its bare.
Change-Id: I061236a691372a267fd7d41f0550650e165d2066
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit.http.server')
-rw-r--r-- | org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/TextFileServlet.java | 2 | ||||
-rw-r--r-- | org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/FileResolver.java | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/TextFileServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/TextFileServlet.java index 5bf5546cf7..650059bd38 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/TextFileServlet.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/TextFileServlet.java @@ -80,6 +80,8 @@ class TextFileServlet extends HttpServlet { private byte[] read(final HttpServletRequest req) throws IOException { final File gitdir = getRepository(req).getDirectory(); + if (gitdir == null) + throw new FileNotFoundException(fileName); return IO.readFully(new File(gitdir, fileName)); } } diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/FileResolver.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/FileResolver.java index cc062dbe88..296725b678 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/FileResolver.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/FileResolver.java @@ -138,8 +138,10 @@ public class FileResolver implements RepositoryResolver { Repository db) throws IOException { if (isExportAll()) return true; - else + else if (db.getDirectory() != null) return new File(db.getDirectory(), "git-daemon-export-ok").exists(); + else + return false; } private static boolean isUnreasonableName(final String name) { |