git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] editor: only save (and restore) the terminal if using a tty

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Nov 30, 2021, 11:07 UTC
Message-ID
<7138fa14-02b2-b123-4d8d-df73763f8431@gmail.com>
In-Reply-To
<CAPUEsphP2GRaHJa0Qnvf22WUnNB+GnnfG8TgHqwJvSGdYfUQGA@mail.gmail.com>
On 23/11/2021 17:31, Carlo Arenas wrote:
Show 18 quoted lines
> On Tue, Nov 23, 2021 at 3:05 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
>> I think a combination of isatty() and tcgetpgrp() is probably the best solution.
> 
> Definitely agree the long term fix needs to include tcgetpgrp() as
> shown by this initial draft[1] (which I apologize, just noticed is
> missing your "Helped-by")
> 
> That of course introduces a regression on the other direction though;
> before this change, git compiled to use our getpass() replacement
> (HAVE_DEV_TTY=1) function, the following will be normally stopped by a
> SIGTTOU just like getpass() if running in the background (need to also
> not have GIT_ASKPASS or SSH_ASKPASS defined in the environment)  :
> 
>    $ echo "https://user@example.com/" | git credential fill
> 
> I suspect that is probably fine though, as when that happens our
> getpass() function still misbehaves if put back in the foreground
> (unlike getpass())

Yes, I tried it out and I couldn't get it to work or figure out why. So long as we don't start echoing the password to the screen we should be fine. It would be nice to know what the problem is that stops it working properly but that is not really related to this patch.

Show 8 quoted lines
> and this "feature" might be undesired anyway as the
> equivalent C code also runs sometimes in daemon-like processes, and
> could even explain some of the workarounds put in place to disable
> password prompts (ex: GIT_TERMINAL_PROMPT=0), but luckily we have all
> the 2.35 dev cycle to figure out.
> 
> Restricting this feature further, maybe through a configuration
> property or even special casing the EDITOR is also IMHO a good idea.

I think just doing this when we run the editor may be the way to go as I think it is only that case that can mess up the terminal.

Best Wishes
Phillip
> Carlo
> 
> [1] https://github.com/carenas/git/commit/64d15b2a74206f31e04cf0200f7be83a54a00517
> 
Previous: Carlo ArenasNext: Chris Torek
Message 20 of 25 in “Update to Git 2.34.0 breaks application”
  1. Alexander VeitNov 22, 2021
  2. Phillip WoodNov 22, 2021
  3. editor: only save (and restore) the terminal if using a ttyCarlo Marcelo Arenas Belón, Nov 22, 2021
  4. Junio C HamanoNov 22, 2021
  5. Junio C HamanoNov 22, 2021
  6. Junio C HamanoNov 22, 2021
  7. Alexander VeitNov 23, 2021
  8. Carlo ArenasNov 23, 2021
  9. Carlo ArenasNov 22, 2021
  10. Junio C HamanoNov 23, 2021
  11. Johannes SchindelinNov 24, 2021
  12. Carlo ArenasNov 24, 2021
  13. Junio C HamanoNov 24, 2021
  14. Carlo ArenasNov 24, 2021
  15. Junio C HamanoNov 24, 2021
  16. Johannes SchindelinNov 29, 2021
  17. Phillip WoodNov 23, 2021
  18. Junio C HamanoNov 23, 2021
  19. Carlo ArenasNov 23, 2021
  20. Phillip WoodNov 30, 2021
  21. Chris TorekDec 1, 2021
  22. Junio C HamanoDec 1, 2021
  23. Junio C HamanoDec 2, 2021
  24. Carlo ArenasDec 2, 2021
  25. Johannes SchindelinDec 2, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.