aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2020-08-29 22:58:33 +0200
committerTeddy Wing2020-08-29 22:58:33 +0200
commitb9729227347e0532891321548b31579b80376bdd (patch)
treea25650cff6467535ad4076b7a4eb23c883be63d9
parent760d49ce6f4a8b1f631fec654ae87300474541a9 (diff)
downloadgit-suggestion-b9729227347e0532891321548b31579b80376bdd.tar.bz2
git-sugdiff: Fix output by waiting for child process
I thought I'd resolved this problem by adding the `--no-pager` flag in 76079daf1e2175d02c9c584e47a21650fce30bb6, but it turns out that didn't fix it. When running the command, I'd get the following output, with the shell prompt preceding the start of the diff, and the command hanging without exiting to a new prompt line until a new interaction: $ ./target/debug/git-sugdiff 459692838 $ diff --git a/src/server.rs b/44ff3b520321467a9220965d13f997690ff3fda7 index d9eee95..44ff3b5 100644 --- a/src/server.rs +++ b/44ff3b520321467a9220965d13f997690ff3fda7 @@ -73,7 +73,7 @@ impl Server { internal_server_error(&mut raw_request.stdout()) }, Error::ConduitResponse { .. } => { error!("Error [-getting-]{+from+} response: {}", e); internal_server_error(&mut raw_request.stdout()) }, Turns out I need to wait for the command to exit in order to properly execute the external command.
-rw-r--r--src/bin/git-sugdiff.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/bin/git-sugdiff.rs b/src/bin/git-sugdiff.rs
index 13c3292..ab893f0 100644
--- a/src/bin/git-sugdiff.rs
+++ b/src/bin/git-sugdiff.rs
@@ -58,7 +58,7 @@ fn main() {
},
};
- match Command::new("git")
+ let mut child = match Command::new("git")
.arg("--no-pager")
.arg("diff")
.args(&diff_args)
@@ -66,6 +66,14 @@ fn main() {
.arg(blob.to_string())
.spawn()
{
+ Ok(c) => c,
+ Err(e) => {
+ gseprintln!(e);
+ process::exit(exitcode::UNAVAILABLE);
+ },
+ };
+
+ match child.wait() {
Err(e) => {
gseprintln!(e);
process::exit(exitcode::UNAVAILABLE);