This patch enables the use of gitconfig files (~/.gitconfig or
.git/config) rather than stgitrc. These files can have a [stgit]
section. Currently, the git config lines have to be stripped since the
options are prepended with spaces.
Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
-# StGIT configuration file. Copy it to any of /etc/stgitrc, ~/.stgitrc
-# or .git/stgitrc and modify as needed. Note that the latter overrides
-# the former.
+# StGIT configuration file. Copy it to any of ~/.gitconfig or
+# .git/gitconfig and modify as needed. Note that the latter overrides
+# the former. The "git repo-config" command can be used as well
[stgit]
# Default author/committer details
[stgit]
# Default author/committer details
-#authname: Your Name
-#authemail: your.name@yourcompany.com
-#commname: Your Name
-#commemail: your.name@yourcompany.com
+#authname = Your Name
+#authemail = your.name@yourcompany.com
+#commname = Your Name
+#commemail = your.name@yourcompany.com
# E-mail sender (added to the "From: " header)
# E-mail sender (added to the "From: " header)
-#sender: Your Name <your.name@yourcompany.com>
+#sender = Your Name <your.name@yourcompany.com>
# Automatically Bcc the address below
# Automatically Bcc the address below
-#autobcc: your.name@yourcompany.com
+#autobcc = your.name@yourcompany.com
# Set to 'yes' if you don't want to use the 'resolved' command.
# 'refresh' will automatically mark the conflicts as resolved
# Set to 'yes' if you don't want to use the 'resolved' command.
# 'refresh' will automatically mark the conflicts as resolved
-#smtpserver: localhost:25
-#smtpuser: username
-#smtppassword: password
+#smtpserver = localhost:25
+#smtpuser = username
+#smtppassword = password
# delay between messages in seconds (defaults to 5)
# delay between messages in seconds (defaults to 5)
# stg will look for this first, then look for the EDITOR environmental
# variable, then default to using 'vi'
# stg will look for this first, then look for the EDITOR environmental
# variable, then default to using 'vi'
# this value overrides the default PAGER environment variable
# this value overrides the default PAGER environment variable
-#pager: ~/share/stgit/contrib/diffcol.sh
-#pager: filterdiff --annotate | colordiff | less -FRX
+#pager = ~/share/stgit/contrib/diffcol.sh
+#pager = filterdiff --annotate | colordiff | less -FRX
# GIT pull command (should take the same arguments as git-pull)
# GIT pull command (should take the same arguments as git-pull)
# The three-way merge tool. Note that the 'output' file contains the
# same data as 'branch1'. This is useful for tools that do not take an
# output parameter
# The three-way merge tool. Note that the 'output' file contains the
# same data as 'branch1'. This is useful for tools that do not take an
# output parameter
-#merger: diff3 -L current -L ancestor -L patched -m -E \
+#merger = diff3 -L current -L ancestor -L patched -m -E \
# "%(branch1)s" "%(ancestor)s" "%(branch2)s" > "%(output)s"
# Interactive three-way merge tool. It is executed by the 'resolved
# --interactive' command
# "%(branch1)s" "%(ancestor)s" "%(branch2)s" > "%(output)s"
# Interactive three-way merge tool. It is executed by the 'resolved
# --interactive' command
-#imerger: xxdiff --title1 current --title2 ancestor --title3 patched \
+#imerger = xxdiff --title1 current --title2 ancestor --title3 patched \
# --show-merged-pane -m -E -O -X -M "%(output)s" \
# "%(branch1)s" "%(ancestor)s" "%(branch2)s"
# --show-merged-pane -m -E -O -X -M "%(output)s" \
# "%(branch1)s" "%(ancestor)s" "%(branch2)s"
-#imerger: emacs --eval '(ediff-merge-files-with-ancestor
+#imerger = emacs --eval '(ediff-merge-files-with-ancestor \
# "%(branch1)s" "%(branch2)s" "%(ancestor)s" nil "%(output)s")'
# Leave the original files in the working tree in case of a merge conflict
# "%(branch1)s" "%(branch2)s" "%(ancestor)s" nil "%(output)s")'
# Leave the original files in the working tree in case of a merge conflict
# Optimize (repack) the object store after every pull
# Optimize (repack) the object store after every pull
# Extensions for the files involved in a three-way merge (ancestor,
# current, patched)
# Extensions for the files involved in a three-way merge (ancestor,
# current, patched)
-#extensions: .ancestor .current .patched
+#extensions = .ancestor .current .patched
packages = ['stgit', 'stgit.commands'],
data_files = [('share/stgit/templates', glob.glob('templates/*.tmpl')),
('share/stgit/examples', glob.glob('examples/*.tmpl')),
packages = ['stgit', 'stgit.commands'],
data_files = [('share/stgit/templates', glob.glob('templates/*.tmpl')),
('share/stgit/examples', glob.glob('examples/*.tmpl')),
- ('share/stgit/examples', ['examples/stgitrc']),
+ ('share/stgit/examples', ['examples/gitconfig']),
('share/stgit/contrib', ['contrib/diffcol.sh',
'contrib/stgbashprompt.sh',
'contrib/stgit-completion.bash']),
('share/stgit/contrib', ['contrib/diffcol.sh',
'contrib/stgbashprompt.sh',
'contrib/stgit-completion.bash']),
"""
import os, ConfigParser
"""
import os, ConfigParser
+from StringIO import StringIO
from stgit import basedir
from stgit import basedir
config = ConfigParser.RawConfigParser()
config = ConfigParser.RawConfigParser()
+def git_config(filename):
+ """Open a git config file and convert it to be understood by
+ Python."""
+ try:
+ f = file(filename)
+ cont = False
+ lines = []
+ for line in f:
+ line = line.strip()
+
+ if cont:
+ # continued line, add a space at the beginning
+ line = ' ' + line
+
+ if line and line[-1] == '\\':
+ line = line[:-1].rstrip()
+ cont = True
+ else:
+ line = line + '\n'
+ cont = False
+
+ lines.append(line)
+
+ f.close()
+ cfg_str = ''.join(lines)
+ except IOError:
+ cfg_str = ''
+
+ strio = StringIO(cfg_str)
+ strio.name = filename
+
+ return strio
+
def config_setup():
global config
def config_setup():
global config
config.set('stgit', 'extensions', '.ancestor .current .patched')
# Read the configuration files (if any) and override the default settings
config.set('stgit', 'extensions', '.ancestor .current .patched')
# Read the configuration files (if any) and override the default settings
+ # stgitrc are read for backward compatibility
config.read('/etc/stgitrc')
config.read(os.path.expanduser('~/.stgitrc'))
config.read(os.path.join(basedir.get(), 'stgitrc'))
config.read('/etc/stgitrc')
config.read(os.path.expanduser('~/.stgitrc'))
config.read(os.path.join(basedir.get(), 'stgitrc'))
+ # GIT configuration files can have a [stgit] section
+ config.readfp(git_config(os.path.expanduser('~/.gitconfig')))
+ config.readfp(git_config(os.path.join(basedir.get(), 'config')))
+
# Set the PAGER environment to the config value (if any)
if config.has_option('stgit', 'pager'):
os.environ['PAGER'] = config.get('stgit', 'pager')
# Set the PAGER environment to the config value (if any)
if config.has_option('stgit', 'pager'):
os.environ['PAGER'] = config.get('stgit', 'pager')