threads / discuss / 33992

Should "git help" respect the 'pager' setting?

Subject: Should "git help" respect the 'pager' setting?

## tl;dr

7 messages between May 30, 2013 and Jun 2, 2013.

replies: 6people: 5as markdown or json

Michael Campbell· May 30, 2013, 16:33 UTC · lore

I have my global git config pager set to 'cat', but when I do a "git help <command>", it still uses a pager. This is especially irksome in emacs shell buffers, where I am most of the time. I know I can do a M-x man -> git-<whatever>, but wondered if this was a bug or user error. ("git --no-pager help <command>" does the same.)

12:31 [mcampbell] /tmp  % git --no-pager help log
WARNING: terminal is not fully functional
-  (press RETURN)
Matthieu Moy· May 30, 2013, 16:42 UTC · re: Michael Campbell · lore

Re: Should "git help" respect the 'pager' setting?

Michael Campbell <michael.campbell@gmail.com> writes:
Show 5 quoted lines
> I have my global git config pager set to 'cat', but when I do a "git
> help <command>", it still uses a pager.  This is especially irksome in
> emacs shell buffers, where I am most of the time.  I know I can do a
> M-x man -> git-<whatever>, but wondered if this was a bug or user
> error.  ("git --no-pager help <command>" does the same.)

"git help foo" just calls "man git-foo" by default, so what happens is the same as if you called "man git-foo" by hand. Git does not have much control over what man will do, it could probably call "man -P $pager" when the Git pager is set, but I'd find it a bit weird.

If you're an Emacs user, you can read about man.viewer and set it to woman, or set PAGER=cat when inside Emacs.

I personally run M-x git-foo RET, and never run "git help".
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Ramkumar Ramachandra· May 30, 2013, 16:56 UTC · re: Matthieu Moy · lore

Re: Should "git help" respect the 'pager' setting?

Matthieu Moy wrote:
Show 11 quoted lines
> Michael Campbell <michael.campbell@gmail.com> writes:
>> I have my global git config pager set to 'cat', but when I do a "git
>> help <command>", it still uses a pager.  This is especially irksome in
>> emacs shell buffers, where I am most of the time.  I know I can do a
>> M-x man -> git-<whatever>, but wondered if this was a bug or user
>> error.  ("git --no-pager help <command>" does the same.)
>
> "git help foo" just calls "man git-foo" by default, so what happens is
> the same as if you called "man git-foo" by hand. Git does not have
> much control over what man will do, it could probably call "man -P
> $pager" when the Git pager is set, but I'd find it a bit weird.

It just needs to set $PAGER or $MANPAGER before the exec(), no? I would argue that it should do this. $GIT_PAGER works everywhere else, but obviously man has no knowledge about it.

> If you're an Emacs user, you can read about man.viewer and set it to
> woman, or set PAGER=cat when inside Emacs.

I just learnt about man.viewer. There's a small problem with it though: why is there no option for Emacs man corresponding to Emacs woman?

> I personally run M-x git-foo RET, and never run "git help".

M-x man git-foo RET, you mean? My style is slightly different: I love typing out 'man git log' on the terminal (dashless); I get it to open in an Emacs buffer using this hack:

function man_ () {
	emacsclient -e "(man \"$*\")" 2>&1 >/dev/null || man "$*"
}
alias man=man_
Matthieu Moy· May 30, 2013, 17:05 UTC · re: Ramkumar Ramachandra · lore

Re: Should "git help" respect the 'pager' setting?

Ramkumar Ramachandra <artagnon@gmail.com> writes:
> It just needs to set $PAGER or $MANPAGER before the exec(), no?
Yes, that should do the same as "man -P".
> I would argue that it should do this. $GIT_PAGER works everywhere
> else, but obviously man has no knowledge about it.

I find it a bit weird that Git sets the configuration for external commands, but it may make sense. No strong opinion here.

Show 6 quoted lines
>> If you're an Emacs user, you can read about man.viewer and set it to
>> woman, or set PAGER=cat when inside Emacs.
>
> I just learnt about man.viewer.  There's a small problem with it
> though: why is there no option for Emacs man corresponding to Emacs
> woman?
I guess because no one implemented it ;-).
>> I personally run M-x git-foo RET, and never run "git help".
>
> M-x man git-foo RET, you mean?
Yes, sorry.
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Ramkumar Ramachandra· May 30, 2013, 17:08 UTC · re: Matthieu Moy · lore

Re: Should "git help" respect the 'pager' setting?

Matthieu Moy wrote:
> I find it a bit weird that Git sets the configuration for external
> commands, but it may make sense. No strong opinion here.

I don't mean a setenv() kind of thing: how would we unset it after that? Perhaps something like execvpe(), passing in the environment as an argument?

John Keeping· May 30, 2013, 17:14 UTC · re: Ramkumar Ramachandra · lore

Re: Should "git help" respect the 'pager' setting?

On Thu, May 30, 2013 at 10:38:59PM +0530, Ramkumar Ramachandra wrote:
Show 7 quoted lines
> Matthieu Moy wrote:
> > I find it a bit weird that Git sets the configuration for external
> > commands, but it may make sense. No strong opinion here.
> 
> I don't mean a setenv() kind of thing: how would we unset it after
> that?  Perhaps something like execvpe(), passing in the environment as
> an argument?

Overriding PAGER might make sense, but I'd be quite annoyed if Git decided to override MANPAGER without providing some way to override it.

If a user sets MANPAGER then it's because they want a specific pager when reading man pages - invoking man through "git help" shouldn't cause it to behave differently in this case.

Junio C Hamano· Jun 2, 2013, 22:24 UTC · re: John Keeping · lore

Re: Should "git help" respect the 'pager' setting?

John Keeping <john@keeping.me.uk> writes:
Show 8 quoted lines
> On Thu, May 30, 2013 at 10:38:59PM +0530, Ramkumar Ramachandra wrote:
>> Matthieu Moy wrote:
>> > I find it a bit weird that Git sets the configuration for external
>> > commands, but it may make sense. No strong opinion here.
>> 
>> I don't mean a setenv() kind of thing: how would we unset it after
>> that?  Perhaps something like execvpe(), passing in the environment as
>> an argument?

Running "man" is the last thing we do before exitting "git help" and exec_man_man() does seem to do execlp(), so I do not see it as an issue.

> Overriding PAGER might make sense, but I'd be quite annoyed if Git
> decided to override MANPAGER without providing some way to override it.
Hmm, see below.
> If a user sets MANPAGER then it's because they want a specific pager
> when reading man pages - invoking man through "git help" shouldn't cause
> it to behave differently in this case.

True, and for that matter, if the user sets PAGER to use with non-Git (including manual pages) and also sets GIT_PAGER to use specifically with Git, the user would be annoyed if we passed formatted manual pages to GIT_PAGER by exporting PAGER (or driving "man" with its "-P" option).

← back to recent threads