[EGIT PATCH 21/23] Don't accept RefSpec with null source for fetch
RefSpec with null source has no sense, so let's inform about it.
Signed-off-by: Marek Zawirski <marek.zawirski@gmail.com>
---
.../org/spearce/jgit/transport/FetchProcess.java | 4 ++++
.../src/org/spearce/jgit/transport/Transport.java | 5 +++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/FetchProcess.java b/org.spearce.jgit/src/org/spearce/jgit/transport/FetchProcess.java
index c765c12..f9c2266 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/FetchProcess.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/FetchProcess.java
@@ -100,6 +100,10 @@ class FetchProcess {
result.setAdvertisedRefs(conn.getRefsMap());
final Set<Ref> matched = new HashSet<Ref>();
for (final RefSpec spec : toFetch) {
+ if (spec.getSource() == null)
+ throw new TransportException(
+ "Source ref not specified for refspec: " + spec);
+
if (spec.isWildcard())
expandWildcard(spec, matched);
else
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/Transport.java b/org.spearce.jgit/src/org/spearce/jgit/transport/Transport.java
index da5b41e..8260da6 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/Transport.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/Transport.java
@@ -363,14 +363,15 @@ public abstract class Transport {
* @param toFetch
* specification of refs to fetch locally. May be null or the
* empty collection to use the specifications from the
- * RemoteConfig.
+ * RemoteConfig. Source for each RefSpec can't be null.
* @return information describing the tracking refs updated.
* @throws NotSupportedException
* this transport implementation does not support fetching
* objects.
* @throws TransportException
* the remote connection could not be established or object
- * copying (if necessary) failed.
+ * copying (if necessary) failed or update specification was
+ * incorrect.
*/
public FetchResult fetch(final ProgressMonitor monitor,
Collection<RefSpec> toFetch) throws NotSupportedException,
--
1.5.5.3