Merge branch 'jk/pager-per-command'
authorJunio C Hamano <gitster@pobox.com>
Wed, 8 Dec 2010 19:24:14 +0000 (11:24 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 8 Dec 2010 19:24:14 +0000 (11:24 -0800)
* jk/pager-per-command:
allow command-specific pagers in pager.<cmd>

1  2 
Documentation/config.txt
t/t7006-pager.sh
diff --combined Documentation/config.txt
index ad5eb5f21d8cf3ea011f01a3b4bc8289877a1c89,0f631712b12ccf1bd95f8d7b04405335705c7d27..0f8579331ed6b9324823f01c3a3cdf32c1e9e674
@@@ -374,15 -374,6 +374,15 @@@ core.warnAmbiguousRefs:
        If true, git will warn you if the ref name you passed it is ambiguous
        and might match multiple refs in the .git/refs/ tree. True by default.
  
 +core.abbrevguard::
 +      Even though git makes sure that it uses enough hexdigits to show
 +      an abbreviated object name unambiguously, as more objects are
 +      added to the repository over time, a short name that used to be
 +      unique will stop being unique.  Git uses this many extra hexdigits
 +      that are more than necessary to make the object name currently
 +      unique, in the hope that its output will stay unique a bit longer.
 +      Defaults to 0.
 +
  core.compression::
        An integer -1..9, indicating a default compression level.
        -1 is the zlib default. 0 means no compression,
@@@ -468,12 -459,6 +468,12 @@@ core.askpass:
        prompt. The external program shall be given a suitable prompt as
        command line argument and write the password on its STDOUT.
  
 +core.attributesfile::
 +      In addition to '.gitattributes' (per-directory) and
 +      '.git/info/attributes', git looks into this file for attributes
 +      (see linkgit:gitattributes[5]). Path expansions are made the same
 +      way as for `core.excludesfile`.
 +
  core.editor::
        Commands such as `commit` and `tag` that lets you edit
        messages by launching an editor uses the value of this
@@@ -563,13 -548,9 +563,13 @@@ core.sparseCheckout:
        linkgit:git-read-tree[1] for more information.
  
  add.ignore-errors::
 +add.ignoreErrors::
        Tells 'git add' to continue adding files when some files cannot be
        added due to indexing errors. Equivalent to the '--ignore-errors'
 -      option of linkgit:git-add[1].
 +      option of linkgit:git-add[1].  Older versions of git accept only
 +      `add.ignore-errors`, which does not follow the usual naming
 +      convention for configuration variables.  Newer versions of git
 +      honor `add.ignoreErrors` as well.
  
  alias.*::
        Command aliases for the linkgit:git[1] command wrapper - e.g.
@@@ -614,9 -595,8 +614,9 @@@ branch.autosetupmerge:
        this behavior can be chosen per-branch using the `--track`
        and `--no-track` options. The valid settings are: `false` -- no
        automatic setup is done; `true` -- automatic setup is done when the
 -      starting point is a remote branch; `always` -- automatic setup is
 -      done when the starting point is either a local branch or remote
 +      starting point is a remote-tracking branch; `always` --
 +      automatic setup is done when the starting point is either a
 +      local branch or remote-tracking
        branch. This option defaults to true.
  
  branch.autosetuprebase::
        When `local`, rebase is set to true for tracked branches of
        other local branches.
        When `remote`, rebase is set to true for tracked branches of
 -      remote branches.
 +      remote-tracking branches.
        When `always`, rebase will be set to true for all tracking
        branches.
        See "branch.autosetupmerge" for details on how to set up a
@@@ -694,7 -674,7 +694,7 @@@ color.branch:
  color.branch.<slot>::
        Use customized color for branch coloration. `<slot>` is one of
        `current` (the current branch), `local` (a local branch),
 -      `remote` (a tracking branch in refs/remotes/), `plain` (other
 +      `remote` (a remote-tracking branch in refs/remotes/), `plain` (other
        refs).
  +
  The value for these configuration variables is a list of colors (at most
@@@ -722,7 -702,7 +722,7 @@@ color.diff.<slot>:
  color.decorate.<slot>::
        Use customized color for 'git log --decorate' output.  `<slot>` is one
        of `branch`, `remoteBranch`, `tag`, `stash` or `HEAD` for local
 -      branches, remote tracking branches, tags, stash and HEAD, respectively.
 +      branches, remote-tracking branches, tags, stash and HEAD, respectively.
  
  color.grep::
        When set to `always`, always highlight matches.  When `false` (or
@@@ -1116,7 -1096,7 +1116,7 @@@ gui.newbranchtemplate:
        linkgit:git-gui[1].
  
  gui.pruneduringfetch::
 -      "true" if linkgit:git-gui[1] should prune tracking branches when
 +      "true" if linkgit:git-gui[1] should prune remote-tracking branches when
        performing a fetch. The default value is "false".
  
  gui.trustmtime::
@@@ -1486,10 -1466,6 +1486,10 @@@ pack.compression:
        not set,  defaults to -1, the zlib default, which is "a default
        compromise between speed and compression (currently equivalent
        to level 6)."
 ++
 +Note that changing the compression level will not automatically recompress
 +all existing objects. You can force recompression by passing the -F option
 +to linkgit:git-repack[1].
  
  pack.deltaCacheSize::
        The maximum memory in bytes used for caching deltas in
@@@ -1545,11 -1521,13 +1545,13 @@@ pack.packSizeLimit:
        supported.
  
  pager.<cmd>::
-       Allows turning on or off pagination of the output of a
-       particular git subcommand when writing to a tty.  If
-       `\--paginate` or `\--no-pager` is specified on the command line,
-       it takes precedence over this option.  To disable pagination for
-       all commands, set `core.pager` or `GIT_PAGER` to `cat`.
+       If the value is boolean, turns on or off pagination of the
+       output of a particular git subcommand when writing to a tty.
+       Otherwise, turns on pagination for the subcommand using the
+       pager specified by the value of `pager.<cmd>`.  If `\--paginate`
+       or `\--no-pager` is specified on the command line, it takes
+       precedence over this option.  To disable pagination for all
+       commands, set `core.pager` or `GIT_PAGER` to `cat`.
  
  pretty.<name>::
        Alias for a --pretty= format string, as specified in
@@@ -1751,7 -1729,6 +1753,7 @@@ sendemail.to:
  sendemail.smtpdomain::
  sendemail.smtpserver::
  sendemail.smtpserverport::
 +sendemail.smtpserveroption::
  sendemail.smtpuser::
  sendemail.thread::
  sendemail.validate::
diff --combined t/t7006-pager.sh
index e9d8b9110d3bb14a0c1d5b325b875abce57b3318,49a62616936e176cb89c20497c6b0c15b969e0a6..ed7575d0fdf9eebf65d808fa810ab4cc03095025
@@@ -4,15 -4,44 +4,15 @@@ test_description='Test automatic use o
  
  . ./test-lib.sh
  . "$TEST_DIRECTORY"/lib-pager.sh
 +. "$TEST_DIRECTORY"/lib-terminal.sh
  
  cleanup_fail() {
        echo >&2 cleanup failed
        (exit 1)
  }
  
 -test_expect_success 'set up terminal for tests' '
 -      rm -f stdout_is_tty ||
 -      cleanup_fail &&
 -
 -      if test -t 1
 -      then
 -              >stdout_is_tty
 -      elif
 -              test_have_prereq PERL &&
 -              "$PERL_PATH" "$TEST_DIRECTORY"/t7006/test-terminal.perl \
 -                      sh -c "test -t 1"
 -      then
 -              >test_terminal_works
 -      fi
 -'
 -
 -if test -e stdout_is_tty
 -then
 -      test_terminal() { "$@"; }
 -      test_set_prereq TTY
 -elif test -e test_terminal_works
 -then
 -      test_terminal() {
 -              "$PERL_PATH" "$TEST_DIRECTORY"/t7006/test-terminal.perl "$@"
 -      }
 -      test_set_prereq TTY
 -else
 -      say "# no usable terminal, so skipping some tests"
 -fi
 -
  test_expect_success 'setup' '
 -      unset GIT_PAGER GIT_PAGER_IN_USE;
 +      sane_unset GIT_PAGER GIT_PAGER_IN_USE &&
        test_might_fail git config --unset core.pager &&
  
        PAGER="cat >paginated.out" &&
@@@ -184,6 -213,11 +184,6 @@@ test_expect_success 'color when writin
        colorful colorful.log
  '
  
 -if test_have_prereq SIMPLEPAGER && test_have_prereq TTY
 -then
 -      test_set_prereq SIMPLEPAGERTTY
 -fi
 -
  # Use this helper to make it easy for the caller of your
  # terminal-using function to specify whether it should fail.
  # If you write
@@@ -219,8 -253,8 +219,8 @@@ parse_args() 
  test_default_pager() {
        parse_args "$@"
  
 -      $test_expectation SIMPLEPAGERTTY "$cmd - default pager is used by default" "
 -              unset PAGER GIT_PAGER;
 +      $test_expectation SIMPLEPAGER,TTY "$cmd - default pager is used by default" "
 +              sane_unset PAGER GIT_PAGER &&
                test_might_fail git config --unset core.pager &&
                rm -f default_pager_used ||
                cleanup_fail &&
@@@ -243,7 -277,7 +243,7 @@@ test_PAGER_overrides() 
        parse_args "$@"
  
        $test_expectation TTY "$cmd - PAGER overrides default pager" "
 -              unset GIT_PAGER;
 +              sane_unset GIT_PAGER &&
                test_might_fail git config --unset core.pager &&
                rm -f PAGER_used ||
                cleanup_fail &&
@@@ -271,7 -305,7 +271,7 @@@ test_core_pager() 
        parse_args "$@"
  
        $test_expectation TTY "$cmd - repository-local core.pager setting $used_if_wanted" "
 -              unset GIT_PAGER;
 +              sane_unset GIT_PAGER &&
                rm -f core.pager_used ||
                cleanup_fail &&
  
@@@ -299,7 -333,7 +299,7 @@@ test_pager_subdir_helper() 
        parse_args "$@"
  
        $test_expectation TTY "$cmd - core.pager $used_if_wanted from subdirectory" "
 -              unset GIT_PAGER;
 +              sane_unset GIT_PAGER &&
                rm -f core.pager_used &&
                rm -fr sub ||
                cleanup_fail &&
@@@ -401,4 -435,33 +401,33 @@@ test_core_pager_subdir    expect_succes
  test_core_pager_subdir    expect_success test_must_fail \
                                         'git -p apply </dev/null'
  
+ test_expect_success TTY 'command-specific pager' '
+       unset PAGER GIT_PAGER;
+       echo "foo:initial" >expect &&
+       >actual &&
+       git config --unset core.pager &&
+       git config pager.log "sed s/^/foo:/ >actual" &&
+       test_terminal git log --format=%s -1 &&
+       test_cmp expect actual
+ '
+ test_expect_success TTY 'command-specific pager overrides core.pager' '
+       unset PAGER GIT_PAGER;
+       echo "foo:initial" >expect &&
+       >actual &&
+       git config core.pager "exit 1"
+       git config pager.log "sed s/^/foo:/ >actual" &&
+       test_terminal git log --format=%s -1 &&
+       test_cmp expect actual
+ '
+ test_expect_success TTY 'command-specific pager overridden by environment' '
+       GIT_PAGER="sed s/^/foo:/ >actual" && export GIT_PAGER &&
+       >actual &&
+       echo "foo:initial" >expect &&
+       git config pager.log "exit 1" &&
+       test_terminal git log --format=%s -1 &&
+       test_cmp expect actual
+ '
  test_done