{"thread":{"id":"19203","subject":"[PATCH] Allow monitor/unintersting objects to be null","startedAt":"2009-05-06T19:57:16Z","lastAt":"2009-05-06T20:02:35Z","messageCount":2,"participants":["Alex Blewitt","Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"113117","messageId":"1241639836-6719-1-git-send-email-alex.blewitt@gmail.com","threadId":"19203","inReplyTo":null,"subject":"[PATCH] Allow monitor/unintersting objects to be null","fromName":"Alex Blewitt","fromEmail":"alex.blewitt@gmail.com","sentAt":"2009-05-06T19:57:16Z","receivedAt":"2009-05-06T19:57:16Z","isPatch":true,"sender":{"key":"alex.blewitt@gmail.com","avatar":"https://gravatar.com/avatar/fb95a3b593b290f03a8d3b022c20b2825205702c5651f731f65d33512dfe6ab2?d=mp&s=160"},"body":"---\n .../src/org/spearce/jgit/lib/PackWriter.java       |    5 +++--\n 1 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java b/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java\nindex ea63942..3d7004d 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java\n@@ -230,8 +230,8 @@ public class PackWriter {\n \tpublic PackWriter(final Repository repo, final ProgressMonitor imonitor,\n \t\t\tfinal ProgressMonitor wmonitor) {\n \t\tthis.db = repo;\n-\t\tinitMonitor = imonitor;\n-\t\twriteMonitor = wmonitor;\n+\t\tinitMonitor = (imonitor == null ? new NullProgressMonitor() : imonitor);\n+\t\twriteMonitor = (wmonitor == null ? new NullProgressMonitor() : wmonitor);\n \t\tthis.deflater = new Deflater(db.getConfig().getCore().getCompression());\n \t\toutputVersion = repo.getConfig().getCore().getPackIndexVersion();\n \t}\n@@ -829,6 +829,7 @@ public class PackWriter {\n \t\t\tRevObject o = walker.parseAny(id);\n \t\t\twalker.markStart(o);\n \t\t}\n+\t\tif (uninterestingObjects != null)\n \t\tfor (ObjectId id : uninterestingObjects) {\n \t\t\tfinal RevObject o;\n \t\t\ttry {\n-- \n1.6.2.2\n"},{"id":"113118","messageId":"20090506200235.GI30527@spearce.org","threadId":"19203","inReplyTo":"1241639836-6719-1-git-send-email-alex.blewitt@gmail.com","subject":"Re: [PATCH] Allow monitor/unintersting objects to be null","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-05-06T20:02:35Z","receivedAt":"2009-05-06T20:02:35Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Alex Blewitt <alex.blewitt@gmail.com> wrote:\n> ---\n>  .../src/org/spearce/jgit/lib/PackWriter.java       |    5 +++--\n>  1 files changed, 3 insertions(+), 2 deletions(-)\n> \n> diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java b/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java\n> index ea63942..3d7004d 100644\n> --- a/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java\n> +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java\n> @@ -230,8 +230,8 @@ public class PackWriter {\n>  \tpublic PackWriter(final Repository repo, final ProgressMonitor imonitor,\n>  \t\t\tfinal ProgressMonitor wmonitor) {\n>  \t\tthis.db = repo;\n> -\t\tinitMonitor = imonitor;\n> -\t\twriteMonitor = wmonitor;\n> +\t\tinitMonitor = (imonitor == null ? new NullProgressMonitor() : imonitor);\n> +\t\twriteMonitor = (wmonitor == null ? new NullProgressMonitor() : wmonitor);\n\nCan't we use NullProgressMonitor.INSTANCE instead?\n\nAlso the () around the ?: expression are unnecessary here and our\ncoding style tends not to include them.\n\n> @@ -829,6 +829,7 @@ public class PackWriter {\n>  \t\t\tRevObject o = walker.parseAny(id);\n>  \t\t\twalker.markStart(o);\n>  \t\t}\n> +\t\tif (uninterestingObjects != null)\n>  \t\tfor (ObjectId id : uninterestingObjects) {\n\nPlease fix the indentation of the other code to be properly under\nthe if, or change the variable to be non-final and assign it\nan empty list if its null, so the for() runs but doesn't crash.\nOr do that in the only caller, preparePack(Collection,Collection).\n\n-- \nShawn.\n"}]}