diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2010-01-15 00:18:11 +0100 |
---|---|---|
committer | Robin Rosenberg <robin.rosenberg@dewire.com> | 2010-01-15 07:17:52 +0100 |
commit | 1c785d6902278f17a92759dc20787a63003e0b03 (patch) | |
tree | 579570836d82a2259fb485a57921166cbdb22813 /org.eclipse.jgit | |
parent | 0b8b6b5309f2510f1a2e1c3d77942fa9470dd324 (diff) | |
download | jgit-1c785d6902278f17a92759dc20787a63003e0b03.tar.gz jgit-1c785d6902278f17a92759dc20787a63003e0b03.zip |
Introduce a named constant for the ".git" directory extension
Change-Id: Icfe9205994c6810fcd880054a586e9eef29df9a1
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Diffstat (limited to 'org.eclipse.jgit')
4 files changed, 13 insertions, 7 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java index 405ddee97c..348905dd12 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java @@ -311,6 +311,9 @@ public final class Constants { /** Default name for the Git repository directory */ public static final String DOT_GIT = ".git"; + /** A bare repository typically ends with this string */ + public static final String DOT_GIT_EXT = ".git"; + /** * Create a new digest function for objects. * diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java index a758564bf8..b086968c6c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java @@ -382,8 +382,8 @@ public class RepositoryCache { final String name = directory.getName(); final File parent = directory.getParentFile(); - if (isGitRepository(new File(parent, name + ".git"))) - return new File(parent, name + ".git"); + if (isGitRepository(new File(parent, name + Constants.DOT_GIT_EXT))) + return new File(parent, name + Constants.DOT_GIT_EXT); return null; } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Daemon.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Daemon.java index c6f69043be..cafcd7b4bd 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Daemon.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Daemon.java @@ -57,6 +57,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; +import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.PersonIdent; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.RepositoryCache; @@ -204,8 +205,8 @@ public class Daemon { * the repository instance. */ public void exportRepository(String name, final Repository db) { - if (!name.endsWith(".git")) - name = name + ".git"; + if (!name.endsWith(Constants.DOT_GIT_EXT)) + name = name + Constants.DOT_GIT_EXT; exports.put(name, db); RepositoryCache.register(db); } @@ -358,7 +359,8 @@ public class Daemon { name = name.substring(1); Repository db; - db = exports.get(name.endsWith(".git") ? name : name + ".git"); + db = exports.get(name.endsWith(Constants.DOT_GIT_EXT) ? name : name + + Constants.DOT_GIT_EXT); if (db != null) { db.incrementOpen(); return db; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java index 4eb87c6ad0..80b94b2324 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java @@ -410,8 +410,9 @@ public class URIish { String result = elements[elements.length - 1]; if (Constants.DOT_GIT.equals(result)) result = elements[elements.length - 2]; - else if (result.endsWith(DOT_GIT)) - result = result.substring(0, result.length() - DOT_GIT.length()); + else if (result.endsWith(Constants.DOT_GIT_EXT)) + result = result.substring(0, result.length() + - Constants.DOT_GIT_EXT.length()); return result; } |