git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Carlo Arenas <carenas@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Chris Torek <chris.torek@gmail.com>,
	phillip.wood@dunelm.org.uk, Git List <git@vger.kernel.org>,
	thomas.wolf@paranor.ch, Alexander Veit <alexander.veit@gmx.net>
Subject: Re: [PATCH] editor: only save (and restore) the terminal if using a tty
Date: Wed, 1 Dec 2021 17:51:28 -0800	[thread overview]
Message-ID: <CAPUEsphktbdxeV7hvF52Or3CVHS8oOk5-WV=xfEZa8kfCVVnVg@mail.gmail.com> (raw)
In-Reply-To: <xmqq7dcnyh5o.fsf@gitster.g>

On Wed, Dec 1, 2021 at 4:39 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Junio C Hamano <gitster@pobox.com> writes:
>
> >  - Add a multi-valued configuration variable whose value is the name
> >    of an editor program that needs this save/restore; optionally, we
> >    may want a way to say "don't do save/restore on this editor",
> >    e.g. "!emacs" may countermand an earlier value that would include
> >    the editor in the list.
> >
> >  - Around the program invocation in launch_specified_editor(), check
> >    the name of the editor against this list and do the save/restore
> >    as necessary;
> >
> >  - When the variable is not defined in the configuration, pretend
> >    that "vi" is on that list (coming up with the list of editors is
> >    left as an exercise to readers).
> >
> > That would give us your flexibility to apply the save/restore on an
> > arbitrary editor that is not "vi", Dscho's convenience to special
> > case "vi" out of the box when unconfigured, and an escape hatch for
> > "vi" users for whom it hurts to do the save/restore on their "vi".
> >
> > Hmm?
>
> That's an overkill.

Ha!, I was going to say that before, but instead went and implemented
(most of) it, discarding my simpler version[1] that was instead using
a boolean config and is otherwise similar to yours (but instead with a
default of false, and obviously not as good looking).

I was assuming the user would know better when the feature was needed
or not (obviously not if their editor is not even terminal based,
which we can't figure out programmatically anyway), and it was on Git
for Windows users that want to also use vi, to enable it[2]; instead
of "affecting" all vi users from all platforms by default, even if we
have reports[3] of some of them being affected before.

A couple of things that are still missing here IMHO are :

* need to also disable if not in the foreground (which was really the
root cause of the reported regression, and needed to address Phillip's
related report[4]; I cover this in my 1/2, so no need to change this
one)
* probably still should do the isatty(2) to disable (at the editor
level), as another way to protect against people scripting around
this, but also because it just doesn't make sense to protect a
terminal from corruption that is not being seen by a human, and as you
pointed out, git doesn't need to be that protective of the tty as bash
does (which will likely fix it itself, or let the user run `reset` to
do so).

Will prepare a new series including your patch for review and a third
one with proposed changes to yours from the second bullet point, that
might be worth squashing instead, or that at least could be used as a
discussion starter, or discarded if you already thought about those
and decided against.

Carlo

[1] https://github.com/carenas/git/commit/910c158b42994132de2480c018b44616962a2a20
[2] https://github.com/git-for-windows/build-extra/pull/399
[3] https://lore.kernel.org/git/xmqqwnmswxs7.fsf@gitster.g/
[4] https://lore.kernel.org/git/b1f2257a-044c-17bb-2737-42b8026421eb@gmail.com/

  reply	other threads:[~2021-12-02  1:53 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-22  8:42 Update to Git 2.34.0 breaks application Alexander Veit
2021-11-22 21:43 ` Phillip Wood
2021-11-22 22:28   ` [PATCH] editor: only save (and restore) the terminal if using a tty Carlo Marcelo Arenas Belón
2021-11-22 22:47     ` Junio C Hamano
2021-11-22 23:03     ` Junio C Hamano
2021-11-22 23:08       ` Junio C Hamano
2021-11-23  8:52         ` Alexander Veit
2021-11-23  9:08           ` Carlo Arenas
2021-11-22 23:39       ` Carlo Arenas
2021-11-23 17:35         ` Junio C Hamano
2021-11-24 13:29           ` Johannes Schindelin
2021-11-24 18:25             ` Carlo Arenas
2021-11-24 19:34             ` Junio C Hamano
2021-11-24 20:04               ` Carlo Arenas
2021-11-24 20:51                 ` Junio C Hamano
2021-11-29 21:12               ` Johannes Schindelin
2021-11-23 11:05     ` Phillip Wood
2021-11-23 17:27       ` Junio C Hamano
2021-11-23 17:31       ` Carlo Arenas
2021-11-30 11:07         ` Phillip Wood
2021-12-01  5:12           ` Chris Torek
2021-12-01 19:33             ` Junio C Hamano
2021-12-02  0:38               ` Junio C Hamano
2021-12-02  1:51                 ` Carlo Arenas [this message]
2021-12-02 14:48             ` Johannes Schindelin

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='CAPUEsphktbdxeV7hvF52Or3CVHS8oOk5-WV=xfEZa8kfCVVnVg@mail.gmail.com' \
    --to=carenas@gmail.com \
    --cc=alexander.veit@gmx.net \
    --cc=chris.torek@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=phillip.wood@dunelm.org.uk \
    --cc=thomas.wolf@paranor.ch \
    /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).