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

Re: [PATCH] git-gui: fix commit message comment line removal with older Tcl versions

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Mar 1, 2021, 06:48 UTC
Message-ID
<CAPig+cRQN4PjfxEOZ8ZBA_uttsRPS8DPDgToM_JFvichDDh_HQ@mail.gmail.com>
In-Reply-To
<20210228231110.24076-1-sunshine@sunshineco.com>
On Sun, Feb 28, 2021 at 6:12 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 17 quoted lines
> git-gui was recently enhanced to remove comment lines from the commit
> message similar to the way git-commit does so (see `core.commentchar`
> and `git-stripspace`). Unfortunately, that change employs features which
> are unavailable in older versions of Tcl, such as 8.5.9 which is shipped
> with macOS (10.13), with the result that the commit operation errors
> out.
>
> There are two problems. First, to add a new informational message to the
> main window, it invokes string method `cat` which does not exist in
> older Tcl. Fix this by using `append` instead.
>
> Second, when passing the commit message through git-stripspace, it
> closes the "write" side of the bidirectional pipe after sending the
> commit message to git-stripspace in order to avoid deadlock before
> reading back the result, however the ability to close only one end of a
> pipe is not present in older Tcl. Fix this by employing a temporary file
> to received the output of git-stripspace.
s/received/receive/
(I noticed this immediately after sending the patch, of course.)
Show 19 quoted lines
> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
> ---
> diff --git a/lib/commit.tcl b/lib/commit.tcl
> @@ -142,16 +142,18 @@ proc setup_commit_encoding {msg_wt {quiet 0}} {
>  proc strip_msg {msg} {
> -       set cmd [concat [list | ] [_git_cmd stripspace] --strip-comments]
> +       set strip_p [gitdir GITGUI_EDITMSG_STRIP]
> +       set cmd [concat [list | ] [_git_cmd stripspace] --strip-comments [list >$strip_p]]
>         _trace_exec $cmd
> -       set fd [open $cmd r+]
> +       set fd [open $cmd w]
>         fconfigure $fd -translation binary -encoding utf-8
> -
>         puts -nonewline $fd $msg
> -       close $fd w
> -       set result [read $fd]
>         close $fd
>
> +       set fd [open $strip_p r]
I had meant to insert:
    fconfigure $fd -translation binary -encoding utf-8

here but forgot. Would you like me to resend the patch or can you tweak it locally?

Show 5 quoted lines
> +       set result [read $fd]
> +       close $fd
> +       file delete $strip_p
>         return $result
>  }
Previous: Eric Sunshine
Message 2 of 2 in “git-gui: fix commit message comment line removal with older Tcl versions”
  1. git-gui: fix commit message comment line removal with older Tcl versionsEric Sunshine, Feb 28, 2021
  2. Eric SunshineMar 1, 2021

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.