All of lore.kernel.org
 help / color / mirror / Atom feed
* t7800-difftool.sh failure on pu
@ 2012-03-29 18:12 Ramsay Jones
  2012-03-29 21:26 ` Junio C Hamano
  2012-04-02 17:09 ` Tim Henigan
  0 siblings, 2 replies; 7+ messages in thread
From: Ramsay Jones @ 2012-03-29 18:12 UTC (permalink / raw)
  To: tim.henigan; +Cc: Junio C Hamano, GIT Mailing-list

Hi Tim,

With the current pu branch, I have t7800.3 (difftool ignores bad --tool values)
failing on Linux (I haven't tried cygwin or mingw yet). The failure is caused
by the test for the value of the exit code; for me the exit code is 9 not 1.

I have investigated, briefly, and found *two* alternatives for a fix. ;-)

The first option is to (effectively) revert commit 0440ed72 ("difftool: replace
system call with Git::command_noisy", 22-03-2012), like so:

-- >8 --
diff --git a/git-difftool.perl b/git-difftool.perl
index e1754ff..49613b1 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -237,5 +237,7 @@ if (defined($dirdiff)) {
 
 	$ENV{GIT_PAGER} = '';
 	$ENV{GIT_EXTERNAL_DIFF} = 'git-difftool--helper';
-	git_cmd_try { Git::command_noisy(('diff', @ARGV)) } 'exit code %d';
+	my @command = ('git', 'diff', @ARGV);
+	my $rc = system(@command);
+	exit($rc | ($rc >> 8));
 }
-- 8< --

The second option is a bit of a mystery, since I don't see why it is necessary
or why it works! :-P

First take a look at the following:

$ perl -e 'print $!+0, " $!\n";'
0 
$ echo $?
0

$ perl -e 'use Carp qw(croak); print $!+0, " $!\n";'
9 Bad file descriptor
$ echo $?
0

$ perl -e 'use Carp qw(croak); print $!+0, " $!\n"; croak oops;'
9 Bad file descriptor
oops at -e line 1
$ echo $?
9

$ perl -e 'use Carp qw(croak); print $!+0, " $!\n"; $!=0; croak oops;'
9 Bad file descriptor
oops at -e line 1
$ echo $?
255

$ perl -e 'use Carp qw(croak); print $!+0, " $!\n"; $!=0;  $?=1<<8; croak oops;'
9 Bad file descriptor
oops at -e line 1
$ echo $?
1

$ 

So, it seems that a stray non-zero errno (Bad file descriptor) is finding it's
way to the perl exit value via the die call from within croak(). In particular,
the call to croak within git_cmd_try() from Git.pm.

However, I don't see why this is happening, since just before the call to croak
the perl vars $! (errno) and $? (exit status) are set to the *correct* values.
Namely, $! is zero and $? is 256 (1<<8). As you can see from the above, that
*should* result in the correct exit code. However, unlike above, git-difftool.perl
returns 9.

Since 'croak' exits via a 'die' call, in desperation, I tried the following
patch - and it works! Just don't ask me why. :-D

-- 8< --
diff --git a/perl/Git.pm b/perl/Git.pm
index 1c96a20..264a45f 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -1258,7 +1258,7 @@ sub git_cmd_try(&$) {
 		# We can't croak here since Error.pm would mangle
 		# that to Error::Simple.
 	};
-	$err and croak $err;
+	$err and die $err;
 	return $array ? @result : $result[0];
 }
 
-- >8 --

HTH

ATB,
Ramsay Jones

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: t7800-difftool.sh failure on pu
  2012-03-29 18:12 t7800-difftool.sh failure on pu Ramsay Jones
@ 2012-03-29 21:26 ` Junio C Hamano
  2012-03-31  4:05   ` David Aguilar
  2012-04-03 17:53   ` Ramsay Jones
  2012-04-02 17:09 ` Tim Henigan
  1 sibling, 2 replies; 7+ messages in thread
From: Junio C Hamano @ 2012-03-29 21:26 UTC (permalink / raw)
  To: Ramsay Jones; +Cc: tim.henigan, GIT Mailing-list

Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:

