Merge branch 'jn/pager-lv-default-env'
authorJunio C Hamano <gitster@pobox.com>
Mon, 13 Jan 2014 19:33:34 +0000 (11:33 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 13 Jan 2014 19:33:35 +0000 (11:33 -0800)
Just like we give a reasonable default for "less" via the LESS
environment variable, specify a reasonable default for "lv" via the
"LV" environment variable when spawning the pager.

* jn/pager-lv-default-env:
pager: set LV=-c alongside LESS=FRSX

1  2 
Documentation/config.txt
git-sh-setup.sh
pager.c
diff --combined Documentation/config.txt
index a4058063cedd61d88990faf739bda955834b1ea7,81064507b6fbdc95751d2046c3d9b77e0fe3ebfe..ed5985319089e287b5ada6353d42b1e81568290c
@@@ -567,6 -567,10 +567,10 @@@ be passed to the shell by Git, which wi
  command to `LESS=FRSX less -+S`. The environment tells the command
  to set the `S` option to chop long lines but the command line
  resets it to the default to fold long lines.
+ +
+ Likewise, when the `LV` environment variable is unset, Git sets it
+ to `-c`.  You can override this setting by exporting `LV` with
+ another value or setting `core.pager` to `lv +c`.
  
  core.whitespace::
        A comma separated list of common whitespace problems to
@@@ -2087,8 -2091,8 +2091,8 @@@ remote.<name>.vcs:
  
  remote.<name>.prune::
        When set to true, fetching from this remote by default will also
 -      remove any remote-tracking branches which no longer exist on the
 -      remote (as if the `--prune` option was give on the command line).
 +      remove any remote-tracking references that no longer exist on the
 +      remote (as if the `--prune` option was given on the command line).
        Overrides `fetch.prune` settings, if any.
  
  remotes.<group>::
diff --combined git-sh-setup.sh
index 190a5394b9265270faadf578685e9a12b4efebfd,f295e586b53089cb3646962d4acdfdbd750b54cf..fffa3c72d75961159888fd156614aa6679f3638c
@@@ -1,6 -1,9 +1,6 @@@
 -#!/bin/sh
 -#
 -# This is included in commands that either have to be run from the toplevel
 -# of the repository, or with GIT_DIR environment variable properly.
 -# If the GIT_DIR does not look like the right correct git-repository,
 -# it dies.
 +# This shell scriplet is meant to be included by other shell scripts
 +# to set up some variables pointing at the normal git directories and
 +# a few helper shell functions.
  
  # Having this variable in your environment would break scripts because
  # you would cause "cd" to be taken to unexpected places.  If you
@@@ -159,7 -162,8 +159,8 @@@ git_pager() 
                GIT_PAGER=cat
        fi
        : ${LESS=-FRSX}
-       export LESS
+       : ${LV=-c}
+       export LESS LV
  
        eval "$GIT_PAGER" '"$@"'
  }
diff --combined pager.c
index 345b0bc4b58ef641a653d6244d2ef7558fc84347,c56a890e2f0b07b1b8518cc74f93417bdca06234..0cc75a8eee32a0195a74c6819a04745f341e45e3
+++ b/pager.c
@@@ -80,8 -80,15 +80,15 @@@ void setup_pager(void
        pager_process.use_shell = 1;
        pager_process.argv = pager_argv;
        pager_process.in = -1;
-       if (!getenv("LESS")) {
-               static const char *env[] = { "LESS=FRSX", NULL };
+       if (!getenv("LESS") || !getenv("LV")) {
+               static const char *env[3];
+               int i = 0;
+               if (!getenv("LESS"))
+                       env[i++] = "LESS=FRSX";
+               if (!getenv("LV"))
+                       env[i++] = "LV=-c";
+               env[i] = NULL;
                pager_process.env = env;
        }
        if (start_command(&pager_process))
@@@ -151,7 -158,7 +158,7 @@@ int decimal_width(int number
  static int pager_command_config(const char *var, const char *value, void *data)
  {
        struct pager_config *c = data;
 -      if (!prefixcmp(var, "pager.") && !strcmp(var + 6, c->cmd)) {
 +      if (starts_with(var, "pager.") && !strcmp(var + 6, c->cmd)) {
                int b = git_config_maybe_bool(var, value);
                if (b >= 0)
                        c->want = b;