From: Phillip Wood <phillip.wood123@gmail.com>
To: Avishay Matayev <me@avishay.dev>, git@vger.kernel.org
Cc: gitster@pobox.com
Subject: Re: Forcing git to use a pager without a tty
Date: Wed, 23 Jun 2021 10:29:57 +0100 [thread overview]
Message-ID: <b5462f20-5d9d-4775-ad5c-c8de686167af@gmail.com> (raw)
In-Reply-To: <077d147c-c22f-6463-6545-3aa991e7868b@gmail.com>
On 23/06/2021 10:05, Phillip Wood wrote:
> Hi Avishay
>
> On 22/06/2021 23:40, Avishay Matayev wrote:
>> Hi there!
>>
>> Fugitive[1] is a vim plugin that wraps git and many of its commands
>> into the editor in a really awesome way, I won't meddle into it too
>> much as you can read about it in its README, but as you understand, it
>> uses git, a lot.
>>
>> 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.
>
> If I understand correctly fugitive is reading the output of the git
> command over a pipe and putting it into a vim buffer?
>
>> The only problem left is that Fugitive can't reliably know when git
>> decides to use the pager, for example `git reflog show` does raise the
>> pager while `git reflog expire` does not. Fugitive currently maintains
>> an (very possibly) incomplete list of commands that need a pager but
>> maintaining it manually isn't ideal.
>
> I don't understand, if as you say above there isn't a pty then git wont
> use a pager unless GIT_PAGER_IN_USE is set which Fugitive does not seem
> to,
Sorry that is confused. GIT_PAGER_IN_USE only causes git to act as if a
pager is being used (for example so it colors things as if it was
outputting to a tty), it does not invoke the pager
so I'm not sure what you mean by 'Fugitive can't reliably know when
> git decides to use the pager'
I'm still confused by this - if there is no tty git wont use a pager.
Best Wishes
Phillip
>> 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.
>>
>> 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.
>
> I note that the latest comment [1] on the github issue talks about a
> different solution that would cause all git commands to behave as if
> there was a pty present.
>
> [1]
> https://github.com/tpope/vim-fugitive/issues/1772#issuecomment-866401942
>
> Best Wishes
>
> Phillip
>
>> I will appreciate any written thoughts on the matter, thank you :)
>>
>> P.S. I am a complete newbie in regards to mailing lists etiquette,
>> pardon me if I've done anything incorrect
>> P.P.S. I CC'd Junio C Hamano because he signed off on (almost?) all
>> changes to `pager.c`, sorry if that was wrong of me (You probably got
>> this mail twice because of a misconfiguration, oops)
>>
>>
>> 1. https://github.com/tpope/vim-fugitive
>> 2. https://github.com/tpope/vim-fugitive/issues/1772
>>
next prev parent reply other threads:[~2021-06-23 9:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-22 22:40 Avishay Matayev
2021-06-23 1:56 ` Felipe Contreras
2021-06-23 8:25 ` Forcing git to use a pager without a tty Avishay Matayev
2021-06-25 17:42 ` Felipe Contreras
2021-06-26 10:28 ` Avishay Matayev
2021-06-23 8:12 ` Why empty subject? (was Re: ) Bagas Sanjaya
2021-06-23 8:21 ` Avishay Matayev
2021-06-23 9:05 ` Forcing git to use a pager without a tty Phillip Wood
2021-06-23 9:29 ` Phillip Wood [this message]
2021-06-24 20:25 ` Avishay Matayev
2021-06-24 22:10 ` Ævar Arnfjörð Bjarmason
2021-06-26 10:26 ` Avishay Matayev
2021-06-29 6:09 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b5462f20-5d9d-4775-ad5c-c8de686167af@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=me@avishay.dev \
--cc=phillip.wood@dunelm.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).