Use a pager for diff and show commands
[stgit] / stgit / config.py
index e6c9538..66e9f41 100644 (file)
@@ -20,11 +20,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
 import os, ConfigParser
 
+from stgit import basedir
 
-if 'GIT_DIR' in os.environ:
-    __git_dir = os.environ['GIT_DIR']
-else:
-    __git_dir = '.git'
 
 config = ConfigParser.RawConfigParser()
 
@@ -41,7 +38,11 @@ config.set('stgit', 'keeporig', 'yes')
 # Read the configuration files (if any) and override the default settings
 config.read('/etc/stgitrc')
 config.read(os.path.expanduser('~/.stgitrc'))
-config.read(os.path.join(__git_dir, 'stgitrc'))
+config.read(os.path.join(basedir.get(), 'stgitrc'))
+
+# Set the PAGER environment to the config value (if any)
+if config.has_option('stgit', 'pager'):
+    os.environ['PAGER'] = config.get('stgit', 'pager')
 
 # [gitmergeonefile] section is deprecated. In case it exists copy the
 # options/values to the [stgit] one