Merge branch 'stable-3.0' into stable-3.1

* stable-3.0:
  LazyPostReceiveHookChain: Catch IllegalStateException on ReceivePack.getPackSize

Change-Id: I86fce58067fff730576a34524379bad967157f39
This commit is contained in:
David Pursehouse
2019-11-13 16:10:00 -08:00

View File

@@ -79,9 +79,20 @@ public class LazyPostReceiveHookChain implements PostReceiveHook {
}
public static boolean affectsSize(ReceivePack rp, Collection<ReceiveCommand> commands) {
if (commands.stream().allMatch(c -> c.getType() == ReceiveCommand.Type.DELETE)) {
long packSize;
try {
packSize = rp.getPackSize();
} catch (IllegalStateException e) {
// No pack was received, i.e. ref deletion or wind back
return false;
}
return rp.getPackSize() > 0L;
if (packSize > 0L) {
for (ReceiveCommand cmd : commands) {
if (cmd.getType() != ReceiveCommand.Type.DELETE) {
return true;
}
}
}
return false;
}
}