@ -1853,23 +1853,28 @@ public class ReceivePack {
/ * *
/ * *
* Send a status report .
* 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
* @param unpackError
* an error that occurred during unpacking , or { @code null }
* an error that occurred during unpacking , or { @code null }
* @param out
* the reporter for sending the status strings .
* @throws java . io . IOException
* @throws java . io . IOException
* an error occurred writing the status report .
* an error occurred writing the status report .
* @since 5 . 6
* @since 5 . 6
* /
* /
private void sendStatusReport ( final boolean forClient ,
private void sendStatusReport ( Throwable unpackError ) throws IOException {
final Throwable unpackError , final Reporter out )
Reporter out = new Reporter ( ) {
throws IOException {
@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 ) {
if ( unpackError ! = null ) {
out . sendString ( "unpack error " + unpackError . getMessage ( ) ) ; //$NON-NLS-1$
out . sendString ( "unpack error " + unpackError . getMessage ( ) ) ; //$NON-NLS-1$
if ( forClient ) {
if ( reportStatus ) {
for ( ReceiveCommand cmd : commands ) {
for ( ReceiveCommand cmd : commands ) {
out . sendString ( "ng " + cmd . getRefName ( ) //$NON-NLS-1$
out . sendString ( "ng " + cmd . getRefName ( ) //$NON-NLS-1$
+ " n/a (unpacker error)" ) ; //$NON-NLS-1$
+ " n/a (unpacker error)" ) ; //$NON-NLS-1$
@ -1878,21 +1883,24 @@ public class ReceivePack {
return ;
return ;
}
}
if ( forClient )
if ( reportStatus ) {
out . sendString ( "unpack ok" ) ; //$NON-NLS-1$
out . sendString ( "unpack ok" ) ; //$NON-NLS-1$
}
for ( ReceiveCommand cmd : commands ) {
for ( ReceiveCommand cmd : commands ) {
if ( cmd . getResult ( ) = = Result . OK ) {
if ( cmd . getResult ( ) = = Result . OK ) {
if ( forClient )
if ( reportStatus ) {
out . sendString ( "ok " + cmd . getRefName ( ) ) ; //$NON-NLS-1$
out . sendString ( "ok " + cmd . getRefName ( ) ) ; //$NON-NLS-1$
}
continue ;
continue ;
}
}
final StringBuilder r = new StringBuilder ( ) ;
final StringBuilder r = new StringBuilder ( ) ;
if ( forClient )
if ( reportStatus ) {
r . append ( "ng " ) . append ( cmd . getRefName ( ) ) . append ( " " ) ; //$NON-NLS-1$ //$NON-NLS-2$
r . append ( "ng " ) . append ( cmd . getRefName ( ) ) . append ( " " ) ; //$NON-NLS-1$ //$NON-NLS-2$
else
} else {
r . append ( " ! [rejected] " ) . append ( cmd . getRefName ( ) ) //$NON-NLS-1$
r . append ( " ! [rejected] " ) . append ( cmd . getRefName ( ) ) //$NON-NLS-1$
. append ( " (" ) ; //$NON-NLS-1$
. append ( " (" ) ; //$NON-NLS-1$
}
switch ( cmd . getResult ( ) ) {
switch ( cmd . getResult ( ) ) {
case NOT_ATTEMPTED :
case NOT_ATTEMPTED :
@ -1939,13 +1947,20 @@ public class ReceivePack {
break ;
break ;
case OK :
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 ;
continue ;
}
}
if ( ! forClient )
if ( ! reportStatus ) {
r . append ( ")" ) ; //$NON-NLS-1$
r . append ( ")" ) ; //$NON-NLS-1$
}
out . sendString ( r . toString ( ) ) ;
out . sendString ( r . toString ( ) ) ;
}
}
} finally {
if ( reportStatus ) {
pckOut . end ( ) ;
}
}
}
}
/ * *
/ * *
@ -2228,22 +2243,7 @@ public class ReceivePack {
unlockPack ( ) ;
unlockPack ( ) ;
}
}
if ( reportStatus ) {
sendStatusReport ( unpackError ) ;
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$
}
} ) ;
}
if ( unpackError ! = null ) {
if ( unpackError ! = null ) {
// we already know which exception to throw. Ignore
// we already know which exception to throw. Ignore