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

(no subject)

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Jun 23, 2021, 01:56 UTC
Message-ID
<60d294eb984ba_3122081@natae.notmuch>
In-Reply-To
<CAJ-0OswsrnAuCwU6U=S2i1qKkg=66U-8RHSGqD2kh9T_30Yw9w@mail.gmail.com>
Avishay Matayev wrote:
Show 5 quoted lines
> 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.
> I started discussing this on an issue in Fugitive's github page[2] and
> Tim Pope (the creator and maintainer of Fugitive, thank you!)
> explained that `git` doesn't use a pager if there is no pty so it's
> impossible to override its behavior.
That is true.
Show 8 quoted lines
> 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
Previous: Avishay MatayevNext: Avishay Matayev
Message 2 of 13 in “”
  1. Avishay MatayevJun 22, 2021
  2. Felipe ContrerasJun 23, 2021
  3. Avishay MatayevJun 23, 2021
  4. Felipe ContrerasJun 25, 2021
  5. Avishay MatayevJun 26, 2021
  6. Why empty subject? (was Re: )Bagas Sanjaya, Jun 23, 2021
  7. Avishay MatayevJun 23, 2021
  8. Phillip WoodJun 23, 2021
  9. Phillip WoodJun 23, 2021
  10. Avishay MatayevJun 24, 2021
  11. Ævar Arnfjörð BjarmasonJun 24, 2021
  12. Avishay MatayevJun 26, 2021
  13. Junio C HamanoJun 29, 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.