Re: Force usage of pager for diff, show, etc when piping to non-TTY

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

 



On Wed, Aug 16, 2023 at 09:30:38AM -0700, Patrick wrote:

> Jeff, would you be so kind as to elaborate more on the
> interactive.diffFilter approach? My understanding is that
> interactive.diffFilter is only used for git add -p or git reset -p.
> However, the limitation for my use case is I need to use the pager
> for git log and git show so that won't work. So then, you are
> suggesting that I ask my users to opt in by setting an arbitrary git
> config like fzf.pager and then read out the pager from that git var?

Yes, they'd have to set a new config variable. Though if you are really
just filtering diffs and the semantics would be the same as
interactive.diffFilter, I would probably just use that. You could also
introduce a new foo.diffFilter option, and if unset have it default to
the value of interactive.diffFilter. That provides flexibility without
forcing users to repeat themselves.

That said, I would not be surprised if many users who set pager.log do
not even know about interactive.diffFilter. It's a bit more obscure, and
came later.

If you do want to follow that approach, the simplest example is probably
just to see how it was added to the perl code in 01143847db
(add--interactive: allow custom diff highlighting programs, 2016-02-27):

  https://github.com/git/git/commit/01143847dbf4fbf27268650f3ace16eac03b3130

In shell it might look something like:

  filter=$(git config --get interactive.difffilter)
  if test -n "$filter"; then
    git show ... | eval "$filter"
  else
    git show ...
  fi

-Peff



[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