Skip to content
Permalink
Browse files
git-pr: git diff can exit with code 141
Reviewed-by: rwestberg
  • Loading branch information
edvbld committed Feb 7, 2020
1 parent b0cc35d commit c73064e68f329a0e5b51179faeb55bf3c829fc3f
Showing with 10 additions and 3 deletions.
  1. +10 −3 cli/src/main/java/org/openjdk/skara/cli/GitPr.java
@@ -271,10 +271,13 @@ private static Optional<Issue> getIssue(String s, String project) throws IOExcep
return Optional.empty();
}

private static void await(Process p) throws IOException {
private static void await(Process p, Integer... allowedExitCodes) throws IOException {
var allowed = new HashSet<>(Arrays.asList(allowedExitCodes));
allowed.add(0);
try {
var res = p.waitFor();
if (res != 0) {

if (!allowed.contains(res)) {
throw new IOException("Unexpected exit code " + res);
}
} catch (InterruptedException e) {
@@ -364,7 +367,11 @@ private static void show(String ref, Hash hash, Path dir) throws IOException {
pb.directory(dir.toFile());
}
pb.inheritIO();
await(pb.start());

// git will return 141 (128 + 13) when it receive SIGPIPE (signal 13) from
// e.g. less when a user exits less when looking at a large diff. Therefore
// must allow 141 as a valid exit code.
await(pb.start(), 141);
}

private static void gimport() throws IOException {

0 comments on commit c73064e

Please sign in to comment.