git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Riesen <raa.lkml@gmail.com>
To: David Aguilar <davvid@gmail.com>
Cc: gitster@pobox.com, git@vger.kernel.org, charles@hashpling.org,
	markus.heidelberg@web.de
Subject: [PATCH] Wait for git diff to finish in git difftool
Date: Wed, 22 Apr 2009 09:27:22 +0200	[thread overview]
Message-ID: <81b0412b0904220027t7afd1ed7xc57c479ef8cdb6b9@mail.gmail.com> (raw)

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 <davvid@gmail.com>:
> +# 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

             reply	other threads:[~2009-04-22  7:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-22  7:27 Alex Riesen [this message]
2009-04-22  8:26 ` [PATCH] Wait for git diff to finish in git difftool David Aguilar
2009-04-22 11:04   ` Alex Riesen
2009-04-22 18:59     ` Junio C Hamano
2009-04-22 20:40       ` Alex Riesen
2009-04-23  4:21         ` Junio C Hamano
2009-04-23  7:33           ` Alex Riesen
2009-04-23  8:26             ` Junio C Hamano
2009-04-23  9:52               ` Alex Riesen
2009-04-23 14:00                 ` Sverre Rabbelier
2009-04-23 14:51                 ` Junio C Hamano
2009-04-23 18:57                   ` Alex Riesen
2009-04-23 19:08                     ` Alex Riesen
2009-04-23 19:18                       ` [PATCH] Explain seemingly pointless use of system in difftool Alex Riesen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=81b0412b0904220027t7afd1ed7xc57c479ef8cdb6b9@mail.gmail.com \
    --to=raa.lkml@gmail.com \
    --cc=charles@hashpling.org \
    --cc=davvid@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=markus.heidelberg@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).