{"thread":{"id":"8381","subject":"[StGIT PATCH 0/4] Rename detection, take 2","startedAt":"2007-05-31T22:34:18Z","lastAt":"2007-06-05T06:47:30Z","messageCount":10,"participants":["Yann Dirson","David Kågedal","Karl Hasselström","Catalin Marinas"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"43699","messageId":"20070531222920.6005.74481.stgit@gandelf.nowhere.earth","threadId":"8381","inReplyTo":null,"subject":"[StGIT PATCH 0/4] Rename detection, take 2","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-05-31T22:34:18Z","receivedAt":"2007-05-31T22:34:18Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"This series brings the ability to pass arbitrary flags to git-diff\nthrough StGIT commands.  Eg:\n\n    stg files -O -C\n    stg diff -O '-C -w --color'\n    stg mail -O --binary\n\nThe latter shows that the recently-added --binary is not needed any\nmore, so I removed it.\n\nWhile doing this, I realized that many git commands were spawned\nthrough shell commands instead of directly exec'ing them, and that was\nannyoing for consistency, so this is part of the same patch.  As a\nbonus, it slightly improves performance.\n\n-- \nYann Dirson    <ydirson@altern.org> |\nDebian-related: <dirson@debian.org> |   Support Debian GNU/Linux:\n                                    |  Freedom, Power, Stability, Gratis\n     http://ydirson.free.fr/        | Check <http://www.debian.org/>\n"},{"id":"43700","messageId":"20070531223423.6005.59088.stgit@gandelf.nowhere.earth","threadId":"8381","inReplyTo":"20070531222920.6005.74481.stgit@gandelf.nowhere.earth","subject":"[PATCH 1/4] Add 2 new contrib scripts.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-05-31T22:34:23Z","receivedAt":"2007-05-31T22:34:23Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\n\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n contrib/stg-k     |   32 ++++++++++++++++++++++++++++++++\n contrib/stg-unnew |   15 +++++++++++++++\n 2 files changed, 47 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/stg-k b/contrib/stg-k\nnew file mode 100755\nindex 0000000..0134c25\n--- /dev/null\n+++ b/contrib/stg-k\n@@ -0,0 +1,32 @@\n+#!/bin/sh\n+set -e\n+\n+# stg-k - execute given StGIT command while preserving local changes\n+\n+# Uses a temporary patch to save local changes, then execute the given\n+# command, and restore local changes from the saved patch.  In\n+# essence, \"stg-k pop\" is a \"stg pop -k\" that works better, hence its\n+# name.\n+\n+# CAVEAT: this script relies on the operation to run ignoring hidden\n+# patches, so in 0.12 (where \"stg push\" can push an hidden patch)\n+# \"stg-k push\" will fail midway, albeit with no information loss -\n+# you'll just have to finish manually.  Luckilly this appears to work\n+# on master branch.\n+\n+# Copyright (c) 2007 Yann Dirson <ydirson@altern.org>\n+# Subject to the GNU GPL, version 2.\n+\n+stg new __local -m \" - local changes (internal patch)\"\n+stg refresh\n+stg pop\n+\n+# avoid bad interactions like \"stg-k push\" not behaving as expected\n+stg hide __local\n+\n+stg \"$@\"\n+\n+stg unhide __local\n+\n+stg push __local\n+stg-unnew\ndiff --git a/contrib/stg-unnew b/contrib/stg-unnew\nnew file mode 100755\nindex 0000000..5ac8781\n--- /dev/null\n+++ b/contrib/stg-unnew\n@@ -0,0 +1,15 @@\n+#!/bin/sh\n+set -e\n+\n+# stg-unnew - sort of \"reverse an 'stg new'\"\n+\n+# Remove the current patch from the stack, keeping its contents as\n+# uncommitted changes.\n+\n+# Copyright (c) 2007 Yann Dirson <ydirson@altern.org>\n+# Subject to the GNU GPL, version 2.\n+\n+patch=$(stg top)\n+stg pop\n+stg pick --fold $patch\n+stg delete $patch\n"},{"id":"43701","messageId":"20070531223428.6005.16339.stgit@gandelf.nowhere.earth","threadId":"8381","inReplyTo":"20070531222920.6005.74481.stgit@gandelf.nowhere.earth","subject":"[PATCH 2/4] Call external commands without a shell where possible.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-05-31T22:34:28Z","receivedAt":"2007-05-31T22:34:28Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\nOn my dev box it consistently improves performance when timing the\nfull testsuite:\n\nbefore:\n\nuser    2m22.509s\nsys     0m50.695s\n\nuser    2m23.565s\nsys     0m49.399s\n\nuser    2m23.497s\nsys     0m49.675s\n\nafter:\n\nuser    2m20.261s\nsys     0m45.687s\n\nuser    2m21.485s\nsys     0m46.427s\n\nuser    2m20.581s\nsys     0m45.367s\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n stgit/git.py |   42 +++++++++++++++++++++---------------------\n 1 files changed, 21 insertions(+), 21 deletions(-)\n\ndiff --git a/stgit/git.py b/stgit/git.py\nindex 845c712..5cdc8cd 100644\n--- a/stgit/git.py\n+++ b/stgit/git.py\n@@ -74,7 +74,7 @@ class Commit:\n     def __init__(self, id_hash):\n         self.__id_hash = id_hash\n \n-        lines = _output_lines('git-cat-file commit %s' % id_hash)\n+        lines = _output_lines(['git-cat-file', 'commit', id_hash])\n         for i in range(len(lines)):\n             line = lines[i]\n             if line == '\\n':\n@@ -102,8 +102,8 @@ class Commit:\n             return None\n \n     def get_parents(self):\n-        return _output_lines('git-rev-list --parents --max-count=1 %s'\n-                             % self.__id_hash)[0].split()[1:]\n+        return _output_lines(['git-rev-list', '--parents', '--max-count=1',\n+                              self.__id_hash])[0].split()[1:]\n \n     def get_author(self):\n         return self.__author\n@@ -285,7 +285,7 @@ def get_head_file():\n     \"\"\"Returns the name of the file pointed to by the HEAD link\n     \"\"\"\n     return strip_prefix('refs/heads/',\n-                        _output_one_line('git-symbolic-ref HEAD'))\n+                        _output_one_line(['git-symbolic-ref', 'HEAD']))\n \n def set_head_file(ref):\n     \"\"\"Resets HEAD to point to a new ref\n@@ -617,27 +617,27 @@ def commit(message, files = None, parents = None, allowempty = False,\n     must_switch = True\n     # write the index to repository\n     if tree_id == None:\n-        tree_id = _output_one_line('git-write-tree')\n+        tree_id = _output_one_line(['git-write-tree'])\n     else:\n         must_switch = False\n \n     # the commit\n-    cmd = ''\n+    cmd = ['env']\n     if author_name:\n-        cmd += 'GIT_AUTHOR_NAME=\"%s\" ' % author_name\n+        cmd += ['GIT_AUTHOR_NAME=%s' % author_name]\n     if author_email:\n-        cmd += 'GIT_AUTHOR_EMAIL=\"%s\" ' % author_email\n+        cmd += ['GIT_AUTHOR_EMAIL=%s' % author_email]\n     if author_date:\n-        cmd += 'GIT_AUTHOR_DATE=\"%s\" ' % author_date\n+        cmd += ['GIT_AUTHOR_DATE=%s' % author_date]\n     if committer_name:\n-        cmd += 'GIT_COMMITTER_NAME=\"%s\" ' % committer_name\n+        cmd += ['GIT_COMMITTER_NAME=%s' % committer_name]\n     if committer_email:\n-        cmd += 'GIT_COMMITTER_EMAIL=\"%s\" ' % committer_email\n-    cmd += 'git-commit-tree %s' % tree_id\n+        cmd += ['GIT_COMMITTER_EMAIL=%s' % committer_email]\n+    cmd += ['git-commit-tree', tree_id]\n \n     # get the parents\n     for p in parents:\n-        cmd += ' -p %s' % p\n+        cmd += ['-p', p]\n \n     commit_id = _output_one_line(cmd, message)\n     if must_switch:\n@@ -652,9 +652,9 @@ def apply_diff(rev1, rev2, check_index = True, files = None):\n     the pushing would fall back to the three-way merge.\n     \"\"\"\n     if check_index:\n-        index_opt = '--index'\n+        index_opt = ['--index']\n     else:\n-        index_opt = ''\n+        index_opt = []\n \n     if not files:\n         files = []\n@@ -662,7 +662,7 @@ def apply_diff(rev1, rev2, check_index = True, files = None):\n     diff_str = diff(files, rev1, rev2)\n     if diff_str:\n         try:\n-            _input_str('git-apply %s' % index_opt, diff_str)\n+            _input_str(['git-apply'] + index_opt, diff_str)\n         except GitException:\n             return False\n \n@@ -680,7 +680,7 @@ def merge(base, head1, head2, recursive = False):\n         # general when pushing or picking patches)\n         try:\n             # use _output() to mask the verbose prints of the tool\n-            _output('git-merge-recursive %s -- %s %s' % (base, head1, head2))\n+            _output(['git-merge-recursive', base, '--', head1, head2])\n         except GitException, ex:\n             err_output = str(ex)\n             pass\n@@ -696,7 +696,7 @@ def merge(base, head1, head2, recursive = False):\n     files = {}\n     stages_re = re.compile('^([0-7]+) ([0-9a-f]{40}) ([1-3])\\t(.*)$', re.S)\n \n-    for line in _output('git-ls-files --unmerged --stage -z').split('\\0'):\n+    for line in _output(['git-ls-files', '--unmerged', '--stage', '-z']).split('\\0'):\n         if not line:\n             continue\n \n@@ -818,7 +818,7 @@ def files(rev1, rev2):\n     \"\"\"\n \n     result = ''\n-    for line in _output_lines('git-diff-tree -r %s %s' % (rev1, rev2)):\n+    for line in _output_lines(['git-diff-tree', '-r', rev1, rev2]):\n         result += '%s %s\\n' % tuple(line.rstrip().split(' ',4)[-1].split('\\t',1))\n \n     return result.rstrip()\n@@ -828,7 +828,7 @@ def barefiles(rev1, rev2):\n     \"\"\"\n \n     result = ''\n-    for line in _output_lines('git-diff-tree -r %s %s' % (rev1, rev2)):\n+    for line in _output_lines(['git-diff-tree', '-r', rev1, rev2]):\n         result += '%s\\n' % line.rstrip().split(' ',4)[-1].split('\\t',1)[-1]\n \n     return result.rstrip()\n@@ -947,7 +947,7 @@ def apply_patch(filename = None, diff = None, base = None,\n         refresh_index()\n \n     try:\n-        _input_str('git-apply --index', diff)\n+        _input_str(['git-apply', '--index'], diff)\n     except GitException:\n         if base:\n             switch(orig_head)\n"},{"id":"43702","messageId":"20070531223433.6005.27608.stgit@gandelf.nowhere.earth","threadId":"8381","inReplyTo":"20070531222920.6005.74481.stgit@gandelf.nowhere.earth","subject":"[PATCH 3/4] Make diff flags handling more modular.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-05-31T22:34:33Z","receivedAt":"2007-05-31T22:34:33Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\n\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n stgit/commands/diff.py   |    7 ++++++-\n stgit/commands/export.py |    8 +++++++-\n stgit/commands/mail.py   |    7 ++++++-\n stgit/git.py             |   12 ++++--------\n 4 files changed, 23 insertions(+), 11 deletions(-)\n\ndiff --git a/stgit/commands/diff.py b/stgit/commands/diff.py\nindex f56cbeb..b66c75b 100644\n--- a/stgit/commands/diff.py\n+++ b/stgit/commands/diff.py\n@@ -79,10 +79,15 @@ def func(parser, options, args):\n         rev1 = 'HEAD'\n         rev2 = None\n \n+    if options.binary:\n+        diff_flags = [ '--binary' ]\n+    else:\n+        diff_flags = []\n+\n     if options.stat:\n         out.stdout_raw(git.diffstat(args, git_id(rev1), git_id(rev2)) + '\\n')\n     else:\n         diff_str = git.diff(args, git_id(rev1), git_id(rev2),\n-                            binary = options.binary)\n+                            diff_flags = diff_flags )\n         if diff_str:\n             pager(diff_str)\ndiff --git a/stgit/commands/export.py b/stgit/commands/export.py\nindex cafcbe3..d6b36a9 100644\n--- a/stgit/commands/export.py\n+++ b/stgit/commands/export.py\n@@ -87,6 +87,11 @@ def func(parser, options, args):\n             os.makedirs(dirname)\n         series = file(os.path.join(dirname, 'series'), 'w+')\n \n+    if options.binary:\n+        diff_flags = [ '--binary' ]\n+    else:\n+        diff_flags = []\n+\n     applied = crt_series.get_applied()\n     if len(args) != 0:\n         patches = parse_patches(args, applied)\n@@ -175,7 +180,8 @@ def func(parser, options, args):\n         # write the diff\n         git.diff(rev1 = patch.get_bottom(),\n                  rev2 = patch.get_top(),\n-                 out_fd = f, binary = options.binary)\n+                 out_fd = f,\n+                 diff_flags = diff_flags )\n         if not options.stdout:\n             f.close()\n         patch_no += 1\ndiff --git a/stgit/commands/mail.py b/stgit/commands/mail.py\nindex b95014c..7113cff 100644\n--- a/stgit/commands/mail.py\n+++ b/stgit/commands/mail.py\n@@ -377,6 +377,11 @@ def __build_message(tmpl, patch, patch_nr, total_nr, msg_id, ref_id, options):\n     else:\n         prefix_str = ''\n         \n+    if options.binary:\n+        diff_flags = [ '--binary' ]\n+    else:\n+        diff_flags = []\n+\n     total_nr_str = str(total_nr)\n     patch_nr_str = str(patch_nr).zfill(len(total_nr_str))\n     if total_nr > 1:\n@@ -394,7 +399,7 @@ def __build_message(tmpl, patch, patch_nr, total_nr, msg_id, ref_id, options):\n                  'endofheaders': '',\n                  'diff':         git.diff(rev1 = git_id('%s//bottom' % patch),\n                                           rev2 = git_id('%s//top' % patch),\n-                                          binary = options.binary),\n+                                          diff_flags = diff_flags ),\n                  'diffstat':     git.diffstat(rev1 = git_id('%s//bottom'%patch),\n                                               rev2 = git_id('%s//top' % patch)),\n                  # for backward template compatibility\ndiff --git a/stgit/git.py b/stgit/git.py\nindex 5cdc8cd..7358fae 100644\n--- a/stgit/git.py\n+++ b/stgit/git.py\n@@ -770,27 +770,23 @@ def status(files = None, modified = False, new = False, deleted = False,\n             out.stdout('%s' % fs[1])\n \n def diff(files = None, rev1 = 'HEAD', rev2 = None, out_fd = None,\n-         binary = False):\n+         diff_flags = []):\n     \"\"\"Show the diff between rev1 and rev2\n     \"\"\"\n     if not files:\n         files = []\n \n-    args = []\n-    if binary:\n-        args.append('--binary')\n-\n     if rev1 and rev2:\n-        diff_str = _output(['git-diff-tree', '-p'] + args\n+        diff_str = _output(['git-diff-tree', '-p'] + diff_flags\n                            + [rev1, rev2, '--'] + files)\n     elif rev1 or rev2:\n         refresh_index()\n         if rev2:\n             diff_str = _output(['git-diff-index', '-p', '-R']\n-                               + args + [rev2, '--'] + files)\n+                               + diff_flags + [rev2, '--'] + files)\n         else:\n             diff_str = _output(['git-diff-index', '-p']\n-                               + args + [rev1, '--'] + files)\n+                               + diff_flags + [rev1, '--'] + files)\n     else:\n         diff_str = ''\n \n"},{"id":"43703","messageId":"20070531223438.6005.76115.stgit@gandelf.nowhere.earth","threadId":"8381","inReplyTo":"20070531222920.6005.74481.stgit@gandelf.nowhere.earth","subject":"[PATCH 4/4] Add new --diff-opts/-O flag to diff- and status-related commands.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-05-31T22:34:38Z","receivedAt":"2007-05-31T22:34:38Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\nThis new flag allows to pass arbitrary flags to the git-diff calls\nunderlying several StGIT commands.  It can be used to pass flags\naffecting both diff- and status-generating commands (eg. -M or -C), or\nflags only affecting diff-generating ones (eg. --color, --binary).\n\nIt supercedes --binary for commands where it was allowed,\n'-O --binary' is now available for the same functionality.\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n stgit/commands/diff.py   |    9 ++++-----\n stgit/commands/export.py |    9 ++++-----\n stgit/commands/files.py  |    9 ++++++++-\n stgit/commands/mail.py   |    9 ++++-----\n stgit/commands/show.py   |   11 +++++++++--\n stgit/commands/status.py |   10 +++++++++-\n stgit/git.py             |   21 ++++++++++++---------\n 7 files changed, 50 insertions(+), 28 deletions(-)\n\ndiff --git a/stgit/commands/diff.py b/stgit/commands/diff.py\nindex b66c75b..f8b19f8 100644\n--- a/stgit/commands/diff.py\n+++ b/stgit/commands/diff.py\n@@ -44,9 +44,8 @@ shows the specified patch (defaulting to the current one).\"\"\"\n options = [make_option('-r', '--range',\n                        metavar = 'rev1[..[rev2]]', dest = 'revs',\n                        help = 'show the diff between revisions'),\n-           make_option('--binary',\n-                       help = 'output a diff even for binary files',\n-                       action = 'store_true'),\n+           make_option('-O', '--diff-opts',\n+                       help = 'options to pass to git-diff'),\n            make_option('-s', '--stat',\n                        help = 'show the stat instead of the diff',\n                        action = 'store_true')]\n@@ -79,8 +78,8 @@ def func(parser, options, args):\n         rev1 = 'HEAD'\n         rev2 = None\n \n-    if options.binary:\n-        diff_flags = [ '--binary' ]\n+    if options.diff_opts:\n+        diff_flags = options.diff_opts.split()\n     else:\n         diff_flags = []\n \ndiff --git a/stgit/commands/export.py b/stgit/commands/export.py\nindex d6b36a9..35851bc 100644\n--- a/stgit/commands/export.py\n+++ b/stgit/commands/export.py\n@@ -62,9 +62,8 @@ options = [make_option('-d', '--dir',\n                        help = 'Use FILE as a template'),\n            make_option('-b', '--branch',\n                        help = 'use BRANCH instead of the default one'),\n-           make_option('--binary',\n-                       help = 'output a diff even for binary files',\n-                       action = 'store_true'),\n+           make_option('-O', '--diff-opts',\n+                       help = 'options to pass to git-diff'),\n            make_option('-s', '--stdout',\n                        help = 'dump the patches to the standard output',\n                        action = 'store_true')]\n@@ -87,8 +86,8 @@ def func(parser, options, args):\n             os.makedirs(dirname)\n         series = file(os.path.join(dirname, 'series'), 'w+')\n \n-    if options.binary:\n-        diff_flags = [ '--binary' ]\n+    if options.diff_opts:\n+        diff_flags = options.diff_opts.split()\n     else:\n         diff_flags = []\n \ndiff --git a/stgit/commands/files.py b/stgit/commands/files.py\nindex 59893d8..659a82b 100644\n--- a/stgit/commands/files.py\n+++ b/stgit/commands/files.py\n@@ -38,6 +38,8 @@ options = [make_option('-s', '--stat',\n                        action = 'store_true'),\n            make_option('-b', '--branch',\n                        help = 'use BRANCH instead of the default one'),\n+           make_option('-O', '--diff-opts',\n+                       help = 'options to pass to git-diff'),\n            make_option('--bare',\n                        help = 'bare file names (useful for scripting)',\n                        action = 'store_true')]\n@@ -61,4 +63,9 @@ def func(parser, options, args):\n     elif options.bare:\n         out.stdout_raw(git.barefiles(rev1, rev2) + '\\n')\n     else:\n-        out.stdout_raw(git.files(rev1, rev2) + '\\n')\n+        if options.diff_opts:\n+            diff_flags = options.diff_opts.split()\n+        else:\n+            diff_flags = []\n+\n+        out.stdout_raw(git.files(rev1, rev2, diff_flags = diff_flags) + '\\n')\ndiff --git a/stgit/commands/mail.py b/stgit/commands/mail.py\nindex 7113cff..cec1828 100644\n--- a/stgit/commands/mail.py\n+++ b/stgit/commands/mail.py\n@@ -120,9 +120,8 @@ options = [make_option('-a', '--all',\n                        help = 'username for SMTP authentication'),\n            make_option('-b', '--branch',\n                        help = 'use BRANCH instead of the default one'),\n-           make_option('--binary',\n-                       help = 'output a diff even for binary files',\n-                       action = 'store_true'),\n+           make_option('-O', '--diff-opts',\n+                       help = 'options to pass to git-diff'),\n            make_option('-m', '--mbox',\n                        help = 'generate an mbox file instead of sending',\n                        action = 'store_true')]\n@@ -377,8 +376,8 @@ def __build_message(tmpl, patch, patch_nr, total_nr, msg_id, ref_id, options):\n     else:\n         prefix_str = ''\n         \n-    if options.binary:\n-        diff_flags = [ '--binary' ]\n+    if options.diff_opts:\n+        diff_flags = options.diff_opts.split()\n     else:\n         diff_flags = []\n \ndiff --git a/stgit/commands/show.py b/stgit/commands/show.py\nindex a270efd..ea4c874 100644\n--- a/stgit/commands/show.py\n+++ b/stgit/commands/show.py\n@@ -35,7 +35,9 @@ options = [make_option('-a', '--applied',\n                        action = 'store_true'),\n            make_option('-u', '--unapplied',\n                        help = 'show the unapplied patches',\n-                       action = 'store_true')]\n+                       action = 'store_true'),\n+           make_option('-O', '--diff-opts',\n+                       help = 'options to pass to git-diff')]\n \n \n def func(parser, options, args):\n@@ -58,8 +60,13 @@ def func(parser, options, args):\n         else:\n             patches = parse_patches(args, applied + unapplied, len(applied))\n \n+    if options.diff_opts:\n+        diff_flags = options.diff_opts.split()\n+    else:\n+        diff_flags = []\n+\n     commit_ids = [git_id(patch) for patch in patches]\n-    commit_str = '\\n'.join([git.pretty_commit(commit_id)\n+    commit_str = '\\n'.join([git.pretty_commit(commit_id, diff_flags=diff_flags)\n                             for commit_id in commit_ids])\n     if commit_str:\n         pager(commit_str)\ndiff --git a/stgit/commands/status.py b/stgit/commands/status.py\nindex b8f0623..156552b 100644\n--- a/stgit/commands/status.py\n+++ b/stgit/commands/status.py\n@@ -58,6 +58,8 @@ options = [make_option('-m', '--modified',\n            make_option('-x', '--noexclude',\n                        help = 'do not exclude any files from listing',\n                        action = 'store_true'),\n+           make_option('-O', '--diff-opts',\n+                       help = 'options to pass to git-diff'),\n            make_option('--reset',\n                        help = 'reset the current tree changes',\n                        action = 'store_true')]\n@@ -75,5 +77,11 @@ def func(parser, options, args):\n             resolved_all()\n             git.reset()\n     else:\n+        if options.diff_opts:\n+            diff_flags = options.diff_opts.split()\n+        else:\n+            diff_flags = []\n+\n         git.status(args, options.modified, options.new, options.deleted,\n-                   options.conflict, options.unknown, options.noexclude)\n+                   options.conflict, options.unknown, options.noexclude,\n+                   diff_flags = diff_flags)\ndiff --git a/stgit/git.py b/stgit/git.py\nindex 7358fae..4bc41aa 100644\n--- a/stgit/git.py\n+++ b/stgit/git.py\n@@ -217,7 +217,7 @@ def __run(cmd, args=None):\n     return 0\n \n def __tree_status(files = None, tree_id = 'HEAD', unknown = False,\n-                  noexclude = True, verbose = False):\n+                  noexclude = True, verbose = False, diff_flags = []):\n     \"\"\"Returns a list of pairs - [status, filename]\n     \"\"\"\n     if verbose:\n@@ -254,7 +254,8 @@ def __tree_status(files = None, tree_id = 'HEAD', unknown = False,\n     cache_files += [('C', filename) for filename in conflicts]\n \n     # the rest\n-    for line in _output_lines(['git-diff-index', tree_id, '--'] + files):\n+    for line in _output_lines(['git-diff-index'] + diff_flags +\n+                              [ tree_id, '--'] + files):\n         fs = tuple(line.rstrip().split(' ',4)[-1].split('\\t',1))\n         if fs[1] not in conflicts:\n             cache_files.append(fs)\n@@ -737,13 +738,15 @@ def merge(base, head1, head2, recursive = False):\n         raise GitException, 'GIT index merging failed (possible conflicts)'\n \n def status(files = None, modified = False, new = False, deleted = False,\n-           conflict = False, unknown = False, noexclude = False):\n+           conflict = False, unknown = False, noexclude = False,\n+           diff_flags = []):\n     \"\"\"Show the tree status\n     \"\"\"\n     if not files:\n         files = []\n \n-    cache_files = __tree_status(files, unknown = True, noexclude = noexclude)\n+    cache_files = __tree_status(files, unknown = True, noexclude = noexclude,\n+                                diff_flags = diff_flags)\n     all = not (modified or new or deleted or conflict or unknown)\n \n     if not all:\n@@ -809,12 +812,12 @@ def diffstat(files = None, rev1 = 'HEAD', rev2 = None):\n         raise GitException, 'git.diffstat failed'\n     return diff_str\n \n-def files(rev1, rev2):\n+def files(rev1, rev2, diff_flags = []):\n     \"\"\"Return the files modified between rev1 and rev2\n     \"\"\"\n \n     result = ''\n-    for line in _output_lines(['git-diff-tree', '-r', rev1, rev2]):\n+    for line in _output_lines(['git-diff-tree'] + diff_flags + ['-r', rev1, rev2]):\n         result += '%s %s\\n' % tuple(line.rstrip().split(' ',4)[-1].split('\\t',1))\n \n     return result.rstrip()\n@@ -829,11 +832,11 @@ def barefiles(rev1, rev2):\n \n     return result.rstrip()\n \n-def pretty_commit(commit_id = 'HEAD'):\n+def pretty_commit(commit_id = 'HEAD', diff_flags = []):\n     \"\"\"Return a given commit (log + diff)\n     \"\"\"\n-    return _output(['git-diff-tree', '--cc', '--always', '--pretty', '-r',\n-                    commit_id])\n+    return _output(['git-diff-tree'] + diff_flags +\n+                   ['--cc', '--always', '--pretty', '-r', commit_id])\n \n def checkout(files = None, tree_id = None, force = False):\n     \"\"\"Check out the given or all files\n"},{"id":"43733","messageId":"87fy5cqbaz.fsf@morpheus.local","threadId":"8381","inReplyTo":"20070531223423.6005.59088.stgit@gandelf.nowhere.earth","subject":"Re: [PATCH 1/4] Add 2 new contrib scripts.","fromName":"David Kågedal","fromEmail":"davidk@lysator.liu.se","sentAt":"2007-06-01T09:22:12Z","receivedAt":"2007-06-01T09:22:12Z","isPatch":true,"sender":{"key":"davidk@lysator.liu.se","avatar":"https://avatars.githubusercontent.com/u/60530?v=4"},"body":"Yann Dirson <ydirson@altern.org> writes:\n\n> diff --git a/contrib/stg-unnew b/contrib/stg-unnew\n> new file mode 100755\n> index 0000000..5ac8781\n> --- /dev/null\n> +++ b/contrib/stg-unnew\n> @@ -0,0 +1,15 @@\n> +#!/bin/sh\n> +set -e\n> +\n> +# stg-unnew - sort of \"reverse an 'stg new'\"\n> +\n> +# Remove the current patch from the stack, keeping its contents as\n> +# uncommitted changes.\n> +\n> +# Copyright (c) 2007 Yann Dirson <ydirson@altern.org>\n> +# Subject to the GNU GPL, version 2.\n> +\n> +patch=$(stg top)\n> +stg pop\n> +stg pick --fold $patch\n> +stg delete $patch\n>\n\nThis is something I've been missing.  But I'd call it \"stg merge\" or\nsomething, since what it does is that it merges the top patch into the\npatch below it.  But since \"merge\" means something else to git, it\nmight not be the best choice.\n\n-- \nDavid Kågedal\n"},{"id":"43858","messageId":"20070603123254.GB6507@diana.vm.bytemark.co.uk","threadId":"8381","inReplyTo":"87fy5cqbaz.fsf@morpheus.local","subject":"Re: [PATCH 1/4] Add 2 new contrib scripts.","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2007-06-03T12:32:54Z","receivedAt":"2007-06-03T12:32:54Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2007-06-01 11:22:12 +0200, David Kågedal wrote:\n\n> This is something I've been missing.\n\nI believe this is useful, too.\n\n> But I'd call it \"stg merge\" or something, since what it does is that\n> it merges the top patch into the patch below it. But since \"merge\"\n> means something else to git, it might not be the best choice.\n\nMaybe \"coalesce\"? I recall using that word when turning several\nconsecutive memory blocks into a single larger block in a malloc\nimplementation, and this sitiation is very similar.\n\nIt would be nice if it was possible to specify an arbitrary series of\npatches, and get them coalesced into one. (StGIT would have to push\nand pop to place them consecutively and topmost.) With a parameter to\ncontrol the name of the new large patch, and the comment being the\nconcatenation of the comments of the component patches (easily\neditable in the editor window that pops up).\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"43860","messageId":"20070603124018.GD6992@nan92-1-81-57-214-146.fbx.proxad.net","threadId":"8381","inReplyTo":"20070603123254.GB6507@diana.vm.bytemark.co.uk","subject":"Re: [PATCH 1/4] Add 2 new contrib scripts.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-06-03T12:40:18Z","receivedAt":"2007-06-03T12:40:18Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"On Sun, Jun 03, 2007 at 02:32:54PM +0200, Karl Hasselström wrote:\n> On 2007-06-01 11:22:12 +0200, David Kågedal wrote:\n> \n> > This is something I've been missing.\n> \n> I believe this is useful, too.\n> \n> > But I'd call it \"stg merge\" or something, since what it does is that\n> > it merges the top patch into the patch below it. But since \"merge\"\n> > means something else to git, it might not be the best choice.\n> \n> Maybe \"coalesce\"? I recall using that word when turning several\n> consecutive memory blocks into a single larger block in a malloc\n> implementation, and this sitiation is very similar.\n\nHm, maybe, but the idea is not necessarily to merge this patch into\nthe former one (I have written contrib/stg-swallow for this use), but\nreally to turn the patch into just local changes (eg. to restore local\nchanges after a complex operation, like in stg-k).\n\n> It would be nice if it was possible to specify an arbitrary series of\n> patches, and get them coalesced into one. (StGIT would have to push\n> and pop to place them consecutively and topmost.) With a parameter to\n> control the name of the new large patch, and the comment being the\n> concatenation of the comments of the component patches (easily\n> editable in the editor window that pops up).\n\nstg-swallow would be quite easy to extend for this usage.\n\nBest regards,\n-- \nYann.\n"},{"id":"44009","messageId":"b0943d9e0706041515l6114a015ye45d40478cc0e3ef@mail.gmail.com","threadId":"8381","inReplyTo":"20070531223438.6005.76115.stgit@gandelf.nowhere.earth","subject":"Re: [PATCH 4/4] Add new --diff-opts/-O flag to diff- and status-related commands.","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2007-06-04T22:15:23Z","receivedAt":"2007-06-04T22:15:23Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"On 31/05/07, Yann Dirson <ydirson@altern.org> wrote:\n> This new flag allows to pass arbitrary flags to the git-diff calls\n> underlying several StGIT commands.  It can be used to pass flags\n> affecting both diff- and status-generating commands (eg. -M or -C), or\n> flags only affecting diff-generating ones (eg. --color, --binary).\n>\n> It supercedes --binary for commands where it was allowed,\n> '-O --binary' is now available for the same functionality.\n\nBTW, should we add --binary by default to export and mail? Do you see\nany problem with this?\n\nAnother idea would be to add support for a [stgit \"options\"] section\nwith entries like \"mail = -O --binary\".\n\n-- \nCatalin\n"},{"id":"44040","messageId":"20070605064730.GG6962@nan92-1-81-57-214-146.fbx.proxad.net","threadId":"8381","inReplyTo":"b0943d9e0706041515l6114a015ye45d40478cc0e3ef@mail.gmail.com","subject":"Re: [PATCH 4/4] Add new --diff-opts/-O flag to diff- and status-related commands.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-06-05T06:47:30Z","receivedAt":"2007-06-05T06:47:30Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"On Mon, Jun 04, 2007 at 11:15:23PM +0100, Catalin Marinas wrote:\n> On 31/05/07, Yann Dirson <ydirson@altern.org> wrote:\n> >This new flag allows to pass arbitrary flags to the git-diff calls\n> >underlying several StGIT commands.  It can be used to pass flags\n> >affecting both diff- and status-generating commands (eg. -M or -C), or\n> >flags only affecting diff-generating ones (eg. --color, --binary).\n> >\n> >It supercedes --binary for commands where it was allowed,\n> >'-O --binary' is now available for the same functionality.\n> \n> BTW, should we add --binary by default to export and mail? Do you see\n> any problem with this?\n> \n> Another idea would be to add support for a [stgit \"options\"] section\n> with entries like \"mail = -O --binary\".\n\nRight, but we have to think how flags in the config file interact with\nflags on command line.\n\n- does the command line shadow the config file completely (ie. \"-O ''\"\ncan be used for to not pass any flags), in which case, each time we\nwant a particular flag we need to pass all default ones again ?\n\n- does the command line add to the flags specified from config file,\nin which case we still need a way to override those ; I have 2 ideas\nhere: a flag that resets opts to '', or a flag to remove specific\nflags (eg. if we have '--binary -w' in the config and we want\n'--binary -C', we can say something like '-O -C --no-diff-opts -w').\n\n\nAlso useful would be to have different config defaults for the case\nwhere we go through the pager, but then we may have to guess when the\npager will trigger (or maybe we can ask pydoc if the pager will\ntrigger ?).\n\nBest regards,\n-- \nYann\n"}]}