in org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java [1828:1934]
private void sendStatusReport(Throwable unpackError) throws IOException {
Reporter out = new Reporter() {
@Override
void sendString(String s) throws IOException {
if (reportStatus) {
pckOut.writeString(s + '\n');
} else if (msgOut != null) {
msgOut.write(Constants.encode(s + '\n'));
}
}
};
try {
if (unpackError != null) {
out.sendString("unpack error " + unpackError.getMessage()); //$NON-NLS-1$
if (reportStatus) {
for (ReceiveCommand cmd : commands) {
out.sendString("ng " + cmd.getRefName() //$NON-NLS-1$
+ " n/a (unpacker error)"); //$NON-NLS-1$
}
}
return;
}
if (reportStatus) {
out.sendString("unpack ok"); //$NON-NLS-1$
}
for (ReceiveCommand cmd : commands) {
if (cmd.getResult() == Result.OK) {
if (reportStatus) {
out.sendString("ok " + cmd.getRefName()); //$NON-NLS-1$
}
continue;
}
final StringBuilder r = new StringBuilder();
if (reportStatus) {
r.append("ng ").append(cmd.getRefName()).append(" "); //$NON-NLS-1$ //$NON-NLS-2$
} else {
r.append(" ! [rejected] ").append(cmd.getRefName()) //$NON-NLS-1$
.append(" ("); //$NON-NLS-1$
}
if (cmd.getResult() == Result.REJECTED_MISSING_OBJECT) {
if (cmd.getMessage() == null)
r.append("missing object(s)"); //$NON-NLS-1$
else if (cmd.getMessage()
.length() == Constants.OBJECT_ID_STRING_LENGTH) {
// TODO: Using get/setMessage to store an OID is a
// misuse. The caller should set a full error message.
r.append("object "); //$NON-NLS-1$
r.append(cmd.getMessage());
r.append(" missing"); //$NON-NLS-1$
} else {
r.append(cmd.getMessage());
}
} else if (cmd.getMessage() != null) {
r.append(cmd.getMessage());
} else {
switch (cmd.getResult()) {
case NOT_ATTEMPTED:
r.append("server bug; ref not processed"); //$NON-NLS-1$
break;
case REJECTED_NOCREATE:
r.append("creation prohibited"); //$NON-NLS-1$
break;
case REJECTED_NODELETE:
r.append("deletion prohibited"); //$NON-NLS-1$
break;
case REJECTED_NONFASTFORWARD:
r.append("non-fast forward"); //$NON-NLS-1$
break;
case REJECTED_CURRENT_BRANCH:
r.append("branch is currently checked out"); //$NON-NLS-1$
break;
case REJECTED_OTHER_REASON:
r.append("unspecified reason"); //$NON-NLS-1$
break;
case LOCK_FAILURE:
r.append("failed to lock"); //$NON-NLS-1$
break;
case REJECTED_MISSING_OBJECT:
case OK:
// We shouldn't have reached this case (see 'ok' case
// above and if-statement above).
throw new AssertionError();
}
}
if (!reportStatus) {
r.append(")"); //$NON-NLS-1$
}
out.sendString(r.toString());
}
} finally {
if (reportStatus) {
pckOut.end();
}
}
}