diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2011-03-16 21:50:42 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2011-03-17 10:53:19 -0700 |
commit | c9a6980a422b485c23bfd99a939a378c5dd5114c (patch) | |
tree | 63a3a6166fc428f0bb021055c43617a0d9e5415f /org.eclipse.jgit/src | |
parent | b0a29c3fcfae9f23949db5cbee46db30448531cf (diff) | |
download | jgit-c9a6980a422b485c23bfd99a939a378c5dd5114c.tar.gz jgit-c9a6980a422b485c23bfd99a939a378c5dd5114c.zip |
UploadPack: Report invalid want lines with ERR
Instead of aborting hard with a server-side exception, report an error
to the client with "ERR %s" in a context where the client is expecting
ACK/NAK. Older clients will report this text to the user, but newer
ones know how to format this message in a more user-friendly way.
Change-Id: I1879b38988ba66f648c069c10dbfa14c3f34adb2
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java | 2 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java | 16 |
2 files changed, 11 insertions, 7 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java b/org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java index 1ce088461f..5877b4f6a6 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java @@ -363,7 +363,6 @@ public class JGitText extends TranslationBundle { /***/ public String notAuthorized; /***/ public String notAValidPack; /***/ public String notFound; - /***/ public String notValid; /***/ public String nothingToFetch; /***/ public String nothingToPush; /***/ public String notMergedExceptionMessage; @@ -526,6 +525,7 @@ public class JGitText extends TranslationBundle { /***/ public String uriNotFound; /***/ public String userConfigFileInvalid; /***/ public String walkFailure; + /***/ public String wantNotValid; /***/ public String windowSizeMustBeLesserThanLimit; /***/ public String windowSizeMustBePowerOf2; /***/ public String writeTimedOut; 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 58a48f10e7..4b225575e8 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java @@ -511,10 +511,12 @@ public class UploadPack { try { obj = q.next(); } catch (MissingObjectException notFound) { - if (wantIds.contains(notFound.getObjectId())) { - throw new PackProtocolException( - MessageFormat.format(JGitText.get().notValid, - notFound.getMessage()), notFound); + ObjectId id = notFound.getObjectId(); + if (wantIds.contains(id)) { + String msg = MessageFormat.format( + JGitText.get().wantNotValid, id.name()); + pckOut.writeString("ERR " + msg); + throw new PackProtocolException(msg, notFound); } continue; } @@ -526,8 +528,10 @@ public class UploadPack { // if (wantIds.remove(obj)) { if (!advertised.contains(obj)) { - throw new PackProtocolException(MessageFormat.format( - JGitText.get().notValid, obj.name())); + String msg = MessageFormat.format( + JGitText.get().wantNotValid, obj.name()); + pckOut.writeString("ERR " + msg); + throw new PackProtocolException(msg); } if (!obj.has(WANT)) { |