]> source.dussan.org Git - jgit.git/commitdiff
Allow UploadPack requests with no options 27/15227/1
authorShawn Pearce <spearce@spearce.org>
Wed, 7 Aug 2013 22:43:58 +0000 (15:43 -0700)
committerShawn Pearce <spearce@spearce.org>
Wed, 7 Aug 2013 22:44:02 +0000 (15:44 -0700)
UploadPack can be invoked with no capabilities selected by the
client if the client is an ancient version of Git that nobody in
their right mind should still be using. Or if the client is very
broken and does not want to use any of the newer features added to
the protocol since its inception.

Change-Id: I3baa6f90e6a41a37a8eab8449a3cc41f4efcb91a

org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

index 836376ce113cd4728a5dfd08beb5d00b4a60825a..f0ee974177a4b361018875f916e38266cb18e06e 100644 (file)
@@ -868,10 +868,13 @@ public class UploadPack {
                        if (!line.startsWith("want ") || line.length() < 45) //$NON-NLS-1$
                                throw new PackProtocolException(MessageFormat.format(JGitText.get().expectedGot, "want", line)); //$NON-NLS-1$
 
-                       if (isFirst && line.length() > 45) {
-                               final FirstLine firstLine = new FirstLine(line);
-                               options = firstLine.getOptions();
-                               line = firstLine.getLine();
+                       if (isFirst) {
+                               if (line.length() > 45) {
+                                       FirstLine firstLine = new FirstLine(line);
+                                       options = firstLine.getOptions();
+                                       line = firstLine.getLine();
+                               } else
+                                       options = Collections.emptySet();
                        }
 
                        wantIds.add(ObjectId.fromString(line.substring(5)));