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

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

From
PPatrick <patrickf3139@gmail.com>
Date
Aug 17, 2023, 17:06 UTC
Message-ID
<CAMRL+qbSn058AsMW7+d1nRbt4Ao6R+BZ6HYHxDrVQhURgWoy7Q@mail.gmail.com>
In-Reply-To
<20230817054405.GD3006160@coredump.intra.peff.net>

Hi Jeff, I think I finally get it now. Thank you for so patiently explaining this to me in different ways. I'm sorry I was slow to understand heh. Just to be really clear, the filter in `interactive.diffFilter` is meant as a filter for transforming (think a photo filter), as opposed to a filter that removes elements, correct? I think that's what I got tripped up on when you explained the first two times.

On Wed, Aug 16, 2023 at 10:44 PM Jeff King <peff@peff.net> wrote:
Show 38 quoted lines
>
> 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
Previous: Jeff KingNext: Jeff King
Message 5 of 7 in “Force usage of pager for diff, show, etc when piping to non-TTY”
  1. PatrickAug 16, 2023
  2. Jeff KingAug 16, 2023
  3. PatrickAug 16, 2023
  4. Jeff KingAug 17, 2023
  5. PatrickAug 17, 2023
  6. Jeff KingAug 17, 2023
  7. PatrickAug 17, 2023

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.