Thread (3 messages) flat view 3 messages, 2 authors, 2016-06-15
DORMANTno replies

[PATCH] Wait for git diff to finish in git difftool

From: Alex Riesen <hidden>
Date: 2016-06-15 22:46:38
Subsystem: the rest · Maintainer: Linus Torvalds

In ActivetState Perl, exec does not wait for the started program. This
breaks difftool tests and may cause unexpected behaviour: git difftool
has returned, but the rest of code (diff and possibly the interactive
program are still running in the background.

---
 git-difftool.perl |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

2009/4/6 David Aguilar [off-list ref]:
+# Ensures that git-difftool ignores bogus --tool values
+test_expect_success 'difftool ignores bad --tool values' '
+       diff=$(git difftool --no-prompt --tool=bogus-tool branch)
+       test "$?" = 1 &&
+       test "$diff" = ""
+'
This breaks in that piece of ActiveState Perl if git-difftool is to
continue to use exec: exec*(2) semantics are not available there
(as they are not possible in Windows at all).

In this case the script will spawn git-diff and immediately exit with 0.
git-diff will run the bogus-tool in "background" later.

I usually don't care for exit code in a pure UI tool, so the kill signal
is just ORed together with the real exit code just to provide indication
of error.
diff --git a/git-difftool.perl b/git-difftool.perl
index 948ff7f..bd828c2 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -82,4 +82,5 @@ sub generate_command
 }

 setup_environment();
-exec(generate_command());
+my $rc = system(generate_command());
+exit($rc | ($rc >> 8));
-- 
1.6.3.rc0.45.g63634
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help