Merge branch 'jn/maint-fix-pager'
authorJunio C Hamano <gitster@pobox.com>
Tue, 2 Mar 2010 20:44:11 +0000 (12:44 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 2 Mar 2010 20:44:11 +0000 (12:44 -0800)
* jn/maint-fix-pager:
tests: Fix race condition in t7006-pager
t7006-pager: if stdout is not a terminal, make a new one
tests: Add tests for automatic use of pager
am: Fix launching of pager
git svn: Fix launching of pager
git.1: Clarify the behavior of the --paginate option
Make 'git var GIT_PAGER' always print the configured pager
Fix 'git var' usage synopsis

1  2 
Documentation/git.txt
git-am.sh
git-sh-setup.sh
git-svn.perl
diff --combined Documentation/git.txt
index cc32ce18d213ab5e986df90b0b23a7eb79226c39,f26641a5f4157907fd2e14b97d4a1050116e3e9a..98b6e169827e91ced62af86694dba556819ac3a4
@@@ -43,10 -43,9 +43,10 @@@ unreleased) version of git, that is ava
  branch of the `git.git` repository.
  Documentation for older releases are available here:
  
 -* link:v1.7.0/git.html[documentation for release 1.7.0]
 +* link:v1.7.0.1/git.html[documentation for release 1.7.0.1]
  
  * release notes for
 +  link:RelNotes-1.7.0.1.txt[1.7.0.1],
    link:RelNotes-1.7.0.txt[1.7.0].
  
  * link:v1.6.6.2/git.html[documentation for release 1.6.6.2]
@@@ -230,7 -229,10 +230,10 @@@ help ...`
  
  -p::
  --paginate::
-       Pipe all output into 'less' (or if set, $PAGER).
+       Pipe all output into 'less' (or if set, $PAGER) if standard
+       output is a terminal.  This overrides the `pager.<cmd>`
+       configuration options (see the "Configuration Mechanism" section
+       below).
  
  --no-pager::
        Do not pipe git output into a pager.
@@@ -402,7 -404,8 +405,8 @@@ people.  Here is an example
  ------------
  
  Various commands read from the configuration file and adjust
- their operation accordingly.
+ their operation accordingly.  See linkgit:git-config[1] for a
+ list.
  
  
  Identifier Terminology
diff --combined git-am.sh
index ebfbee59d3dda5ba8a11e35f697e8e48d2565698,b11af03e0b47f248304adfe4317949da92196388..9df951a597d6b9ec5f7f390c35a60adb942a3fdc
+++ b/git-am.sh
@@@ -663,10 -663,7 +663,7 @@@ d
                [eE]*) git_editor "$dotest/final-commit"
                       action=again ;;
                [vV]*) action=again
-                      : ${GIT_PAGER=$(git var GIT_PAGER)}
-                      : ${LESS=-FRSX}
-                      export LESS
-                      $GIT_PAGER "$dotest/patch" ;;
+                      git_pager "$dotest/patch" ;;
                *)     action=again ;;
                esac
            done
        go_next
  done
  
 -git gc --auto
 -
  rm -fr "$dotest"
 +git gc --auto
diff --combined git-sh-setup.sh
index 5e22440aecc4aa57455ce836624f5fe17b6d1f73,44fb4670aed97fb4eebc2c8985dff9c363732507..7a095665d71f153a970243a9d03d919ddef29c88
mode 100644,100755..100644
@@@ -107,6 -107,19 +107,19 @@@ git_editor() 
        eval "$GIT_EDITOR" '"$@"'
  }
  
+ git_pager() {
+       if test -t 1
+       then
+               GIT_PAGER=$(git var GIT_PAGER)
+       else
+               GIT_PAGER=cat
+       fi
+       : ${LESS=-FRSX}
+       export LESS
+       eval "$GIT_PAGER" '"$@"'
+ }
  sane_grep () {
        GREP_OPTIONS= LC_ALL=C grep "$@"
  }
@@@ -128,7 -141,7 +141,7 @@@ cd_to_toplevel () 
  }
  
  require_work_tree () {
 -      test $(git rev-parse --is-inside-work-tree) = true ||
 +      test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = true ||
        die "fatal: $0 cannot be used without a working tree."
  }
  
diff --combined git-svn.perl
index 49dd649bc562ac1b8e5da708ba91572b5e0f0c11,473a0b9d556fc7ead7088c4cb6c6f14c4a70995b..b7c03b641cc3d38a0e619b4843d6309413eb4903
@@@ -36,13 -36,11 +36,13 @@@ $ENV{TZ} = 'UTC'
  $| = 1; # unbuffer STDOUT
  
  sub fatal (@) { print STDERR "@_\n"; exit 1 }
 -require SVN::Core; # use()-ing this causes segfaults for me... *shrug*
 -require SVN::Ra;
 -require SVN::Delta;
 -if ($SVN::Core::VERSION lt '1.1.0') {
 -      fatal "Need SVN::Core 1.1.0 or better (got $SVN::Core::VERSION)";
 +sub _req_svn {
 +      require SVN::Core; # use()-ing this causes segfaults for me... *shrug*
 +      require SVN::Ra;
 +      require SVN::Delta;
 +      if ($SVN::Core::VERSION lt '1.1.0') {
 +              fatal "Need SVN::Core 1.1.0 or better (got $SVN::Core::VERSION)";
 +      }
  }
  my $can_compress = eval { require Compress::Zlib; 1};
  push @Git::SVN::Ra::ISA, 'SVN::Ra';
@@@ -732,8 -730,6 +732,8 @@@ sub cmd_branch 
                $src=~s/^http:/https:/;
        }
  
 +      ::_req_svn();
 +
        my $ctx = SVN::Client->new(
                auth    => Git::SVN::Ra::_auth_providers(),
                log_msg => sub {
@@@ -3277,7 -3273,7 +3277,7 @@@ sub find_extra_svn_parents 
                                        "$new_parents[$i]..$new_parents[$j]",
                                       );
                                if ( !$revs ) {
 -                                      undef($new_parents[$i]);
 +                                      undef($new_parents[$j]);
                                }
                        }
                }
@@@ -4863,8 -4859,6 +4863,8 @@@ sub new 
        $url =~ s!/+$!!;
        return $RA if ($RA && $RA->{url} eq $url);
  
 +      ::_req_svn();
 +
        SVN::_Core::svn_config_ensure($config_dir, undef);
        my ($baton, $callbacks) = SVN::Core::auth_open_helper(_auth_providers);
        my $config = SVN::Core::config_get_config($config_dir);
@@@ -5465,7 -5459,12 +5465,12 @@@ sub git_svn_log_cmd 
  
  # adapted from pager.c
  sub config_pager {
-       chomp(my $pager = command_oneline(qw(var GIT_PAGER)));
+       if (! -t *STDOUT) {
+               $ENV{GIT_PAGER_IN_USE} = 'false';
+               $pager = undef;
+               return;
+       }
+       chomp($pager = command_oneline(qw(var GIT_PAGER)));
        if ($pager eq 'cat') {
                $pager = undef;
        }
  }
  
  sub run_pager {
-       return unless -t *STDOUT && defined $pager;
+       return unless defined $pager;
        pipe my ($rfd, $wfd) or return;
        defined(my $pid = fork) or ::fatal "Can't fork: $!";
        if (!$pid) {