Re: preparing for 2.34.1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Carlo,

On Mon, 22 Nov 2021, Carlo Arenas wrote:

> On Mon, Nov 22, 2021 at 11:54 AM Junio C Hamano <gitster@xxxxxxxxx> 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@xxxxxxxxxxxxxxxxx/

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@xxxxxxx/
> [2] https://yhbt.net/lore/all/nycvar.QRO.7.76.6.1903221436590.41@xxxxxxxxxxxxxxxxx/T/
>
>




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux