git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Ben Walton <bwalton@artsci.utoronto.ca>
To: gitster@pobox.com, jrnieder@gmail.com, git@vger.kernel.org
Cc: Ben Walton <bwalton@artsci.utoronto.ca>
Subject: [PATCH 1/2] Provide a build time default-pager setting
Date: Thu, 29 Oct 2009 12:42:44 -0400	[thread overview]
Message-ID: <1256834565-19443-2-git-send-email-bwalton@artsci.utoronto.ca> (raw)
In-Reply-To: <1256834565-19443-1-git-send-email-bwalton@artsci.utoronto.ca>

From: Junio C Hamano <gitster@pobox.com>

On (old) solaris systems, /usr/bin/less (typically the first less
found) doesn't understand the default arguments (FXRS), which
forces users to alter their environment (PATH, GIT_PAGER, LESS,
etc) or have a local or global gitconfig before paging works as
expected.

On Debian systems, by policy packages must fall back to the
'pager' command, so that changing the target of the
/usr/bin/pager symlink changes the default pager for all packages
at once.

Provide a DEFAULT_PAGER knob so packagers can set the fallback
pager to something appropriate during the build.

This puts the "less" default in the Makefile instead of pager.c, since
it is needed for git-svn and git-am, too.  This means that the
DEFAULT_PAGER preprocessor token _has_ to be defined on the command
line for git to build.  I was worried about this for a moment, but
GIT_VERSION already works this way without trouble.

Probably the DEFAULT_PAGER setting should be added to something
like TRACK_CFLAGS as well.  Actually, some other settings that
can change without forcing files to be rebuilt (e.g. SHELL_PATH),
too.  This should be probably be addressed separately.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca>
---
 Makefile     |    9 +++++++++
 git-am.sh    |    2 +-
 git-svn.perl |    5 +++--
 pager.c      |    2 +-
 4 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 42b7d60..1d26800 100644
--- a/Makefile
+++ b/Makefile
@@ -200,6 +200,9 @@ all::
 # memory allocators with the nedmalloc allocator written by Niall Douglas.
 #
 # Define NO_REGEX if you have no or inferior regex support in your C library.
+#
+# Define DEFAULT_PAGER to the path of a sensible pager (defaults to "less") if
+# you want to use something different.
 
 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
 	@$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -1294,6 +1297,10 @@ ifdef NO_REGEX
 	COMPAT_CFLAGS += -Icompat/regex
 	COMPAT_OBJS += compat/regex/regex.o
 endif
+ifndef DEFAULT_PAGER
+	DEFAULT_PAGER = less
+endif
+BASIC_CFLAGS += -DDEFAULT_PAGER='"$(DEFAULT_PAGER)"'
 
 ifdef USE_NED_ALLOCATOR
        COMPAT_CFLAGS += -DUSE_NED_ALLOCATOR -DOVERRIDE_STRDUP -DNDEBUG -DREPLACE_SYSTEM_ALLOCATOR -Icompat/nedmalloc
@@ -1428,6 +1435,7 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
 	    -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
 	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
 	    -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
+	    -e 's|@@DEFAULT_PAGER@@|$(DEFAULT_PAGER)|g' \
 	    -e $(BROKEN_PATH_FIX) \
 	    $@.sh >$@+ && \
 	chmod +x $@+ && \
@@ -1451,6 +1459,7 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
 	    -e '}' \
 	    -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
 	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
+	    -e 's|@@DEFAULT_PAGER@@|$(DEFAULT_PAGER)|g' \
 	    $@.perl >$@+ && \
 	chmod +x $@+ && \
 	mv $@+ $@
diff --git a/git-am.sh b/git-am.sh
index c132f50..a194a4e 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -649,7 +649,7 @@ do
 		[eE]*) git_editor "$dotest/final-commit"
 		       action=again ;;
 		[vV]*) action=again
