summaryrefslogtreecommitdiffstats
path: root/src/com/gitblit
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2012-08-07 08:14:15 -0400
committerJames Moger <james.moger@gitblit.com>2012-08-07 08:14:15 -0400
commit749110b462b3147c6dfff076fb5d1bf0460a4f99 (patch)
treec5a1868c02e8196db4588d5df8317702ef4732a9 /src/com/gitblit
parenta02998032e7077e3e744d5725485023097bf30f0 (diff)
downloadgitblit-749110b462b3147c6dfff076fb5d1bf0460a4f99.tar.gz
gitblit-749110b462b3147c6dfff076fb5d1bf0460a4f99.zip
Do not incrementally index blobs in submodules (issue 119)
Diffstat (limited to 'src/com/gitblit')
-rw-r--r--src/com/gitblit/LuceneExecutor.java7
-rw-r--r--src/com/gitblit/utils/JGitUtils.java24
2 files changed, 18 insertions, 13 deletions
diff --git a/src/com/gitblit/LuceneExecutor.java b/src/com/gitblit/LuceneExecutor.java
index eafb5168..d1c27f4d 100644
--- a/src/com/gitblit/LuceneExecutor.java
+++ b/src/com/gitblit/LuceneExecutor.java
@@ -494,6 +494,7 @@ public class LuceneExecutor implements Runnable {
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 @@ public class LuceneExecutor implements Runnable {
// 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);
+ }
}
}
}
diff --git a/src/com/gitblit/utils/JGitUtils.java b/src/com/gitblit/utils/JGitUtils.java
index 4415982a..90e6a76b 100644
--- a/src/com/gitblit/utils/JGitUtils.java
+++ b/src/com/gitblit/utils/JGitUtils.java
@@ -559,18 +559,20 @@ public class JGitUtils {
}
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());