Subject: [StGit PATCH 4/4] Read default diff options from the user's config

From: Karl Hasselström <[email-masked]>
Date: Thu, 24 Jan 2008 09:08:21 +0100

Signed-off-by: Karl Hasselström <[email-masked]>

---

 examples/gitconfig |    4 ++++
 stgit/utils.py     |    3 ++-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/examples/gitconfig b/examples/gitconfig
index cd9b569..c16f786 100644
--- a/examples/gitconfig
+++ b/examples/gitconfig
@@ -95,6 +95,10 @@
 	# The maximum length of an automatically generated patch name
 	#namelenth = 30
 
+	# Extra options to pass to "git diff" (extend/override with
+	# -O/--diff-opts). For example, -M turns on rename detection.
+	#diff-opts = -M
+
 [mail "alias"]
 	# E-mail aliases used with the 'mail' command
 	git = [email-masked]
diff --git a/stgit/utils.py b/stgit/utils.py
index 00776b0..69203dc 100644
--- a/stgit/utils.py
+++ b/stgit/utils.py
@@ -320,7 +320,8 @@ def make_diff_opts_option():
         else:
             parser.values.diff_flags = []
     return [optparse.make_option(
-        '-O', '--diff-opts', dest = 'diff_flags', default = [],
+        '-O', '--diff-opts', dest = 'diff_flags',
+        default = (config.get('stgit.diff-opts') or '').split(),
         action = 'callback', callback = diff_opts_callback,
         type = 'string', metavar = 'OPTIONS',
         help = 'extra options to pass to "git diff"')]