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 09acfdf58..3b6683954 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java @@ -309,10 +309,10 @@ public Set getOptions() { /** * (Possibly short) ref names, ancestors of which the client has asked us - * not to send using --shallow-exclude. Cannot be non-null if depth is + * not to send using --shallow-exclude. Cannot be non-empty if depth is * nonzero. */ - private @Nullable List shallowExcludeRefs; + private List shallowExcludeRefs = new ArrayList<>(); /** Commit time of the oldest common commit, in seconds. */ private int oldestTime; @@ -1023,16 +1023,12 @@ private void fetchV2() throws IOException { throw new PackProtocolException( JGitText.get().deepenSinceWithDeepen); } - if (shallowExcludeRefs != null) { + if (!shallowExcludeRefs.isEmpty()) { throw new PackProtocolException( JGitText.get().deepenNotWithDeepen); } } else if (line.startsWith("deepen-not ")) { //$NON-NLS-1$ - List exclude = shallowExcludeRefs; - if (exclude == null) { - exclude = shallowExcludeRefs = new ArrayList<>(); - } - exclude.add(line.substring(11)); + shallowExcludeRefs.add(line.substring(11)); if (depth != 0) { throw new PackProtocolException( JGitText.get().deepenNotWithDeepen); @@ -1071,7 +1067,7 @@ private void fetchV2() throws IOException { if (!clientShallowCommits.isEmpty()) { verifyClientShallow(); } - if (depth != 0 || shallowSince != 0 || shallowExcludeRefs != null) { + if (depth != 0 || shallowSince != 0 || !shallowExcludeRefs.isEmpty()) { shallowCommits = new ArrayList<>(); processShallow(shallowCommits, unshallowCommits, false); } @@ -1238,7 +1234,7 @@ private void processShallow(@Nullable List shallowCommits, boolean writeToPckOut) throws IOException { if (options.contains(OPTION_DEEPEN_RELATIVE) || shallowSince != 0 || - shallowExcludeRefs != null) { + !shallowExcludeRefs.isEmpty()) { // TODO(jonathantanmy): Implement deepen-relative, deepen-since, // and deepen-not. throw new UnsupportedOperationException();