Skip to contentSkip to conversation

Allow monitor/unintersting objects to be null

PATCH In review Alex Blewitt 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow monitor/unintersting objects to be null

---
 .../src/org/spearce/jgit/lib/PackWriter.java       |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java +3 -2
index ea63942..3d7004d 100644
@@ -230,8 +230,8 @@ public class PackWriter {
 	public PackWriter(final Repository repo, final ProgressMonitor imonitor,
 			final ProgressMonitor wmonitor) {
 		this.db = repo;
-		initMonitor = imonitor;
-		writeMonitor = wmonitor;
+		initMonitor = (imonitor == null ? new NullProgressMonitor() : imonitor);
+		writeMonitor = (wmonitor == null ? new NullProgressMonitor() : wmonitor);
 		this.deflater = new Deflater(db.getConfig().getCore().getCompression());
 		outputVersion = repo.getConfig().getCore().getPackIndexVersion();
 	}
@@ -829,6 +829,7 @@ public class PackWriter {
 			RevObject o = walker.parseAny(id);
 			walker.markStart(o);
 		}
+		if (uninterestingObjects != null)
 		for (ObjectId id : uninterestingObjects) {
 			final RevObject o;
 			try {
Signature · 1 line
1.6.2.2
#1 lore raw
Quoted 9 lines · Alex Blewitt
---
 .../src/org/spearce/jgit/lib/PackWriter.java       |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java +0 -0
index ea63942..3d7004d 100644

org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java public class PackWriter { · line 234

Quoted 7 lines
org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java +2 -2
@@ -230,8 +230,8 @@ public class PackWriter {
 	public PackWriter(final Repository repo, final ProgressMonitor imonitor,
 			final ProgressMonitor wmonitor) {
 		this.db = repo;
-		initMonitor = imonitor;
-		writeMonitor = wmonitor;
+		initMonitor = (imonitor == null ? new NullProgressMonitor() : imonitor);
+		writeMonitor = (wmonitor == null ? new NullProgressMonitor() : wmonitor);

Can't we use NullProgressMonitor.INSTANCE instead?

Also the () around the ?: expression are unnecessary here and our coding style tends not to include them.

org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java public class PackWriter { · line 833

Quoted 6 lines
org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java +1 -0
@@ -829,6 +829,7 @@ public class PackWriter {
 			RevObject o = walker.parseAny(id);
 			walker.markStart(o);
 		}
+		if (uninterestingObjects != null)
 		for (ObjectId id : uninterestingObjects) {

Please fix the indentation of the other code to be properly under the if, or change the variable to be non-final and assign it an empty list if its null, so the for() runs but doesn't crash. Or do that in the only caller, preparePack(Collection,Collection).

Signature · 1 line
Shawn.