Could I get a config option added to stgit for diff-opts? So that I
can always have git diff -M set on renames.--
Jon Smirl
jonsmirl@gmail.com
-
Good idea. I've often needed this myself, without consciously
realizing it -- my bash is set to save an infinite amount of history,
so Ctrl+R always helps me out ...Will whip up, unless someone beats me to it. It's getting sorta late,
so I won't have time for at least a day or two.--
Karl Hasselström, kha@treskal.com
www.treskal.com/kalle
-
I also think that some config stuff should be done, but I could not
come with a usable design.See eg. http://marc.info/?l=git&m=118102609623481&w=4
Another problem not explicitely mentionned there is that we my want on
the same project to have different settings, eg. for viewing (as
compact as possible), exporting (GNU compatibility), and feeding to
other git commands (with --binary).Best regards,
--
Yann
-
This is first two cleanup patches, followed by one patch that makes
"stg show" handle diff options like the other commands, and last a
patch that reads diff opts from the config file.The first two patches are in kha/safe, but the latter two are in
kha/experimental because -- as Yann pointed out -- it's good to make
sure the design is OK before committing to it.I've solved the problem of overriding the config on the command line
by making --diff-opts='--foo --bar' _add_ options, and special-cased
--diff-opts='' to clear all options, including those from the config
file, since appending no options makes no sense.We'll still have to consider if and how to support different options
for different tools.Oh, and Jon: is this what you wanted, by the way? :-)
---
Karl Hasselström (4):
Read default diff options from the user's config
Let "stg show" use the unified --diff-opts handling
Refactor --diff-opts handling
Remove unused default valuesexamples/gitconfig | 4 ++++
stgit/commands/diff.py | 14 ++++----------
stgit/commands/edit.py | 14 +++-----------
stgit/commands/export.py | 12 +++---------
stgit/commands/files.py | 13 ++++---------
stgit/commands/mail.py | 12 +++---------
stgit/commands/show.py | 13 ++++---------
stgit/commands/status.py | 17 +++++------------
stgit/utils.py | 13 +++++++++++++
9 files changed, 43 insertions(+), 69 deletions(-)--
Karl Hasselström, kha@treskal.com
www.treskal.com/kalle
-
--
Jon Smirl
jonsmirl@gmail.com
-
Mph. I just realized that none of the patches add any documentation
that explains this.--
Karl Hasselström, kha@treskal.com
www.treskal.com/kalle
-
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
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 = git@vger.kernel.org
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"')]-
This introduces a small UI change: "stg show" called that flag
--show-opts. This could of course be avoided, but I don't think it's
worth it, since git-diff and git-show accept mostly the same options.Signed-off-by: Karl Hasselström <kha@treskal.com>
---
Catalin, do you agree?
stgit/commands/show.py | 13 ++++---------
1 files changed, 4 insertions(+), 9 deletions(-)diff --git a/stgit/commands/show.py b/stgit/commands/show.py
index 72d1be3..b77a9c8 100644
--- a/stgit/commands/show.py
+++ b/stgit/commands/show.py
@@ -38,9 +38,8 @@ options = [make_option('-b', '--branch',
action = 'store_true'),
make_option('-u', '--unapplied',
help = 'show the unapplied patches',
- action = 'store_true'),
- make_option('-O', '--show-opts',
- help = 'options to pass to "git show"')]
+ action = 'store_true')
+ ] + make_diff_opts_option()def func(parser, options, args):
@@ -62,13 +61,9 @@ def func(parser, options, args):
patches = parse_patches(args, applied + unapplied + \
crt_series.get_hidden(), len(applied))- if options.show_opts:
- show_flags = options.show_opts.split()
- else:
- show_flags = []
-
commit_ids = [git_id(crt_series, patch) for patch in patches]
- commit_str = '\n'.join([git.pretty_commit(commit_id, flags = show_flags)
+ commit_str = '\n'.join([git.pretty_commit(commit_id,
+ flags = options.diff_flags)
for commit_id in commit_ids])
if commit_str:
pager(commit_str)-
Lots of commands take a -O/--diff-opts flag, and they all handle it
identically. So break that out into a library function.Signed-off-by: Karl Hasselström <kha@treskal.com>
---
stgit/commands/diff.py | 14 ++++----------
stgit/commands/edit.py | 14 +++-----------
stgit/commands/export.py | 12 +++---------
stgit/commands/files.py | 13 ++++---------
stgit/commands/mail.py | 12 +++---------
stgit/commands/status.py | 12 +++---------
stgit/utils.py | 12 ++++++++++++
7 files changed, 32 insertions(+), 57 deletions(-)diff --git a/stgit/commands/diff.py b/stgit/commands/diff.py
index 1425518..7c213d1 100644
--- a/stgit/commands/diff.py
+++ b/stgit/commands/diff.py
@@ -46,12 +46,10 @@ directory = DirectoryHasRepository()
options = [make_option('-r', '--range',
metavar = 'rev1[..[rev2]]', dest = 'revs',
help = 'show the diff between revisions'),
- make_option('-O', '--diff-opts',
- help = 'options to pass to git-diff'),
make_option('-s', '--stat',
help = 'show the stat instead of the diff',
- action = 'store_true')]
-
+ action = 'store_true')
+ ] + make_diff_opts_option()def func(parser, options, args):
"""Show the tree diff
@@ -83,16 +81,12 @@ def func(parser, options, args):
rev1 = 'HEAD'
rev2 = None- if options.diff_opts:
- diff_flags = options.diff_opts.split()
- else:
- diff_flags = []
-
if options.stat:
out.stdout_raw(git.diffstat(args, git_id(crt_series, rev1),
git_id(crt_series, rev2)) + '\n')
else:
diff_str = git.diff(args, git_id(crt_series, rev1),
- git_id(crt_series, rev2), diff_flags = diff_flags )
+ git_id(crt_series, rev2),
+ diff_flags = option...
This function was called from only one place, and the default values
weren't used there, so they're useless.Signed-off-by: Karl Hasselström <kha@treskal.com>
---
stgit/commands/status.py | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)diff --git a/stgit/commands/status.py b/stgit/commands/status.py
index 708dd16..02a5832 100644
--- a/stgit/commands/status.py
+++ b/stgit/commands/status.py
@@ -66,9 +66,8 @@ options = [make_option('-m', '--modified',
action = 'store_true')]-def status(files = None, modified = False, new = False, deleted = False,
- conflict = False, unknown = False, noexclude = False,
- diff_flags = []):
+def status(files, modified, new, deleted, conflict, unknown, noexclude,
+ diff_flags):
"""Show the tree status
"""
cache_files = git.tree_status(files,-
| Christoph Lameter | Re: [PATCH 0/24] make atomic_read() behave consistently across all architectures |
| Greg Kroah-Hartman | [PATCH 005/196] Chinese: add translation of SubmittingDrivers |
| Pekka Enberg | Re: [bug] mm/slab.c boot crash in -git, "kernel BUG at mm/slab.c:2103!" |
| Glauber de Oliveira Costa | [PATCH 08/79] [PATCH] use identify_boot_cpu |
git: | |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
| Jarek Poplawski | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Natalie Protasevich | [BUG] New Kernel Bugs |
| David Miller | [GIT]: Networking |
