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

Re: To page or not to page

From
Jeff King <peff@peff.net>
Date
May 5, 2008, 21:59 UTC
Message-ID
<20080505215924.GA9228@sigill.intra.peff.net>
In-Reply-To
<7v1w4ky3hh.fsf@gitster.siamese.dyndns.org>
On Fri, May 02, 2008 at 11:18:02AM -0700, Junio C Hamano wrote:
Show 28 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > My bigger worry is that this affects only builtins. Which makes it
> > sufficient for turning off the pager for anything that does USE_PAGER.
> 
> Hmm. How about doing things this way?
> 
>  - at the beginning of handle_options() remember argv[0]
> 
>  - restructure handle_options() so that it does not run setup_pager() and
>    setenv("GIT_PAGER", "cat", 1) inside the loop, but instead remember
>    what we had on the command line;
> 
>  - after the handle_options() loop, if we saw an explicit --pager,
>    --no-pager, that's the decision;
> 
>  - otherwise:
> 
>    - look at argv[0] to see what the command is;
> 
>    - do the config thing to see if there is user preference; if there is
>      one, that setting decides;
> 
>    - otherwise:
> 
>      - see the built-in defaults;
> 
>  - and finally use or not use pager depending on what we found above.

OK, that makes some sense. I think some of what you describe is just refactoring (e.g., it doesn't matter if we actually do things when we see --no-pager or afterwards, since it always takes precedence). The key things are:

  - work not just on running builtins, but before we even figure out
    whether we have a builtin or a script
  - in my patch the config just says "ignore the default USE_PAGER", but
    it really should be "turn off the pager via GIT_PAGER=cat". That way
    you can say pager.stash = false, and it will impact the git-diff
    invocation run by stash.

But that isn't to say the refactoring isn't worth doing to keep things clean. I will take a stab at restructuring it the way you specified.

There is one remaining annoyance, though: this code is only run via the git wrapper. That means that you will get different behavior for "git-stash" versus "git stash". To make that work, we would have to put equivalent support into each script (although we could hit several at once with git-sh-setup.sh) and each non-builtin.

-Peff
Previous: Junio C HamanoNext: Jeff King
Message 22 of 31 in “To page or not to page”
  1. Kevin BallardMay 2, 2008
  2. Jeff KingMay 2, 2008
  3. Junio C HamanoMay 2, 2008
  4. Kevin BallardMay 2, 2008
  5. Junio C HamanoMay 2, 2008
  6. Bart TrojanowskiMay 2, 2008
  7. Pedro MeloMay 2, 2008
  8. Kevin BallardMay 2, 2008
  9. Wincent ColaiutaMay 2, 2008
  10. Jeff KingMay 2, 2008
  11. Pedro MeloMay 2, 2008
  12. Aidan Van DykMay 2, 2008
  13. Wincent ColaiutaMay 2, 2008
  14. Kevin BallardMay 2, 2008
  15. Wincent ColaiutaMay 2, 2008
  16. Jeff KingMay 2, 2008
  17. Johannes SchindelinMay 2, 2008
  18. Jeff KingMay 2, 2008
  19. Junio C HamanoMay 2, 2008
  20. Jeff KingMay 2, 2008
  21. Junio C HamanoMay 2, 2008
  22. Jeff KingMay 5, 2008
  23. Jeff KingMay 6, 2008
  24. Jeff KingMay 6, 2008
  25. Junio C HamanoMay 11, 2008
  26. Jeff KingMay 16, 2008
  27. Jeff KingMay 16, 2008
  28. Johannes SchindelinMay 16, 2008
  29. Jakub NarebskiMay 2, 2008
  30. Jeff KingMay 2, 2008
  31. Jeff KingMay 2, 2008

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.