From 166e6a131d0693d20b3cc08f252705608d24d5f0 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Wed, 27 Apr 2011 21:56:56 -0400
Subject: [PATCH] Improve repo folder detection. Fail gracefully on create repo error.

---
 src/com/gitblit/utils/JGitUtils.java |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/com/gitblit/utils/JGitUtils.java b/src/com/gitblit/utils/JGitUtils.java
index 4cfed0d..70a938f 100644
--- a/src/com/gitblit/utils/JGitUtils.java
+++ b/src/com/gitblit/utils/JGitUtils.java
@@ -94,9 +94,10 @@
 				File gitFolder = new File(file, Constants.DOT_GIT);
 				boolean isGitRepository = gitFolder.exists() && gitFolder.isDirectory();
 				
-				// then look for folder.git/HEAD
+				// then look for folder.git/HEAD or folder/HEAD and folder/config
 				if (!isGitRepository) {
-					if (file.getName().endsWith(Constants.DOT_GIT_EXT) && new File(file, Constants.HEAD).exists()) {
+					if ((file.getName().endsWith(Constants.DOT_GIT_EXT) && new File(file, Constants.HEAD).exists())
+							|| (new File(file, "config").exists() && new File(file, Constants.HEAD).exists())) {
 						gitFolder = file;
 						isGitRepository = true;
 					}
@@ -266,13 +267,13 @@
 
 	public static String getRawContentAsString(Repository r, RevBlob blob) {
 		byte [] content = getRawContent(r, blob);
-		return new String(content, Charset.forName("UTF-8"));
+		return new String(content, Charset.forName(Constants.CHARACTER_ENCODING));
 	}
 
 	public static String getRawContentAsString(Repository r, RevCommit commit, String blobPath) {
 		RevObject obj = getRevObject(r, commit.getTree(), blobPath);
 		byte [] content = getRawContent(r, (RevBlob) obj);
-		return new String(content, Charset.forName("UTF-8"));
+		return new String(content, Charset.forName(Constants.CHARACTER_ENCODING));
 	}
 
 	public static List<PathModel> getFilesInPath(Repository r, String basePath, String objectId) {

--
Gitblit v1.9.1