]> source.dussan.org Git - jgit.git/commitdiff
Fixed several NPEs in the Fetch CLI 45/2345/2
authorSasa Zivkov <sasa.zivkov@sap.com>
Wed, 26 Jan 2011 16:28:47 +0000 (17:28 +0100)
committerChris Aniszczyk <caniszczyk@gmail.com>
Wed, 26 Jan 2011 17:38:59 +0000 (11:38 -0600)
The Fetch command line was failing with NPE in case some options were omitted.
Additionally, it was setting a negative timeout when no timeout option was used
which caused HttpURLConnection to throw an IllegalArgumentException.

Change-Id: I2c67e2e1a03044284d183d73f0b82bb7ff79de95
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java

index e2467b2c3e72870238f19505844c908a653d8f6c..f100390e4ef70cec115f6b90fa288d0b7a856648 100644 (file)
@@ -93,13 +93,18 @@ class Fetch extends AbstractFetchCommand {
        protected void run() throws Exception {
                Git git = new Git(db);
                FetchCommand fetch = git.fetch();
-               fetch.setCheckFetchedObjects(fsck.booleanValue());
-               fetch.setRemoveDeletedRefs(prune.booleanValue());
-               fetch.setRefSpecs(toget);
-               fetch.setTimeout(timeout);
+               if (fsck != null)
+                       fetch.setCheckFetchedObjects(fsck.booleanValue());
+               if (prune != null)
+                       fetch.setRemoveDeletedRefs(prune.booleanValue());
+               if (toget != null)
+                       fetch.setRefSpecs(toget);
+               if (0 <= timeout)
+                       fetch.setTimeout(timeout);
                fetch.setDryRun(dryRun);
                fetch.setRemote(remote);
-               fetch.setThin(thin.booleanValue());
+               if (thin != null)
+                       fetch.setThin(thin.booleanValue());
                fetch.setProgressMonitor(new TextProgressMonitor());
 
                FetchResult result = fetch.call();