-		       LESS=-S ${PAGER:-less} "$dotest/patch" ;;
+		       LESS=-S ${PAGER:-@@DEFAULT_PAGER@@} "$dotest/patch" ;;
 		*)     action=again ;;
 		esac
 	    done
diff --git a/git-svn.perl b/git-svn.perl
index eb4b75a..a61ec55 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -3,11 +3,12 @@
 # License: GPL v2 or later
 use warnings;
 use strict;
-use vars qw/	$AUTHOR $VERSION
+use vars qw/	$AUTHOR $VERSION $DEFAULT_PAGER
 		$sha1 $sha1_short $_revision $_repository
 		$_q $_authors $_authors_prog %users/;
 $AUTHOR = 'Eric Wong <normalperson@yhbt.net>';
 $VERSION = '@@GIT_VERSION@@';
+$DEFAULT_PAGER = '@@DEFAULT_PAGER@@';
 
 # From which subdir have we been invoked?
 my $cmd_dir_prefix = eval {
@@ -5031,7 +5032,7 @@ sub git_svn_log_cmd {
 sub config_pager {
 	$pager ||= $ENV{GIT_PAGER} || $ENV{PAGER};
 	if (!defined $pager) {
-		$pager = 'less';
+		$pager = $DEFAULT_PAGER;
 	} elsif (length $pager == 0 || $pager eq 'cat') {
 		$pager = undef;
 	}
diff --git a/pager.c b/pager.c
index 86facec..416a796 100644
--- a/pager.c
+++ b/pager.c
@@ -58,7 +58,7 @@ void setup_pager(void)
 	if (!pager)
 		pager = getenv("PAGER");
 	if (!pager)
-		pager = "less";
+		pager = DEFAULT_PAGER;
 	else if (!*pager || !strcmp(pager, "cat"))
 		return;
 
-- 
1.6.5

      reply	other threads:[~2009-10-29 16:43 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-28 15:21 packaging vs default pager Ben Walton
2009-10-28 17:55 ` Junio C Hamano
2009-10-29  7:32   ` [PATCH 0/2] " Jonathan Nieder
2009-10-29  7:45     ` [PATCH 1/2] Provide a build time default-pager setting Jonathan Nieder
2009-10-29  7:50     ` [PATCH/RFC 2/2] Provide a build time default-editor setting Jonathan Nieder
2009-10-29 10:36       ` David Roundy
2009-10-29 11:50         ` Johannes Sixt
2009-10-29 20:40           ` Junio C Hamano
2009-10-29 20:57             ` Johannes Sixt
2009-10-29 22:12               ` Junio C Hamano
2009-10-30  2:21                 ` David Roundy
2009-10-29 20:43       ` Junio C Hamano
2009-10-30 10:16         ` [PATCH v2 0/8] Default pager and editor Jonathan Nieder
2009-10-30 10:20           ` [PATCH 1/8] launch_editor: Longer error message when TERM=dumb Jonathan Nieder
2009-10-30 10:25           ` [PATCH 2/8] Handle more shell metacharacters in editor names Jonathan Nieder
2009-10-30 10:26           ` [PATCH 3/8] Teach git var about GIT_EDITOR Jonathan Nieder
2009-10-30 20:51             ` Johannes Sixt
2009-10-30 22:47               ` Jonathan Nieder
2009-10-30 22:43                 ` Junio C Hamano
2009-10-31  0:01                   ` Jonathan Nieder
2009-10-30 10:29           ` [PATCH 4/8] Teach git var about GIT_PAGER Jonathan Nieder
2009-10-30 10:32           ` [PATCH 5/8] add -i, send-email, svn, p4, etc: use "git var GIT_EDITOR" Jonathan Nieder
2009-10-30 10:33           ` [PATCH 6/8] am -i, git-svn: use "git var GIT_PAGER" Jonathan Nieder
2009-10-30 10:35           ` [PATCH 7/8] Provide a build time default-editor setting Jonathan Nieder
2009-10-30 13:17             ` Jonathan Nieder
2009-10-30 10:39           ` [PATCH 8/8] Provide a build time default-pager setting Jonathan Nieder
2009-10-30 22:59             ` Junio C Hamano
2009-10-30 10:49           ` [PATCH/RFC 9/8] Teach git var to run the editor Jonathan Nieder
2009-10-31  1:20           ` [PATCH v3 0/8] Default pager and editor Jonathan Nieder
2009-10-31  1:24             ` [PATCH 1/8] Handle more shell metacharacters in editor names Jonathan Nieder
2009-10-31  1:30             ` [PATCH 2/8] Do not use VISUAL editor on dumb terminals Jonathan Nieder
2009-10-31  7:46               ` [PATCH v2 " Jonathan Nieder
2009-10-31  1:39             ` [PATCH v2 3/8] Teach git var about GIT_EDITOR Jonathan Nieder
2009-10-31  2:01               ` Junio C Hamano
2009-10-31  2:23                 ` Jonathan Nieder
2009-10-31  2:34                   ` Junio C Hamano
2009-10-31  4:00                     ` Jonathan Nieder
2009-10-31  4:04                       ` [PATCH v3] " Jonathan Nieder
2009-10-31  4:53                         ` Jonathan Nieder
2009-10-31  7:56                           ` [PATCH v4] " Jonathan Nieder
2009-11-01  4:29                             ` Junio C Hamano
2009-10-31 19:40               ` [PATCH v2 3/8] " Johannes Sixt
2009-10-31  1:41             ` [PATCH 4/8] Teach git var about GIT_PAGER Jonathan Nieder
2009-10-31  1:42             ` [PATCH 5/8] add -i, send-email, svn, p4, etc: use "git var GIT_EDITOR" Jonathan Nieder
2009-10-31  1:43             ` [PATCH 6/8] am -i, git-svn: use "git var GIT_PAGER" Jonathan Nieder
2009-10-31  1:44             ` [PATCH 7/8] Provide a build time default-editor setting Jonathan Nieder
2009-10-31  2:09               ` Junio C Hamano
2009-10-31  3:26                 ` Jonathan Nieder
2009-10-31 19:51                   ` Junio C Hamano
2009-10-31 21:21                     ` Jonathan Nieder
2009-11-01  4:29                       ` Junio C Hamano
2009-10-31  1:45             ` [PATCH 8/8] Provide a build time default-pager setting Jonathan Nieder
2009-11-11 23:51             ` [PATCH v4 0/9] Default pager and editor Jonathan Nieder
2009-11-11 23:52               ` [PATCH 1/9] Handle more shell metacharacters in editor names Jonathan Nieder
2009-11-11 23:56               ` [PATCH 2/9] Do not use VISUAL editor on dumb terminals Jonathan Nieder
2009-11-11 23:57               ` [PATCH 3/9] Suppress warnings from "git var -l" Jonathan Nieder
2009-11-12  0:01               ` [PATCH 4/9] Teach git var about GIT_EDITOR Jonathan Nieder
2009-11-12  0:02               ` [PATCH 5/9] Teach git var about GIT_PAGER Jonathan Nieder
2009-11-12  0:02               ` [PATCH 6/9] add -i, send-email, svn, p4, etc: use "git var GIT_EDITOR" Jonathan Nieder
2009-11-12  0:03               ` [PATCH 7/9] am -i, git-svn: use "git var GIT_PAGER" Jonathan Nieder
2009-11-12  0:03               ` [PATCH 8/9] Provide a build time default-editor setting Jonathan Nieder
2009-11-12  0:04               ` [PATCH 9/9] Provide a build time default-pager setting Jonathan Nieder
2009-11-15  9:04               ` [PATCH v4 0/9] Default pager and editor Junio C Hamano
2009-10-29 16:42     ` [PATCH 0/2] Default Pager and Editor at build-time Ben Walton
2009-10-29 16:42       ` Ben Walton [this message]

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1256834565-19443-2-git-send-email-bwalton@artsci.utoronto.ca \
    --to=bwalton@artsci.utoronto.ca \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).