From 6e59e6dab963f2ae796a1e331a716fc7f4f9bfdd Mon Sep 17 00:00:00 2001 From: Mathias Kinzler Date: Wed, 28 Jul 2010 13:58:39 +0200 Subject: [PATCH] Meaningful error message when trying to check-out submodules Currently, a NullPointerException occurs in this case. We should instead throw a more meaningful Exception with a proper message. This is a very "stupid" implementation which simply checks for the existence of a ".gitmodules" file. Bug: 300731 Bug: 306765 Bug: 308452 Bug: 314853 Change-Id: I155aa340a85cbc5d7d60da31dba199fc30689b67 Signed-off-by: Mathias Kinzler --- .../resources/org/eclipse/jgit/JGitText.properties | 1 + org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java | 1 + .../src/org/eclipse/jgit/lib/WorkDirCheckout.java | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/org.eclipse.jgit/resources/org/eclipse/jgit/JGitText.properties b/org.eclipse.jgit/resources/org/eclipse/jgit/JGitText.properties index 1b2b81fce3..a9878f8d29 100644 --- a/org.eclipse.jgit/resources/org/eclipse/jgit/JGitText.properties +++ b/org.eclipse.jgit/resources/org/eclipse/jgit/JGitText.properties @@ -335,6 +335,7 @@ sourceRefNotSpecifiedForRefspec=Source ref not specified for refspec: {0} staleRevFlagsOn=Stale RevFlags on {0} startingReadStageWithoutWrittenRequestDataPendingIsNotSupported=Starting read stage without written request data pending is not supported statelessRPCRequiresOptionToBeEnabled=stateless RPC requires {0} to be enabled +submodulesNotSupported=Submodules are not supported symlinkCannotBeWrittenAsTheLinkTarget=Symlink "{0}" cannot be written as the link target cannot be read from within Java. tSizeMustBeGreaterOrEqual1=tSize must be >= 1 theFactoryMustNotBeNull=The factory must not be null diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java b/org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java index 9d1e2cd808..461242cb27 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java @@ -394,6 +394,7 @@ public class JGitText extends TranslationBundle { /***/ public String staleRevFlagsOn; /***/ public String startingReadStageWithoutWrittenRequestDataPendingIsNotSupported; /***/ public String statelessRPCRequiresOptionToBeEnabled; + /***/ public String submodulesNotSupported; /***/ public String symlinkCannotBeWrittenAsTheLinkTarget; /***/ public String tSizeMustBeGreaterOrEqual1; /***/ public String theFactoryMustNotBeNull; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/WorkDirCheckout.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/WorkDirCheckout.java index ef3d7840f7..beab61abe2 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/WorkDirCheckout.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/WorkDirCheckout.java @@ -165,6 +165,10 @@ public class WorkDirCheckout { private void checkoutOutIndexNoHead() throws IOException { new IndexTreeWalker(index, merge, root, new AbstractIndexTreeVisitor() { public void visitEntry(TreeEntry m, Entry i, File f) throws IOException { + // TODO remove this once we support submodules + if (f.getName().equals(".gitmodules")) + throw new UnsupportedOperationException( + JGitText.get().submodulesNotSupported); if (m == null) { index.remove(root, f); return; -- 2.39.5