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

5 messages from 2008-05-23 to 2008-05-23. Participants: Mark Levedahl, Paul Mackerras, Shawn O. Pearce.
Thread: https://gitlist.dev/t/13628

## Mark Levedahl, 2008-05-23 03:00

Subject: [PATCH] gitk - restore operation of git-reset on Cygwin
Message-ID: <1211511636-3552-1-git-send-email-mlevedahl@gmail.com>
URL: https://gitlist.dev/e/1211511636-3552-1-git-send-email-mlevedahl%40gmail.com

```
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(-)

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, 2008-05-23 03:46

Subject: Re: [PATCH] gitk - restore operation of git-reset on Cygwin
Message-ID: <18486.15879.551874.408651@cargo.ozlabs.ibm.com>
URL: https://gitlist.dev/e/18486.15879.551874.408651%40cargo.ozlabs.ibm.com
In-Reply-To: <1211511636-3552-1-git-send-email-mlevedahl@gmail.com>

```
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.

```

## Mark Levedahl, 2008-05-23 22:26

Subject: Re: [PATCH] gitk - restore operation of git-reset on Cygwin
Message-ID: <483744AB.8070509@gmail.com>
URL: https://gitlist.dev/e/483744AB.8070509%40gmail.com
In-Reply-To: <18486.15879.551874.408651@cargo.ozlabs.ibm.com>

```
Paul Mackerras wrote:
> 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, 2008-05-23 23:13

Subject: Re: [PATCH] gitk - restore operation of git-reset on Cygwin
Message-ID: <48374F82.7050005@gmail.com>
URL: https://gitlist.dev/e/48374F82.7050005%40gmail.com
In-Reply-To: <483744AB.8070509@gmail.com>

```
Mark Levedahl wrote:
> 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, 2008-05-23 23:17

Subject: Re: [PATCH] gitk - restore operation of git-reset on Cygwin
Message-ID: <20080523231714.GY29038@spearce.org>
URL: https://gitlist.dev/e/20080523231714.GY29038%40spearce.org
In-Reply-To: <48374F82.7050005@gmail.com>

```
Mark Levedahl <mlevedahl@gmail.com> wrote:
> >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.

```
