Refactor parsing of "filter" into its own method

The implementation of protocol v2 will also need to parse the "filter"
option, so refactor it into its own method.

Change-Id: I751f6e6ca63fab873298594653a3885202297a2e
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
index 8a4cae4..4538ce2 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
@@ -1371,6 +1371,33 @@
 		return msgOut;
 	}
 
+	private void parseFilter(String arg) throws PackProtocolException {
+		if (arg.equals("blob:none")) { //$NON-NLS-1$
+			filterBlobLimit = 0;
+		} else if (arg.startsWith("blob:limit=")) { //$NON-NLS-1$
+			try {
+				filterBlobLimit = Long.parseLong(
+						arg.substring("blob:limit=".length())); //$NON-NLS-1$
+			} catch (NumberFormatException e) {
+				throw new PackProtocolException(
+						MessageFormat.format(JGitText.get().invalidFilter,
+								arg));
+			}
+		}
+		/*
+		 * We must have (1) either "blob:none" or
+		 * "blob:limit=" set (because we only support
+		 * blob size limits for now), and (2) if the
+		 * latter, then it must be nonnegative. Throw
+		 * if (1) or (2) is not met.
+		 */
+		if (filterBlobLimit < 0) {
+			throw new PackProtocolException(
+					MessageFormat.format(JGitText.get().invalidFilter,
+							arg));
+		}
+	}
+
 	private void recvWants() throws IOException {
 		boolean isFirst = true;
 		boolean filterReceived = false;
@@ -1411,30 +1438,7 @@
 				}
 				filterReceived = true;
 
-				if (arg.equals("blob:none")) { //$NON-NLS-1$
-					filterBlobLimit = 0;
-				} else if (arg.startsWith("blob:limit=")) { //$NON-NLS-1$
-					try {
-						filterBlobLimit = Long.parseLong(
-								arg.substring("blob:limit=".length())); //$NON-NLS-1$
-					} catch (NumberFormatException e) {
-						throw new PackProtocolException(
-								MessageFormat.format(JGitText.get().invalidFilter,
-										arg));
-					}
-				}
-				/*
-				 * We must have (1) either "blob:none" or
-				 * "blob:limit=" set (because we only support
-				 * blob size limits for now), and (2) if the
-				 * latter, then it must be nonnegative. Throw
-				 * if (1) or (2) is not met.
-				 */
-				if (filterBlobLimit < 0) {
-					throw new PackProtocolException(
-							MessageFormat.format(JGitText.get().invalidFilter,
-									arg));
-				}
+				parseFilter(arg);
 				continue;
 			}