From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Carlo Arenas <carenas@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: preparing for 2.34.1
Date: Mon, 22 Nov 2021 23:28:22 +0100 (CET) [thread overview]
Message-ID: <nycvar.QRO.7.76.6.2111222319100.63@tvgsbejvaqbjf.bet> (raw)
In-Reply-To: <CAPUEsphNH9pfQoHqVgJfkQCU-Li45dz4QtGtDjWu5bDV9A3PEg@mail.gmail.com>
Hi Carlo,
On Mon, 22 Nov 2021, Carlo Arenas wrote:
> On Mon, Nov 22, 2021 at 11:54 AM Junio C Hamano <gitster@pobox.com> wrote:
> >
> > There are a few topics [*] to fix regressions introduced in the
> > previous cycle
>
> There was another regression report[1] that I just fished out of my
> spam folder and that I introduced in 3d411afabc (editor: save and
> reset terminal after calling EDITOR, 2021-10-05), but that I have not
> yet produced a fix for or fully understood.
>
> The gist is that some people seem to be using a hack[2] dscho posted a
You mean
https://lore.kernel.org/git/nycvar.QRO.7.76.6.1903221436590.41@tvgsbejvaqbjf.bet/
right? I.e. figuring out what Git considers its system config location via
GIT_EDITOR=echo git config --system -e 2>/dev/null
> few years ago to get info from git programmatically and I just didn't
> expect someone would try to invoke the EDITOR unless they had a
> terminal, so the fix might be to just add an isatty(0) call, but
> reverting that commit would be also an option.
The quickest workaround for this is probably to special-case the editor
`echo`:
-- snip --
diff --git a/editor.c b/editor.c
index 674309eed8bd..1b97f7da9920 100644
--- a/editor.c
+++ b/editor.c
@@ -51,12 +51,11 @@ const char *git_sequence_editor(void)
static int launch_specified_editor(const char *editor, const char *path,
struct strbuf *buffer, const char *const *env)
{
- int term_fail;
-
if (!editor)
return error("Terminal is dumb, but EDITOR unset");
if (strcmp(editor, ":")) {
+ int save_and_restore_term = strcmp(editor, "echo");
struct strbuf realpath = STRBUF_INIT;
const char *args[] = { editor, NULL, NULL };
struct child_process p = CHILD_PROCESS_INIT;
@@ -86,9 +85,10 @@ static int launch_specified_editor(const char *editor, const char *path,
p.env = env;
p.use_shell = 1;
p.trace2_child_class = "editor";
- term_fail = save_term(1);
+ if (save_and_restore_term)
+ save_and_restore_term = !save_term(1);
if (start_command(&p) < 0) {
- if (!term_fail)
+ if (save_and_restore_term)
restore_term();
strbuf_release(&realpath);
return error("unable to start editor '%s'", editor);
@@ -97,7 +97,7 @@ static int launch_specified_editor(const char *editor, const char *path,
sigchain_push(SIGINT, SIG_IGN);
sigchain_push(SIGQUIT, SIG_IGN);
ret = finish_command(&p);
- if (!term_fail)
+ if (!save_and_restore_term)
restore_term();
strbuf_release(&realpath);
sig = ret - 128;
-- snap --
However, I could imagine that other scenarios call for an editor that
_also_ does not run in the terminal, and where also no real terminal is
available for saving and restoring.
I was tempted to suggest an `isatty(2)`, but that probably comes with its
own problems, too.
Ciao,
Dscho
>
> Carlo
>
> [1] https://lore.kernel.org/git/ee302c98-da27-da43-e684-c7ec8b225360@gmx.net/
> [2] https://yhbt.net/lore/all/nycvar.QRO.7.76.6.1903221436590.41@tvgsbejvaqbjf.bet/T/
>
>
next prev parent reply other threads:[~2021-11-22 22:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-22 17:37 preparing for 2.34.1 Junio C Hamano
2021-11-22 20:51 ` Carlo Arenas
2021-11-22 22:28 ` Johannes Schindelin [this message]
2021-11-22 22:42 ` Junio C Hamano
2021-11-22 23:30 ` Johannes Schindelin
2021-11-22 23:51 ` rsbecker
2021-11-22 22:50 ` Carlo Arenas
2021-11-22 21:50 ` Derrick Stolee
2021-11-22 22:45 ` Junio C Hamano
2021-11-23 17:18 ` preparing for 2.34.1 (2nd round) Junio C Hamano
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=nycvar.QRO.7.76.6.2111222319100.63@tvgsbejvaqbjf.bet \
--to=johannes.schindelin@gmx.de \
--cc=carenas@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).