Skip to contentSkip to conversation

Wait for git diff to finish in git difftool

PATCH In review Alex Riesen 4 participants 14 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Wait for git diff to finish in git difftool

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 <[email protected]>:

Review

Quoted 6 lines
(quoted diff) +6 -0
+# 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.

git-difftool.perl +2 -1
index 948ff7f..bd828c2 100755
@@ -82,4 +82,5 @@ sub generate_command
 }
 
 setup_environment();
-exec(generate_command());
+my $rc = system(generate_command());
+exit($rc | ($rc >> 8));
Signature · 1 line
1.6.3.rc0.45.g63634
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Alex Riesen

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.

Thanks for keeping an eye on portability.

There's a tiny typo in the commit message (Active't'State) that maybe you can tweak before applying? ('you' being Junio)

For whatever it's worth,

Quoted 3 lines

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.

This seems reasonable. The exit code isn't very important in the common 'show-me-the-diff' read-only scenario, and I wouldn't expect anyone to rely on difftool being exactly exit-code equivalent to git-diff.

Quoted 13 lines
git-difftool.perl +2 -1
index 948ff7f..bd828c2 100755
@@ -82,4 +82,5 @@ sub generate_command
 }
 
 setup_environment();
-exec(generate_command());
+my $rc = system(generate_command());
+exit($rc | ($rc >> 8));
Signature · 1 line
1.6.3.rc0.45.g63634
Signature · 1 line
		David
#2 lore raw

2009/4/22 David Aguilar <[email protected]>:

Quoted 1 line · Alex Riesen

I wasn't born on 0th.

Quoted 4 lines

For whatever it's worth,

Yes, FWIW. I intentionally stopped signing off patches for Windows, ActiveState Perl and Cygwin: they usually harm the rest of the world, while just allowing Windows users limp along.

#3 lore raw
Quoted 6 lines · Alex Riesen

2009/4/22 David Aguilar <[email protected]>:

Quoted 1 line · Alex Riesen

I wasn't born on 0th.

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

For whatever it's worth,

Yes, FWIW. I intentionally stopped signing off patches for Windows, ActiveState Perl and Cygwin: they usually harm the rest of the world, while just allowing Windows users limp along.

I have to wonder if you are doing that with the full understanding of what Signed-off-by means. I do not think the provenance of your patch is affected by your distaste towards the system it has effects in any way.

#4 lore raw

2009/4/22 Junio C Hamano <[email protected]>:

Quoted 7 lines
Quoted 3 lines

Yes, FWIW. I intentionally stopped signing off patches for Windows, ActiveState Perl and Cygwin: they usually harm the rest of the world, while just allowing Windows users limp along.

I have to wonder if you are doing that with the full understanding of what Signed-off-by means.  I do not think the provenance of your patch is affected by your distaste towards the system it has effects in any way.

I'm trying to avoid being associated with development for the platform :)

Frankly, I just always forget about it. The patches to my windows repository are mostly just hacks to either make it pass test suite or workaround another, the platforms specific, stupidity. Not sure anyone is actually interested in them (because, I repeat, they mostly hurt everyone else, while making the platforms port "a little working").

#5 lore raw
Quoted 9 lines · Alex Riesen

2009/4/22 Junio C Hamano <[email protected]>:

Quoted 7 lines
Quoted 3 lines

Yes, FWIW. I intentionally stopped signing off patches for Windows, ActiveState Perl and Cygwin: they usually harm the rest of the world, while just allowing Windows users limp along.

I have to wonder if you are doing that with the full understanding of what Signed-off-by means.  I do not think the provenance of your patch is affected by your distaste towards the system it has effects in any way.

Quoted 7 lines

I'm trying to avoid being associated with development for the platform :)

Frankly, I just always forget about it. The patches to my windows repository are mostly just hacks to either make it pass test suite or workaround another, the platforms specific, stupidity. Not sure anyone is actually interested in them (because, I repeat, they mostly hurt everyone else, while making the platforms port "a little working").

What do you really mean? These patches add maintenance burden but its benefit nobody would care about, and should not be applied?

#6 lore raw

2009/4/23 Junio C Hamano <[email protected]>:

Quoted 9 lines
Quoted 5 lines · Alex Riesen

Frankly, I just always forget about it. The patches to my windows repository are mostly just hacks to either make it pass test suite or workaround another, the platforms specific, stupidity. Not sure anyone is actually interested in them (because, I repeat, they mostly hurt everyone else, while making the platforms port "a little working").

