git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-gui - simplify _open_stdout_stderr

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Apr 1, 2025, 16:04 UTC
Message-ID
<0140dfd8-f65d-34a0-2e66-44e3f696b100@gmx.de>
In-Reply-To
<20230922164412.130504-1-mlevedahl@gmail.com>
Hi Mark,

this patch is still relevant, right? I am Cc:ing Johannes Sixt for awareness.

Ciao, Johannes

On Fri, 22 Sep 2023, Mark Levedahl wrote:
Show 60 quoted lines
> From: "Mark Levedahl Date: Tue, 19 Sep 2023" <mlevedahl@gmail.com>
>
> Since b792230 ("git-gui: Show a progress meter for checking out files",
> 2007-07-08), git-gui includes a workaround for Tcl that does not support
> using 2>@1 to redirect stderr to stdout. Tcl added such support in
> 8.4.7, released in 2004, while the later 8.4.14 still predated git-gui.
> But, Cygwin was stuck on an 8.4.1 Tcl variant until 2011, hence the need
> for this workaround. Commit 7145c65 recently removed much other specific
> code for that obsolete Cygwin Tcl/Tk, but missed this piece.
>
> Also, Tcl since 8.5 explicitly supports 2>@1 across all platforms, and
> git-gui requires Tcl >= 8.5, further evidence the workaround is
> obsolete.  (I did test that 2>@1 works as-expected on current Linux,
> Cygwin, and Git For Windows Tcl packages).
>
> Remove the workaround and exploit concat's documented capability to
> handle both scalar and list arguments, leaving a much simpler function.
> This eliminates any question that cmd might be executed twice.
>
> Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
> ---
>  git-gui.sh | 21 ++-------------------
>  1 file changed, 2 insertions(+), 19 deletions(-)
>
> diff --git a/git-gui.sh b/git-gui.sh
> index 8bc8892..a5d008d 100755
> --- a/git-gui.sh
> +++ b/git-gui.sh
> @@ -583,25 +583,8 @@ proc git {args} {
>
>  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
> -		}
> +	if {[catch {set fd [open [concat | $cmd] r]} err]} {
> +		error $err
>  	}
>  	fconfigure $fd -eofchar {}
>  	return $fd
> --
> 2.41.0.99.19
>
>
Previous: Mark LevedahlNext: Mark Levedahl
Message 2 of 3 in “git-gui - simplify _open_stdout_stderr”
  1. git-gui - simplify _open_stdout_stderrMark Levedahl, Sep 22, 2023
  2. Johannes SchindelinApr 1, 2025
  3. Mark LevedahlApr 1, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.