Re: Forcing git to use a pager without a tty

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

 



On Wed, 23 Jun 2021 at 04:57, Felipe Contreras
<felipe.contreras@xxxxxxxxx> wrote:
>
> Avishay Matayev wrote:
>
> > Some git commands use a pager, which is usually a program that needs a
> > pty to function properly (`less`, for example). Fugitive can't really
> > use a pty for the pager as vim runs its subprocesses without a pty.
> > Therefore Fugitive just creates its own pager (which is a simple
> > window in vim) and pastes the git command output there.
>
> That's not necessarily true; vim uses a bunch of convoluted logic to
> sometimes use a pty, but that depends on the mode used (graphical vs.
> console), and a bunch of other things.
>
> Even more complicated when you throw nvim into the mix.
>
> But yeah, for the sake of simplication let's say that's true.

True, I did oversimplify.

> > We had some ideas how to make this feasible (as you can read on the
> > thread) but for brevity's sake I'll present the best (IMO) idea:
> > Essentially, at `pager.c`, don't short-circuit in `git_pager` (or
> > `setup_pager`?) due to pty absence if a new environment variable is
> > present, perhaps something like `GIT_PAGER_FORCE` which will override
> > the `PAGER` and `GIT_PAGER` variables. This will allow Fugitive to
> > apply custom logic through to pager to know if one exists and present
> > the window in vim.
>
> Seems like a completely sensible request to me, except I would do it a
> slightly different place:
>
> --- a/pager.c
> +++ b/pager.c
> @@ -101,7 +101,7 @@ void prepare_pager_args(struct child_process *pager_process, const char *pager)
>
>  void setup_pager(void)
>  {
> -       const char *pager = git_pager(isatty(1));
> +       const char *pager = git_pager(git_env_bool("GIT_PAGER_FORCE", isatty(1)));
>
>         if (!pager)
>                 return;
>
> I'm Cc'ing Jonathan Nieder who seems to have toched these lines.
>
> Cheers.
>
> --
> Felipe Contreras

Well I'm glad to hear you find it sensible, though your patch suggests
that `GIT_PAGER_FORCE` will be a boolean, while I expect it to be an
actual pager, which would make more sense IMO.

Avishay



[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