Skip to contentSkip to conversation

gitk - restore operation of git-reset on Cygwin

PATCH In review Mark Levedahl 3 participants 5 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gitk - restore operation of git-reset on Cygwin

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.

---
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(-)
gitk +1 -1
index 22bcd18..aa70911 100755
@@ -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

#1 lore raw
Quoted 6 lines · Mark Levedahl

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.

#2 lore raw
Quoted 11 lines · Paul Mackerras
Quoted 7 lines · Mark Levedahl

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.

Quoted 7 lines

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

#3 lore raw
Quoted 6 lines · Mark Levedahl
Quoted 5 lines · Paul Mackerras

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.

Quoted 6 lines
Quoted 2 lines

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

#4 lore raw
Quoted 11 lines · Mark Levedahl
Quoted 5 lines
Quoted 4 lines · Paul Mackerras

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
}
Signature · 1 line
Shawn.