New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Git reflog shouldn't always open the pager #1772
Comments
The goal is to implement it correctly for each command. Ideally we'd let Git decide instead, but Git disables the pager if there isn't a PTY, with no way to override. |
A few things:
|
Git consults https://github.com/git/git/blob/670b81a890388c60b7032a4f5b879f2ece8c4558/pager.c#L102-L107 The utility function it calls short circuits if it's false, with no way to override: https://github.com/git/git/blob/670b81a890388c60b7032a4f5b879f2ece8c4558/pager.c#L44-L65 The most straightforward solution would be an environment variable that takes precedence. Something that changes the conditional to perhaps look like: if (!git_env_bool("GIT_PAGER_FORCE",` stdout_is_tty))
return NULL; With this in place, I could set Your ideas sound more convenient than mine, but also higher effort and lower overall value outside of Fugitive. I wouldn't oppose them, but I wouldn't expect Git core to share that opinion. |
Oh, I haven't thought about using
I disagree, your idea sounds much more convenient as it fits exactly to Fugitive's need. I'll create a discussion over in git's mailing list and report back soon, thanks! |
Hm.. I have a question, why does git not recognize the pty? Is this just to support Windows? Or is this because vim doesn't pass the pty to In fact, I played a bit with |
Okay I played a bit with nvim by calling |
Windows is the primary place we can't use a PTY; it's also not available on older versions of Vim. You're not seeing results because your |
Now that I think about it, the lack of a PTY burns us in a few other places. To name 2 examples, |
Oh, right, I forgot that it is an actual git flag.
I'm not sure I understand how Perhaps you are planning on parsing the escape sequences that will be written to your PAGER and then displaying it as you want? |
Progress bars use nothing more than a carriage return to reset the cursor position to the beginning of the line, which Vim's |
Oh that's neat, TIL about I'm dropping the link to the discussion at the mailing list here https://lore.kernel.org/git/CAJ-0Osy9JhGD0=6eF3jgZuoHJEzymksCWZZZC+A4FtHxzOrdhA@mail.gmail.com/T/#u |
Resisting the urge to join that thread (I reserve the right to change my mind) but I want to clarify that while thread pays lip service to " https://github.com/git/git/blob/670b81a890388c60b7032a4f5b879f2ece8c4558/sequencer.c#L2043 If I were to propose an implementation, it would be to add a utility function: int git_isatty(int fd)
{
return git_env_bool("GIT_FORCE_TTY", isatty(fd));
} And then replace all calls to |
Please do join the thread, your understanding of the issue is probably better than most people's view. The new suggestion seems nice, but we should probably check each call site and make sure it makes sense everywhere. |
I don't know if this is done by design to avoid implementing it correctly for each command, but the only time the pager should open for
git reflog
is when calling it as is (or withshow
, which is the default behaviour).I found this out because I used fugitive to write a vim function that mimicks something like
git stash push -k
that doesn't push the index to the stash (i.e stashing only whatever is not in the index), it made the reflog messy (I solved it by creating a commit for whatever is in the index and then callinggit reset --soft HEAD~1
) so I usedgit reflog delete
to cleanup things a bit, but it opened the pager so for now I am just closing the window :)If fixing this seems right for fugitive, I could try and do it myself.
The text was updated successfully, but these errors were encountered: