From: Matthieu Moy <Matthieu.Moy@grenoble-inp•fr>
To: worley@alum•mit.edu (Dale R. Worley)
Cc: git@vger•kernel.org, Junio C Hamano <gitster@pobox•com>
Subject: Re: the pager
Date: Thu, 29 Aug 2013 17:55:29 +0200 [thread overview]
Message-ID: <vpqsixsv6dq.fsf@anie.imag.fr> (raw)
In-Reply-To: <201308291541.r7TFfuJr023110@freeze.ariadne.com> (Dale R. Worley's message of "Thu, 29 Aug 2013 11:41:56 -0400")
worley@alum•mit.edu (Dale R. Worley) writes:
> const char *git_pager(int stdout_is_tty)
> {
> const char *pager;
>
> if (!stdout_is_tty)
> return NULL;
>
> pager = getenv("GIT_PAGER");
> if (!pager) {
> if (!pager_program)
> git_config(git_default_config, NULL);
> pager = pager_program;
> }
> if (!pager)
> pager = getenv("PAGER");
> if (!pager)
> pager = DEFAULT_PAGER;
> else if (!*pager || !strcmp(pager, "cat"))
> pager = NULL;
I guess the "else" could and should be dropped. If you do so (and
possibly insert a blank line between the DEFAULT_PAGER case and the
"pager = NULL" case), you get a nice pattern
if (!pager)
try_something();
if (!pager)
try_next_option();
...
> Commenting your code is what you learn first in programming.
Not commenting too much is the second thing you learn ;-).
I agree that a comment like this would help, though:
--- a/cache.h
+++ b/cache.h
@@ -1266,7 +1266,7 @@ static inline ssize_t write_str_in_full(int fd, const char *str)
/* pager.c */
extern void setup_pager(void);
-extern const char *pager_program;
+extern const char *pager_program; /* value read from git_config() */
extern int pager_in_use(void);
extern int pager_use_color;
extern int term_columns(void);
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
next prev parent reply other threads:[~2013-08-29 15:57 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-26 19:57 the pager Dale R. Worley
2013-08-27 4:38 ` Junio C Hamano
2013-08-28 18:19 ` Dale R. Worley
2013-08-28 20:26 ` Junio C Hamano
2013-08-29 15:41 ` Dale R. Worley
2013-08-29 15:55 ` Matthieu Moy [this message]
2013-09-03 2:27 ` Dale R. Worley
2013-09-03 2:57 ` Jonathan Nieder
2013-09-03 7:41 ` [PATCH] pager: turn on "cat" optimization for DEFAULT_PAGER Jeff King
2013-09-03 17:35 ` Junio C Hamano
2013-11-20 17:24 ` Erik Faye-Lund
2013-11-20 17:30 ` Jeff King
2013-11-20 17:33 ` Erik Faye-Lund
2013-11-20 17:33 ` Junio C Hamano
2013-11-20 17:34 ` Erik Faye-Lund
2013-09-03 8:16 ` the pager Jeff King
2013-09-03 2:37 ` Dale R. Worley
2013-09-03 8:01 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=vpqsixsv6dq.fsf@anie.imag.fr \
--to=matthieu.moy@grenoble-inp$(echo .)fr \
--cc=git@vger$(echo .)kernel.org \
--cc=gitster@pobox$(echo .)com \
--cc=worley@alum$(echo .)mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox