@ -1853,23 +1853,28 @@ public class ReceivePack {
/ * *
* Send a status report .
*
* @param forClient
* true if this report is for a Git client , false if it is for an
* end - user .
* @param unpackError
* an error that occurred during unpacking , or { @code null }
* @param out
* the reporter for sending the status strings .
* @throws java . io . IOException
* an error occurred writing the status report .
* @since 5 . 6
* /
private void sendStatusReport ( final boolean forClient ,
final Throwable unpackError , final Reporter out )
throws IOException {
private void sendStatusReport ( Throwable unpackError ) throws IOException {
Reporter out = new Reporter ( ) {
@Override
void sendString ( String s ) throws IOException {
if ( reportStatus ) {
pckOut . writeString ( s + "\n" ) ; //$NON-NLS-1$
} else if ( msgOut ! = null ) {
msgOut . write ( Constants . encode ( s + "\n" ) ) ; //$NON-NLS-1$
}
}
} ;
try {
if ( unpackError ! = null ) {
out . sendString ( "unpack error " + unpackError . getMessage ( ) ) ; //$NON-NLS-1$
if ( forClient ) {
if ( reportStatus ) {
for ( ReceiveCommand cmd : commands ) {
out . sendString ( "ng " + cmd . getRefName ( ) //$NON-NLS-1$
+ " n/a (unpacker error)" ) ; //$NON-NLS-1$
@ -1878,21 +1883,24 @@ public class ReceivePack {
return ;
}
if ( forClient )
if ( reportStatus ) {
out . sendString ( "unpack ok" ) ; //$NON-NLS-1$
}
for ( ReceiveCommand cmd : commands ) {
if ( cmd . getResult ( ) = = Result . OK ) {
if ( forClient )
if ( reportStatus ) {
out . sendString ( "ok " + cmd . getRefName ( ) ) ; //$NON-NLS-1$
}
continue ;
}
final StringBuilder r = new StringBuilder ( ) ;
if ( forClient )
if ( reportStatus ) {
r . append ( "ng " ) . append ( cmd . getRefName ( ) ) . append ( " " ) ; //$NON-NLS-1$ //$NON-NLS-2$
else
} else {
r . append ( " ! [rejected] " ) . append ( cmd . getRefName ( ) ) //$NON-NLS-1$
. append ( " (" ) ; //$NON-NLS-1$
}
switch ( cmd . getResult ( ) ) {
case NOT_ATTEMPTED :
@ -1939,13 +1947,20 @@ public class ReceivePack {
break ;
case OK :
// We shouldn't have reached this case (see 'ok' case above).
// We shouldn't have reached this case (see 'ok' case
// above).
continue ;
}
if ( ! forClient )
if ( ! reportStatus ) {
r . append ( ")" ) ; //$NON-NLS-1$
}
out . sendString ( r . toString ( ) ) ;
}
} finally {
if ( reportStatus ) {
pckOut . end ( ) ;
}
}
}
/ * *
@ -2228,22 +2243,7 @@ public class ReceivePack {
unlockPack ( ) ;
}
if ( reportStatus ) {
sendStatusReport ( true , unpackError , new Reporter ( ) {
@Override
void sendString ( String s ) throws IOException {
pckOut . writeString ( s + "\n" ) ; //$NON-NLS-1$
}
} ) ;
pckOut . end ( ) ;
} else if ( msgOut ! = null ) {
sendStatusReport ( false , unpackError , new Reporter ( ) {
@Override
void sendString ( String s ) throws IOException {
msgOut . write ( Constants . encode ( s + "\n" ) ) ; //$NON-NLS-1$
}
} ) ;
}
sendStatusReport ( unpackError ) ;
if ( unpackError ! = null ) {
// we already know which exception to throw. Ignore