From a28ae3995fc4655be1400cf694e4b0d97db5df45 Mon Sep 17 00:00:00 2001 From: Andrey Loskutov Date: Sat, 1 Aug 2015 17:03:11 +0200 Subject: containsGitModulesFile() should not crash on bare repository Change-Id: Iba7e4674b3d33c730613a6ac703977f48b015853 Signed-off-by: Andrey Loskutov --- .../src/org/eclipse/jgit/submodule/SubmoduleWalk.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'org.eclipse.jgit') diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java index 7d9bca0d1b..6263d4b74d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java @@ -451,13 +451,14 @@ public class SubmoduleWalk implements AutoCloseable { } /** - * Checks whether the working tree (or the index in case of a bare repo) - * contains a .gitmodules file. That's a hint that the repo contains - * submodules. + * Checks whether the working tree contains a .gitmodules file. That's a + * hint that the repo contains submodules. * * @param repository * the repository to check - * @return true if the repo contains a .gitmodules file + * @return true if the working tree contains a .gitmodules file, + * false otherwise. Always returns false + * for bare repositories. * @throws IOException * @throws CorruptObjectException * @since 3.6 @@ -465,8 +466,7 @@ public class SubmoduleWalk implements AutoCloseable { public static boolean containsGitModulesFile(Repository repository) throws IOException { if (repository.isBare()) { - DirCache dc = repository.readDirCache(); - return (dc.findEntry(Constants.DOT_GIT_MODULES) >= 0); + return false; } File modulesFile = new File(repository.getWorkTree(), Constants.DOT_GIT_MODULES); -- cgit v1.2.3