Browse Source

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>
stable-0.12
Shawn O. Pearce 14 years ago
parent
commit
c9a6980a42
  1. 2
      org.eclipse.jgit/resources/org/eclipse/jgit/JGitText.properties
  2. 2
      org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java
  3. 16
      org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

2
org.eclipse.jgit/resources/org/eclipse/jgit/JGitText.properties

@ -303,7 +303,6 @@ notASCIIString=Not ASCII string: {0}
notAuthorized=not authorized
notAValidPack=Not a valid pack {0}
notFound=not found.
notValid={0} not valid
nothingToFetch=Nothing to fetch.
nothingToPush=Nothing to push.
notMergedExceptionMessage=Branch was not deleted as it has not been merged yet; use the force option to delete it anyway
@ -466,6 +465,7 @@ updatingRefFailed=Updating the ref {0} to {1} failed. ReturnCode from RefUpdate.
uriNotFound={0} not found
userConfigFileInvalid=User config file {0} invalid {1}
walkFailure=Walk failure.
wantNotValid=want {0} not valid
windowSizeMustBeLesserThanLimit=Window size must be < limit
windowSizeMustBePowerOf2=Window size must be power of 2
writeTimedOut=Write timed out

2
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;

16
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)) {

Loading…
Cancel
Save