]> source.dussan.org Git - jgit.git/commitdiff
RepositoryCache: don't require HEAD in git repositories 42/152842/8
authorHan-Wen Nienhuys <hanwen@google.com>
Sun, 17 Nov 2019 23:05:57 +0000 (15:05 -0800)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 26 Nov 2019 00:57:19 +0000 (01:57 +0100)
Reftable-enabled repositories don't have a file called HEAD. Check for
reftable/ instead.

This fixes repository creation on reftable in Gerrit.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: I778c2be01d96aaf135affae4b457b5fe5b483bee

org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileReftableTest.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java

index e0e20fb4dd87e075798907ac5eed661bd55cdc22..0e06d459a2b352904015d4ee4c45a3d3af8c6edd 100644 (file)
@@ -73,6 +73,7 @@ import org.eclipse.jgit.lib.RefUpdate;
 import org.eclipse.jgit.lib.RefUpdate.Result;
 import org.eclipse.jgit.lib.ReflogEntry;
 import org.eclipse.jgit.lib.ReflogReader;
+import org.eclipse.jgit.lib.RepositoryCache;
 import org.eclipse.jgit.revwalk.RevWalk;
 import org.eclipse.jgit.test.resources.SampleDataRepositoryTestCase;
 import org.eclipse.jgit.transport.ReceiveCommand;
@@ -507,6 +508,11 @@ public class FileReftableTest extends SampleDataRepositoryTestCase {
                }
        }
 
+       @Test
+       public void isGitRepository() {
+               assertTrue(RepositoryCache.FileKey.isGitRepository(db.getDirectory(), db.getFS()));
+       }
+
        @Test
        public void testRenameDestExists() throws IOException {
                ObjectId rb = db.resolve("refs/heads/b");
index fa113bfc6b8f8f284db726a26382bc06799778db..fc74f5324f7e956d128e39b35e3433868600824b 100644 (file)
@@ -476,7 +476,8 @@ public class RepositoryCache {
                public static boolean isGitRepository(File dir, FS fs) {
                        return fs.resolve(dir, Constants.OBJECTS).exists()
                                        && fs.resolve(dir, "refs").exists() //$NON-NLS-1$
-                                       && isValidHead(new File(dir, Constants.HEAD));
+                                       && (fs.resolve(dir, Constants.REFTABLE).exists()
+                                                       || isValidHead(new File(dir, Constants.HEAD)));
                }
 
                private static boolean isValidHead(File head) {