threads / patch / 13628

patchgitk - restore operation of git-reset on Cygwin

Subject: [PATCH] gitk - restore operation of git-reset on Cygwin

## tl;dr

5 messages between May 23, 2008 and May 23, 2008. Diffs are folded; open one to read it.

replies: 4people: 3as markdown or json

Mark Levedahl· May 23, 2008, 03:00 UTC · lore

Commit 6df7403a98737 modified the call to git-reset to invoke git directly rather than using "sh -c", but is redirecting stderr to stdout. This does not work on Cygwin, probably because the Tcl/Tk package is a windows program rather than Cygwin. The result is always an error message proclaiming 'can not find channel named "1"'. This restores invocation through sh -c.

Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
---
Note - this applies to Paul's tree, please let me know if you prefer
one that applies to Junio's instead (gitk-git/gitk rather than gitk).
 gitk |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to gitk +1 −2
diff --git a/gitk b/gitk
index 22bcd18..aa70911 100755
--- a/gitk
+++ b/gitk
@@ -7617,7 +7617,7 @@ proc resethead {} {
     tkwait window $w
     if {!$confirm_ok} return
     if {[catch {set fd [open \
-	    [list | git reset --$resettype $rowmenuid 2>@1] r]} err]} {
+	    [list | sh -c "git reset --$resettype $rowmenuid 2>&1"] r]} err]} {
 	error_popup $err
     } else {
 	dohidelocalchanges
--
1.5.5.1.333.gd69f4
Paul Mackerras· May 23, 2008, 03:46 UTC · re: Mark Levedahl · lore

Re: [PATCH] gitk - restore operation of git-reset on Cygwin

Mark Levedahl writes:
Show 6 quoted lines
> Commit 6df7403a98737 modified the call to git-reset to invoke git
> directly rather than using "sh -c", but is redirecting stderr to stdout.
> This does not work on Cygwin, probably because the Tcl/Tk package is
> a windows program rather than Cygwin. The result is always an error
> message proclaiming 'can not find channel named "1"'. This restores
> invocation through sh -c.

Are you using Tk 8.4 or 8.5? The man pages for 8.5 imply that the 2>@1 form should work for all platforms, but maybe that wasn't true in 8.4. If that's the case it's worth mentioning in the patch description.

Paul.
Mark Levedahl· May 23, 2008, 22:26 UTC · re: Paul Mackerras · lore

Re: [PATCH] gitk - restore operation of git-reset on Cygwin

Paul Mackerras wrote:
Show 18 quoted lines
> Mark Levedahl writes:
>
>   
>> Commit 6df7403a98737 modified the call to git-reset to invoke git
>> directly rather than using "sh -c", but is redirecting stderr to stdout.
>> This does not work on Cygwin, probably because the Tcl/Tk package is
>> a windows program rather than Cygwin. The result is always an error
>> message proclaiming 'can not find channel named "1"'. This restores
>> invocation through sh -c.
>>     
>
> Are you using Tk 8.4 or 8.5?  The man pages for 8.5 imply that the
> 2>@1 form should work for all platforms, but maybe that wasn't true in
> 8.4.  If that's the case it's worth mentioning in the patch
> description.
>
> Paul.
>   

Cygwin's Tcl/Tk is essentially frozen at 8.4.1. However, I really believe the problem is that the Tcl/Tk is not a full Cygwin application: it is mostly Windows, with only a few pieces converted to Posix through the cygwin.dll, so many things don't quite work correctly. For instance, the current gitk works fine under a pure Cygwin build of Tcl/Tk (8.4.13) I have locally. So, I believe the commit message I wrote is correct.

Mark
Mark Levedahl· May 23, 2008, 23:13 UTC · re: Mark Levedahl · lore

Re: [PATCH] gitk - restore operation of git-reset on Cygwin

Mark Levedahl wrote:
Show 18 quoted lines
> Paul Mackerras wrote:
>> Are you using Tk 8.4 or 8.5?  The man pages for 8.5 imply that the
>> 2>@1 form should work for all platforms, but maybe that wasn't true in
>> 8.4.  If that's the case it's worth mentioning in the patch
>> description.
>>
>> Paul.
>>   
> Cygwin's Tcl/Tk is essentially frozen at 8.4.1. However, I really 
> believe the problem is that the Tcl/Tk is not a full Cygwin 
> application: it is mostly Windows, with only a few pieces converted to 
> Posix through the cygwin.dll, so many things don't quite work 
> correctly. For instance, the current gitk works fine under a pure 
> Cygwin build of Tcl/Tk (8.4.13) I have locally. So, I believe the 
> commit message I wrote is correct.
>
> Mark
>

I just tried installation of ActiveState Tcl 8.4.16, put that on the Cygwin path, and gitk operates correctly without the patch. So, the issue seems to be entirely one of Cygwin's particular Tcl/Tk build, though whether that is due to the version or the odd attributes of its compilation I cannot say.

Mark
Shawn O. Pearce· May 23, 2008, 23:17 UTC · re: Mark Levedahl · lore

Re: [PATCH] gitk - restore operation of git-reset on Cygwin

Mark Levedahl <mlevedahl@gmail.com> wrote:
Show 11 quoted lines
> >Paul Mackerras wrote:
> >>Are you using Tk 8.4 or 8.5?  The man pages for 8.5 imply that the
> >>2>@1 form should work for all platforms, but maybe that wasn't true in
> >>8.4.  If that's the case it's worth mentioning in the patch
> >>description.
> 
> I just tried installation of ActiveState Tcl 8.4.16, put that on the 
> Cygwin path, and gitk operates correctly without the patch. So, the 
> issue seems to be entirely one of Cygwin's particular Tcl/Tk build, 
> though whether that is due to the version or the odd attributes of its 
> compilation I cannot say.

git-gui ran into this problem and uses the following procedure anytime it wants both stdout and stderr:

proc _open_stdout_stderr {cmd} {
    _trace_exec $cmd
    if {[catch {
            set fd [open [concat [list | ] $cmd] r]
        } err]} {
        if {   [lindex $cmd end] eq {2>@1}
            && $err eq {can not find channel named "1"}
            } {
            # Older versions of Tcl 8.4 don't have this 2>@1 IO
            # redirect operator.  Fallback to |& cat for those.
            # The command was not actually started, so its safe
            # to try to start it a second time.
            #
            set fd [open [concat \
                [list | ] \
                [lrange $cmd 0 end-1] \
                [list |& cat] \
                ] r]
        } else {
            error $err
        }
    }
    fconfigure $fd -eofchar {}
    return $fd
}
-- 
Shawn.

← back to recent threads