git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: Pratyush Yadav <me@yadavpratyush.com>
Cc: Git List <git@vger.kernel.org>, Johannes Sixt <j6t@kdbg.org>,
	Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] git-gui: fix commit message comment line removal with older Tcl versions
Date: Mon, 1 Mar 2021 01:48:49 -0500	[thread overview]
Message-ID: <CAPig+cRQN4PjfxEOZ8ZBA_uttsRPS8DPDgToM_JFvichDDh_HQ@mail.gmail.com> (raw)
In-Reply-To: <20210228231110.24076-1-sunshine@sunshineco.com>

On Sun, Feb 28, 2021 at 6:12 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
> 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.)

> 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?

> +       set result [read $fd]
> +       close $fd
> +       file delete $strip_p
>         return $result
>  }

      reply	other threads:[~2021-03-01  6:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <https://lore.kernel.org/git/CAPig+cT-sfgMDi9-6AEKF85NtOiXeqddJjk-pYuhDtTVAE-UEw@mail.gmail.com/>
2021-02-28 23:11 ` [PATCH] git-gui: fix commit message comment line removal with older Tcl versions Eric Sunshine
2021-03-01  6:48   ` Eric Sunshine [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPig+cRQN4PjfxEOZ8ZBA_uttsRPS8DPDgToM_JFvichDDh_HQ@mail.gmail.com \
    --to=sunshine@sunshineco.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=me@yadavpratyush.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).