> Hi Tim,
>
> With the current pu branch, I have t7800.3 (difftool ignores bad --tool values)
> failing on Linux (I haven't tried cygwin or mingw yet). The failure is caused
> by the test for the value of the exit code; for me the exit code is 9 not 1.
>
> I have investigated, briefly, and found *two* alternatives for a fix. ;-)
>
> The first option is to (effectively) revert commit 0440ed72 ("difftool: replace
> system call with Git::command_noisy", 22-03-2012), like so:
>
> -- >8 --
> diff --git a/git-difftool.perl b/git-difftool.perl
> index e1754ff..49613b1 100755
> --- a/git-difftool.perl
> +++ b/git-difftool.perl
> @@ -237,5 +237,7 @@ if (defined($dirdiff)) {
>  
>  	$ENV{GIT_PAGER} = '';
>  	$ENV{GIT_EXTERNAL_DIFF} = 'git-difftool--helper';
> -	git_cmd_try { Git::command_noisy(('diff', @ARGV)) } 'exit code %d';
> +	my @command = ('git', 'diff', @ARGV);
> +	my $rc = system(@command);
> +	exit($rc | ($rc >> 8));
>  }
> -- 8< --

I would prefer this, regardless of the issue.

I actually recall asking Tim about the exit status when I reviewed this
change.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: t7800-difftool.sh failure on pu
  2012-03-29 21:26 ` Junio C Hamano
@ 2012-03-31  4:05   ` David Aguilar
  2012-04-02 17:19     ` Tim Henigan
  2012-04-03 17:53   ` Ramsay Jones
  1 sibling, 1 reply; 7+ messages in thread
From: David Aguilar @ 2012-03-31  4:05 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Ramsay Jones, tim.henigan, GIT Mailing-list

On Thu, Mar 29, 2012 at 2:26 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:
>
>> Hi Tim,
>>
>> With the current pu branch, I have t7800.3 (difftool ignores bad --tool values)
>> failing on Linux (I haven't tried cygwin or mingw yet). The failure is caused
>> by the test for the value of the exit code; for me the exit code is 9 not 1.
>>
>> I have investigated, briefly, and found *two* alternatives for a fix. ;-)
>>
>> The first option is to (effectively) revert commit 0440ed72 ("difftool: replace
>> system call with Git::command_noisy", 22-03-2012), like so:
>>
>> -- >8 --
>> diff --git a/git-difftool.perl b/git-difftool.perl
>> index e1754ff..49613b1 100755
>> --- a/git-difftool.perl
>> +++ b/git-difftool.perl
>> @@ -237,5 +237,7 @@ if (defined($dirdiff)) {
>>
>>       $ENV{GIT_PAGER} = '';
>>       $ENV{GIT_EXTERNAL_DIFF} = 'git-difftool--helper';
>> -     git_cmd_try { Git::command_noisy(('diff', @ARGV)) } 'exit code %d';
>> +     my @command = ('git', 'diff', @ARGV);
>> +     my $rc = system(@command);
>> +     exit($rc | ($rc >> 8));
>>  }
>> -- 8< --
>
> I would prefer this, regardless of the issue.
>
> I actually recall asking Tim about the exit status when I reviewed this
> change.

I would also prefer this.

A question for the msysgit/cygwin folks:

would we need to go back to use "git.exe" as well?
-- 
David

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: t7800-difftool.sh failure on pu
  2012-03-29 18:12 t7800-difftool.sh failure on pu Ramsay Jones
  2012-03-29 21:26 ` Junio C Hamano
@ 2012-04-02 17:09 ` Tim Henigan
  1 sibling, 0 replies; 7+ messages in thread
From: Tim Henigan @ 2012-04-02 17:09 UTC (permalink / raw)
  To: Ramsay Jones; +Cc: Junio C Hamano, GIT Mailing-list, David Aguilar

Hi Ramsay - thank you for running the tests and trying this out.


On Thu, Mar 29, 2012 at 2:12 PM, Ramsay Jones
<ramsay@ramsay1.demon.co.uk> wrote:
>
> With the current pu branch, I have t7800.3 (difftool ignores bad --tool values)
> failing on Linux (I haven't tried cygwin or mingw yet). The failure is caused
> by the test for the value of the exit code; for me the exit code is 9 not 1.

This is interesting.  On my Ubuntu box, I am able to run all of t7800
without error.  This has been my primary development platform and the
tests have consistently passed for me on that system.

I have had trouble getting the test suite to run on msysgit.  However,
I just tried the simple test sequence that you demonstrated and found
that I get the same failure on that platform (i.e. "9 Bad file
descriptor").  So it appears that Carp is broken on some platforms.


> I have investigated, briefly, and found *two* alternatives for a fix. ;-)
>
> The first option is to (effectively) revert commit 0440ed72 ("difftool: replace
> system call with Git::command_noisy", 22-03-2012), like so:

Thanks again for spending the time to dig into the problem.  Based on
feedback from Junio and David in later emails, I plan to revert commit
0440ed72.


> The second option is a bit of a mystery, since I don't see why it is necessary
> or why it works! :-P
>
> First take a look at the following:
>
> $ perl -e 'print $!+0, " $!\n";'
> 0
> $ echo $?
> 0
>
> $ perl -e 'use Carp qw(croak); print $!+0, " $!\n";'
> 9 Bad file descriptor
> $ echo $?
> 0

I agree that this is mysterious.  On my Ubuntu box, this Perl
one-liner prints and exits with 0 for me (i.e. no bad file descriptor
error).  However, I was able to replicate the failure on msysgit.
This makes me wonder if other users of Git.pm have had the same
problem.  The primary user appears to be 'git-svn.perl' and its
related tests.  A quick review of those files did not show any mention
of problems with Carp.  Perhaps they simply do not check the exact
exit code on failure?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: t7800-difftool.sh failure on pu
  2012-03-31  4:05   ` David Aguilar
@ 2012-04-02 17:19     ` Tim Henigan
  2012-04-02 18:33       ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: Tim Henigan @ 2012-04-02 17:19 UTC (permalink / raw)
  To: Junio C Hamano, David Aguilar; +Cc: Ramsay Jones, GIT Mailing-list

On Sat, Mar 31, 2012 at 12:05 AM, David Aguilar <davvid@gmail.com> wrote:
> On Thu, Mar 29, 2012 at 2:26 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:
>>
>>> The first option is to (effectively) revert commit 0440ed72 ("difftool: replace
>>> system call with Git::command_noisy", 22-03-2012), like so:
>>>
>>> -- >8 --
>>> diff --git a/git-difftool.perl b/git-difftool.perl
>>> index e1754ff..49613b1 100755
>>> --- a/git-difftool.perl
>>> +++ b/git-difftool.perl
>>> @@ -237,5 +237,7 @@ if (defined($dirdiff)) {
>>>
>>>       $ENV{GIT_PAGER} = '';
>>>       $ENV{GIT_EXTERNAL_DIFF} = 'git-difftool--helper';
>>> -     git_cmd_try { Git::command_noisy(('diff', @ARGV)) } 'exit code %d';
>>> +     my @command = ('git', 'diff', @ARGV);
>>> +     my $rc = system(@command);
>>> +     exit($rc | ($rc >> 8));
>>>  }
>>> -- 8< --
>>
>> I would prefer this, regardless of the issue.
>>
>> I actually recall asking Tim about the exit status when I reviewed this
>> change.

This breakage is a surprise to me.  All the tests in t7800 have passed
for me since my first modifications to them.  They continue to pass
for me on Ubuntu.  That being said, the simple tests that Ramsay
posted in his email (simply printing $!) also fail for me on msysgit.


> I would also prefer this.
>

This change will involve:
  - Dropping 7/9 from the series
  - Editing 8/9 to replace 'git_cmd_try' with simple system calls

Would it be better to resend the entire series or just edit and resend 8/9?


> A question for the msysgit/cygwin folks:
>
> would we need to go back to use "git.exe" as well?

I would welcome some feedback from other Windows users.  I have been
successfully using this series on Win7 with msysgit, but obviously
some setups differ.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: t7800-difftool.sh failure on pu
  2012-04-02 17:19     ` Tim Henigan
@ 2012-04-02 18:33       ` Junio C Hamano
  0 siblings, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2012-04-02 18:33 UTC (permalink / raw)
  To: Tim Henigan; +Cc: Junio C Hamano, David Aguilar, Ramsay Jones, GIT Mailing-list

Tim Henigan <tim.henigan@gmail.com> writes:

> This change will involve:
>   - Dropping 7/9 from the series
>   - Editing 8/9 to replace 'git_cmd_try' with simple system calls
>
> Would it be better to resend the entire series or just edit and resend 8/9?

As long as you know I have the right "previous round" in my tree, it would
be sufficient to just send an updated 8/9 and tell me clearly what to do,
i.e. "drop 0440ed7 and replace 6fbdb7b with this patch, leaving everything
else intact.", after "---" line in it (if you were resending many patches
with an updated cover letter, the insn to me will be in 0/n instead).

Thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: t7800-difftool.sh failure on pu
  2012-03-29 21:26 ` Junio C Hamano
  2012-03-31  4:05   ` David Aguilar
@ 2012-04-03 17:53   ` Ramsay Jones
  1 sibling, 0 replies; 7+ messages in thread
From: Ramsay Jones @ 2012-04-03 17:53 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: tim.henigan, GIT Mailing-list

Junio C Hamano wrote:
> Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:
>> The first option is to (effectively) revert commit 0440ed72 ("difftool: replace
>> system call with Git::command_noisy", 22-03-2012), like so:
>>
>> -- >8 --
>> diff --git a/git-difftool.perl b/git-difftool.perl
>> index e1754ff..49613b1 100755
>> --- a/git-difftool.perl
>> +++ b/git-difftool.perl
>> @@ -237,5 +237,7 @@ if (defined($dirdiff)) {
>>  
>>  	$ENV{GIT_PAGER} = '';
>>  	$ENV{GIT_EXTERNAL_DIFF} = 'git-difftool--helper';
>> -	git_cmd_try { Git::command_noisy(('diff', @ARGV)) } 'exit code %d';
>> +	my @command = ('git', 'diff', @ARGV);
>> +	my $rc = system(@command);
>> +	exit($rc | ($rc >> 8));
>>  }
>> -- 8< --
> 
> I would prefer this, regardless of the issue.

Me too! ;-P

I noticed this afternoon (using my isp's web-mail interface) that Tim has
already sent a patch fixing this issue along these lines. [Thanks Tim]

However, just for the record, all three of the platforms I test on failed
in more-or-less the same way. [the exit code on cygwin was 2 (No such File
or Directory) rather than 9.]

Note that the failure occurred (on Linux, cygwin and MinGW) when pu was at
commit e5471b396660313b172e102b50939c9c35d4c637 (v1.7.10-rc2-260-ge5471b3).
However, on Linux, having fetched an updated pu which is now at commit
ae98c9308d3a79f2b22de2f6dae614f700f7ce0c (v1.7.10-rc3-272-gae98c93), then
test t7800 now reliably passes!

[when I say it reliably passes (fails), I mean it passes (fails) each time
on ten consecutive runs.]

I created a diff of git-difftool.perl between these two commits and applied
the patch, in reverse, to effectively revert that file. Having done so, then
t7800 once again reliably fails! Looking at the diff, I have no idea why!
[I've included the diff below, just for completeness.]

ATB,
Ramsay Jones

dt.diff:
-- >8 --
diff --git a/git-difftool.perl b/git-difftool.perl
index e1754ff..78e93a6 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -14,14 +14,16 @@
 use 5.008;
 use strict;
 use warnings;
-use File::Basename qw(dirname basename);
+use File::Basename qw(dirname);
 use File::Copy;
+use File::Find;
 use File::stat;
 use File::Path qw(mkpath);
 use File::Temp qw(tempdir);
 use Getopt::Long qw(:config pass_through);
 use Git;
 
+my @tools;
 my @working_tree;
 
 sub usage
@@ -38,17 +40,32 @@ USAGE
 	exit($exitcode);
 }
 
+sub filter_tool_scripts
+{
+	if (-d $_) {
+		if ($_ ne ".") {
+			# Ignore files in subdirectories
+			$File::Find::prune = 1;
+		}
+	} else {
+		if ((-f $_) && ($_ ne "defaults")) {
+			push(@tools, $_);
+		}
+	}
+}
+
 sub print_tool_help
 {
 	my ($cmd, @found, @notfound);
 	my $gitpath = Git::exec_path();
 
-	for (glob "$gitpath/mergetools/*") {
-		my $tool = basename($_);
-		next if ($tool eq "defaults");
+	find(\&filter_tool_scripts, "$gitpath/mergetools");
 
-		$cmd  = '. "$(git --exec-path)/git-mergetool--lib"';
+	foreach my $tool (@tools) {
+		$cmd  = "TOOL_MODE=diff";
+		$cmd .= ' && . "$(git --exec-path)/git-mergetool--lib"';
 		$cmd .= " && get_merge_tool_path $tool >/dev/null 2>&1";
+		$cmd .= " && can_diff >/dev/null 2>&1";
 		if (system('sh', '-c', $cmd) == 0) {
 			push(@found, $tool);
 		} else {
@@ -57,10 +74,10 @@ sub print_tool_help
 	}
 
 	print "'git difftool --tool=<tool>' may be set to one of the following:\n";
-	print "\t$_\n" for (@found);
+	print "\t$_\n" for (sort(@found));
 
 	print "\nThe following tools are valid, but not currently available:\n";
-	print "\t$_\n" for (@notfound);
+	print "\t$_\n" for (sort(@notfound));
 
 	print "\nNOTE: Some of the tools listed above only work in a windowed\n";
 	print "environment. If run in a terminal-only session, they will fail.\n";
-- 8< --

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-04-03 17:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-29 18:12 t7800-difftool.sh failure on pu Ramsay Jones
2012-03-29 21:26 ` Junio C Hamano
2012-03-31  4:05   ` David Aguilar
2012-04-02 17:19     ` Tim Henigan
2012-04-02 18:33       ` Junio C Hamano
2012-04-03 17:53   ` Ramsay Jones
2012-04-02 17:09 ` Tim Henigan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.