]> source.dussan.org Git - gitblit.git/commitdiff
Do not incrementally index blobs in submodules (issue 119)
authorJames Moger <james.moger@gitblit.com>
Tue, 7 Aug 2012 12:14:15 +0000 (08:14 -0400)
committerJames Moger <james.moger@gitblit.com>
Tue, 7 Aug 2012 12:14:15 +0000 (08:14 -0400)
docs/04_releases.mkd
src/com/gitblit/LuceneExecutor.java
src/com/gitblit/utils/JGitUtils.java

index ac3b31e9824f7c0f11c00482da671b98e7340c6e..a519175a113c96b6b70f22da6fd57b32a2507fae 100644 (file)
@@ -11,6 +11,7 @@ If you are updating from an earlier release AND you have indexed branches with t
 \r
 #### fixes\r
 \r
+- Do not index blobs in submodules (issue 119)\r
 - Restore original user or team object on failure to update (issue 118)\r
 - Repository URL uses `X-Forwarded-Proto` and `X-Forwarded-Port`, if available, for reverse proxy configurations (issue 115)\r
 - Fixes to relative path determination in repository searh algorithm for symlinks (issue 116)\r
index eafb5168ceeaef644e324a3270c9dba71e2ba636..d1c27f4d41350b28ff627ac1b558b2ee30b1aa38 100644 (file)
@@ -494,6 +494,7 @@ public class LuceneExecutor implements Runnable {
                                \r
                                Map<String, ObjectId> paths = new TreeMap<String, ObjectId>();\r
                                while (treeWalk.next()) {\r
+                                       // ensure path is not in a submodule\r
                                        if (treeWalk.getFileMode(0) != FileMode.GITLINK) {\r
                                                paths.put(treeWalk.getPathString(), treeWalk.getObjectId(0));\r
                                        }\r
@@ -679,8 +680,10 @@ public class LuceneExecutor implements Runnable {
                                                // read the blob content\r
                                                String str = JGitUtils.getStringContent(repository, commit.getTree(),\r
                                                                path.path, encodings);\r
-                                               doc.add(new Field(FIELD_CONTENT, str, Store.YES, Index.ANALYZED));\r
-                                               writer.addDocument(doc);\r
+                                               if (str != null) {\r
+                                                       doc.add(new Field(FIELD_CONTENT, str, Store.YES, Index.ANALYZED));\r
+                                                       writer.addDocument(doc);\r
+                                               }\r
                                        }\r
                                }\r
                        }\r
index 4415982a524f1acf4fd5dc0dc015ce79d9443f8d..90e6a76b2edbcc854059f7367ca970d031c3daa0 100644 (file)
@@ -559,18 +559,20 @@ public class JGitUtils {
                                }\r
                                ObjectId entid = tw.getObjectId(0);\r
                                FileMode entmode = tw.getFileMode(0);\r
-                               RevObject ro = rw.lookupAny(entid, entmode.getObjectType());\r
-                               rw.parseBody(ro);\r
-                               ByteArrayOutputStream os = new ByteArrayOutputStream();\r
-                               ObjectLoader ldr = repository.open(ro.getId(), Constants.OBJ_BLOB);\r
-                               byte[] tmp = new byte[4096];\r
-                               InputStream in = ldr.openStream();\r
-                               int n;\r
-                               while ((n = in.read(tmp)) > 0) {\r
-                                       os.write(tmp, 0, n);\r
+                               if (entmode != FileMode.GITLINK) {\r
+                                       RevObject ro = rw.lookupAny(entid, entmode.getObjectType());\r
+                                       rw.parseBody(ro);\r
+                                       ByteArrayOutputStream os = new ByteArrayOutputStream();\r
+                                       ObjectLoader ldr = repository.open(ro.getId(), Constants.OBJ_BLOB);\r
+                                       byte[] tmp = new byte[4096];\r
+                                       InputStream in = ldr.openStream();\r
+                                       int n;\r
+                                       while ((n = in.read(tmp)) > 0) {\r
+                                               os.write(tmp, 0, n);\r
+                                       }\r
+                                       in.close();\r
+                                       content = os.toByteArray();\r
                                }\r
-                               in.close();\r
-                               content = os.toByteArray();\r
                        }\r
                } catch (Throwable t) {\r
                        error(t, repository, "{0} can't find {1} in tree {2}", path, tree.name());\r