Re: preparing for 2.34.1

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

 



Hi Junio,

On Mon, 22 Nov 2021, Junio C Hamano wrote:

> Johannes Schindelin <Johannes.Schindelin@xxxxxx> writes:
>
> > The quickest workaround for this is probably to special-case the editor
> > `echo`:
>
> "GIT_EDITOR=: git cmd" would also be a common trick people would use
> to bypass editor and take whatever is given as an initial template.

GIT_EDITOR=: is not a problem because of
https://github.com/git/git/blob/v2.34.0/editor.c#L59:

	if (strcmp(editor, ":")) {
		[...]
		term_fail = save_term(1);
		if (start_command(&p) < 0) {
			if (!term_fail)
				restore_term();
			[...]
		}

		[...]
		if (!term_fail)
			restore_term();
		[...]
	}

> > 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.
>
> I think isatty(2) is pretty much our synonym to "are we talking to
> an end-user sitting in front of the terminal".  Mostly we use it as
> a way to control the progress bars, and use of editor on terminal
> would be in line with these existing uses.

Indeed, I think that isatty(2) is a better indicator than isatty(1). We
sometimes _do_ redirect the output of, say, `git commit`, to capture the
commit hash that was generated. We typically do not redirect stderr,
though, unless calling from an application and capturing everything via
pipes. So isatty(2) strikes me as the best balance we can strike here.

Ciao,
Dscho




[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