What do you really mean?  These patches add maintenance burden but its benefit nobody would care about, and should not be applied?

Maintenance _and_ run-time. It is your decision, but yes, I kind of hate the idea of them being applied.

In plain words: please don't apply MY patches with words "Windows" or "Cygwin" in message body, unless I beg you to (and even then, consider me heavily drugged).

#7 lore raw
Quoted 11 lines · Alex Riesen

2009/4/23 Junio C Hamano <[email protected]>:

Quoted 9 lines
Quoted 5 lines · Alex Riesen

Frankly, I just always forget about it. The patches to my windows repository are mostly just hacks to either make it pass test suite or workaround another, the platforms specific, stupidity. Not sure anyone is actually interested in them (because, I repeat, they mostly hurt everyone else, while making the platforms port "a little working").

What do you really mean?  These patches add maintenance burden but its benefit nobody would care about, and should not be applied?

Quoted 6 lines

Maintenance _and_ run-time. It is your decision, but yes, I kind of hate the idea of them being applied.

In plain words: please don't apply MY patches with words "Windows" or "Cygwin" in message body, unless I beg you to (and even then, consider me heavily drugged).

Hmm, what's the point then for me to spend time looking at them posted on the list?

#8 lore raw

2009/4/23 Junio C Hamano <[email protected]>:

Quoted 16 lines
Quoted 14 lines · Alex Riesen

2009/4/23 Junio C Hamano <[email protected]>:

Quoted 9 lines
Quoted 5 lines · Alex Riesen

Frankly, I just always forget about it. The patches to my windows repository are mostly just hacks to either make it pass test suite or workaround another, the platforms specific, stupidity. Not sure anyone is actually interested in them (because, I repeat, they mostly hurt everyone else, while making the platforms port "a little working").

What do you really mean?  These patches add maintenance burden but its benefit nobody would care about, and should not be applied?

Maintenance _and_ run-time. It is your decision, but yes, I kind of hate the idea of them being applied.

Quoted 7 lines
Quoted 3 lines

In plain words: please don't apply MY patches with words "Windows" or "Cygwin" in message body, unless I beg you to (and even then, consider me heavily drugged).

Hmm, what's the point then for me to spend time looking at them posted on the list?

None. But it still would be nice if you look at them when you're addressed directly. Please understand, maybe I'm abusing the list a little, but it looks like the best place to _archive_ the workarounds for this obscure platform. The code is of little use to general public, but in case one finds himself in the same situation as I am in, at least Google can help out. I think it happens too rare to justify your looking at them, and especially including them in the mainline, but hiding the code on my laptop isn't of any use to anyone (including me: I don't always have that laptop).

#9 lore raw

Heya,

Quoted 3 lines · Alex Riesen

None. But it still would be nice if you look at them when you're addressed directly. Please understand, maybe I'm abusing the list a little, but it looks like the best place to _archive_ the workarounds for this obscure platform.

In that case you should note in your patch (preferrably in the subject) that they are not meant for inclusion and merely for the that purpose so that those who are not interested in them need not waste their time reviewing the patch with the assumption that it _is_ meant for inclusion.

Signature · 3 lines
Cheers,

Sverre Rabbelier
#10 lore raw
In reply to Alex Riesen
Quoted 7 lines · Alex Riesen
Quoted 6 lines
Quoted 3 lines

In plain words: please don't apply MY patches with words "Windows" or "Cygwin" in message body, unless I beg you to (and even then, consider me heavily drugged).

Hmm, what's the point then for me to spend time looking at them posted on the list?

Quoted 8 lines

None. But it still would be nice if you look at them when you're addressed directly. Please understand, maybe I'm abusing the list a little, but it looks like the best place to _archive_ the workarounds for this obscure platform. The code is of little use to general public, but in case one finds himself in the same situation as I am in, at least Google can help out. I think it happens too rare to justify your looking at them, and especially including them in the mainline, but hiding the code on my laptop isn't of any use to anyone (including me: I don't always have that laptop).

Actually, I think I probably should have phrased it more positively.

Do you think you are in a so minority situation that your "workarounds" are valuable for nobody else? Apparently you see value in letting them finding your patches in the archive, so you do not expect them to be "nobody else" but rather "a small minority".

People on minority platforms have smaller number of people in similar situation to ask help from than people on mainstream platforms, and they suffer from the minority status of their platforms not only with git but about many other things. Worse, their chance of finding solution by digging the archive is smaller, and they would need to spend a lot more time, than the people on other platforms. And you know this a lot better than I do ;-).

Even though the suffering of these people as a whole may not be much, only because there are small number of them, as individuals they may suffer a lot. If we can help them without having to bend over backwards too much, it would be a good thing. I think we should at least try.

For example, I do not think conversion from Perl exec() to Perl system() is worsening the code in any way in difftool. Sure, it won't *improve* things for general majority of people, but as long as it does not hurt people (that includes me and others who pay maintenance cost), I do not think we should just bury the patch in archive or in your laptop.

#11 lore raw

Junio C Hamano, Thu, Apr 23, 2009 16:51:28 +0200:

Quoted 4 lines

Do you think you are in a so minority situation that your "workarounds" are valuable for nobody else? Apparently you see value in letting them finding your patches in the archive, so you do not expect them to be "nobody else" but rather "a small minority".

Correct, "small minority".

Quoted 7 lines

People on minority platforms have smaller number of people in similar situation to ask help from than people on mainstream platforms, and they suffer from the minority status of their platforms not only with git but about many other things. Worse, their chance of finding solution by digging the archive is smaller, and they would need to spend a lot more time, than the people on other platforms. And you know this a lot better than I do ;-).

Well, this particular minority is used to have marginal levels of technical support and .

Quoted 5 lines

For example, I do not think conversion from Perl exec() to Perl system() is worsening the code in any way in difftool. Sure, it won't *improve* things for general majority of people, but as long as it does not hurt people (that includes me and others who pay maintenance cost), I do not think we should just bury the patch in archive or in your laptop.

Isn't it clearly marked in the archives with the keywords most often associated with the platform? (they may seem a little... unprintable)

Still, you are, as usual, right. Especially regarding this particular case.

I'll add this comment regarding use of system in the case where exec is right choice on all accounts and resend the patch:

# ActiveState Perl for Win32 does not implement POSIX semantics of # exec* system call. It just spawns the given executable and finishes # the starting program, exiting with code 0.
# system will at least catch the errors in returned by git diff, # allowing the caller of git difftool better handling of failures.

#12 lore raw

Alex Riesen, Thu, Apr 23, 2009 20:57:32 +0200:

Quoted 12 lines

Junio C Hamano, Thu, Apr 23, 2009 16:51:28 +0200:

Quoted 5 lines

For example, I do not think conversion from Perl exec() to Perl system() is worsening the code in any way in difftool. Sure, it won't *improve* things for general majority of people, but as long as it does not hurt people (that includes me and others who pay maintenance cost), I do not think we should just bury the patch in archive or in your laptop.

Isn't it clearly marked in the archives with the keywords most often associated with the platform? (they may seem a little... unprintable)

Still, you are, as usual, right. Especially regarding this particular case.

Quoted 8 lines

I'll add this comment regarding use of system in the case where exec is right choice on all accounts and resend the patch:

# ActiveState Perl for Win32 does not implement POSIX semantics of # exec* system call. It just spawns the given executable and finishes # the starting program, exiting with code 0.
# system will at least catch the errors in returned by git diff, # allowing the caller of git difftool better handling of failures.

Oh... I'm too late...

#13 lore raw

PATCH 1/1 Explain seemingly pointless use of system in difftool

Portability reasons.

---

Alex Riesen, Thu, Apr 23, 2009 21:08:35 +0200:

Quoted 4 lines

Alex Riesen, Thu, Apr 23, 2009 20:57:32 +0200:

Quoted 3 lines

I'll add this comment regarding use of system in the case where exec is right choice on all accounts and resend the patch:

Quoted 8 lines
Quoted 5 lines

# ActiveState Perl for Win32 does not implement POSIX semantics of # exec* system call. It just spawns the given executable and finishes # the starting program, exiting with code 0.
# system will at least catch the errors in returned by git diff, # allowing the caller of git difftool better handling of failures.

Oh... I'm too late...

There.

 git-difftool.perl |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
git-difftool.perl +6 -0
index bd828c2..9255d23 100755
@@ -82,5 +82,11 @@ sub generate_command
 }
 
 setup_environment();
+
+# ActiveState Perl for Win32 does not implement POSIX semantics of
+# exec* system call. It just spawns the given executable and finishes
+# the starting program, exiting with code 0.
+# system will at least catch the errors returned by git diff,
+# allowing the caller of git difftool better handling of failures.
 my $rc = system(generate_command());
 exit($rc | ($rc >> 8));
Signature · 1 line
1.6.3.rc1.74.g42ff