James Moger
2012-08-07 749110b462b3147c6dfff076fb5d1bf0460a4f99
Do not incrementally index blobs in submodules (issue-119)
3 files modified
32 ■■■■■ changed files
docs/04_releases.mkd 1 ●●●● patch | view | raw | blame | history
src/com/gitblit/LuceneExecutor.java 7 ●●●● patch | view | raw | blame | history
src/com/gitblit/utils/JGitUtils.java 24 ●●●● patch | view | raw | blame | history
docs/04_releases.mkd
@@ -11,6 +11,7 @@
#### fixes
- Do not index blobs in submodules (issue 119)
- Restore original user or team object on failure to update (issue 118)
- Repository URL uses `X-Forwarded-Proto` and `X-Forwarded-Port`, if available, for reverse proxy configurations (issue 115)
- Fixes to relative path determination in repository searh algorithm for symlinks (issue 116)
src/com/gitblit/LuceneExecutor.java
@@ -494,6 +494,7 @@
                
                Map<String, ObjectId> paths = new TreeMap<String, ObjectId>();
                while (treeWalk.next()) {
                    // ensure path is not in a submodule
                    if (treeWalk.getFileMode(0) != FileMode.GITLINK) {
                        paths.put(treeWalk.getPathString(), treeWalk.getObjectId(0));
                    }
@@ -679,8 +680,10 @@
                        // read the blob content
                        String str = JGitUtils.getStringContent(repository, commit.getTree(),
                                path.path, encodings);
                        doc.add(new Field(FIELD_CONTENT, str, Store.YES, Index.ANALYZED));
                        writer.addDocument(doc);
                        if (str != null) {
                            doc.add(new Field(FIELD_CONTENT, str, Store.YES, Index.ANALYZED));
                            writer.addDocument(doc);
                        }
                    }
                }
            }
src/com/gitblit/utils/JGitUtils.java
@@ -559,18 +559,20 @@
                }
                ObjectId entid = tw.getObjectId(0);
                FileMode entmode = tw.getFileMode(0);
                RevObject ro = rw.lookupAny(entid, entmode.getObjectType());
                rw.parseBody(ro);
                ByteArrayOutputStream os = new ByteArrayOutputStream();
                ObjectLoader ldr = repository.open(ro.getId(), Constants.OBJ_BLOB);
                byte[] tmp = new byte[4096];
                InputStream in = ldr.openStream();
                int n;
                while ((n = in.read(tmp)) > 0) {
                    os.write(tmp, 0, n);
                if (entmode != FileMode.GITLINK) {
                    RevObject ro = rw.lookupAny(entid, entmode.getObjectType());
                    rw.parseBody(ro);
                    ByteArrayOutputStream os = new ByteArrayOutputStream();
                    ObjectLoader ldr = repository.open(ro.getId(), Constants.OBJ_BLOB);
                    byte[] tmp = new byte[4096];
                    InputStream in = ldr.openStream();
                    int n;
                    while ((n = in.read(tmp)) > 0) {
                        os.write(tmp, 0, n);
                    }
                    in.close();
                    content = os.toByteArray();
                }
                in.close();
                content = os.toByteArray();
            }
        } catch (Throwable t) {
            error(t, repository, "{0} can't find {1} in tree {2}", path, tree.name());