{"thread":{"id":"10190","subject":"[StGit PATCH 2/6] Use our nice message printout wrapping system","startedAt":"2007-10-08T08:55:02Z","lastAt":"2007-10-09T05:12:47Z","messageCount":12,"participants":["Karl Hasselström"],"isPatch":true,"patchVersion":1,"patchTotal":6},"messages":[{"id":"55170","messageId":"20071008085430.9734.75797.stgit@yoghurt","threadId":"10190","inReplyTo":null,"subject":"[StGit PATCH 0/6] Survive capital punishment","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2007-10-08T08:55:02Z","receivedAt":"2007-10-08T08:55:02Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"This series allows StGit to deal with a detached HEAD: in most cases\nit will just exit with a nice error message, but in some cases it will\nactually handle it.\n\nPreceded by some more or less related cleanups. (The \"explicit\ncrt_series\" patch was needed so that I could grep for the files that\ndidn't contain crt_series.)\n\n---\n\nKarl Hasselström (6):\n      Let some commands work with detached HEAD\n      Don't have a global crt_series in stgit.commans.common\n      Refactor crt_series creation\n      Properly detect that HEAD is detached\n      Use our nice message printout wrapping system\n      Allow caller to customize title of error/warning message\n\n\n stgit/commands/add.py      |    2 +-\n stgit/commands/branch.py   |    8 ++++----\n stgit/commands/clean.py    |    4 ++--\n stgit/commands/clone.py    |    2 +-\n stgit/commands/commit.py   |    2 +-\n stgit/commands/common.py   |   24 ++++++++++++------------\n stgit/commands/delete.py   |    4 ++--\n stgit/commands/diff.py     |    9 +++++----\n stgit/commands/edit.py     |    6 +++---\n stgit/commands/files.py    |    4 ++--\n stgit/commands/float.py    |    6 +++---\n stgit/commands/fold.py     |    5 +++--\n stgit/commands/goto.py     |    8 ++++----\n stgit/commands/id.py       |    2 +-\n stgit/commands/imprt.py    |    7 ++++---\n stgit/commands/mail.py     |   16 +++++++++-------\n stgit/commands/new.py      |    2 +-\n stgit/commands/pick.py     |   12 ++++++------\n stgit/commands/pop.py      |    8 ++++----\n stgit/commands/pull.py     |   14 +++++++-------\n stgit/commands/push.py     |    8 ++++----\n stgit/commands/rebase.py   |   12 ++++++------\n stgit/commands/refresh.py  |   10 +++++-----\n stgit/commands/resolved.py |    2 +-\n stgit/commands/series.py   |    5 +++--\n stgit/commands/show.py     |    2 +-\n stgit/commands/sink.py     |    6 +++---\n stgit/commands/status.py   |    2 +-\n stgit/commands/sync.py     |    8 ++++----\n stgit/commands/uncommit.py |    2 +-\n stgit/git.py               |   23 +++++++++++++++++------\n stgit/main.py              |    8 +++-----\n stgit/out.py               |   12 ++++++------\n 33 files changed, 130 insertions(+), 115 deletions(-)\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"55171","messageId":"20071008085512.9734.33911.stgit@yoghurt","threadId":"10190","inReplyTo":"20071008085430.9734.75797.stgit@yoghurt","subject":"[StGit PATCH 1/6] Allow caller to customize title of error/warning message","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2007-10-08T08:55:12Z","receivedAt":"2007-10-08T08:55:12Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"Signed-off-by: Karl Hasselström <kha@treskal.com>\n\n---\n\n stgit/out.py |   12 ++++++------\n 1 files changed, 6 insertions(+), 6 deletions(-)\n\n\ndiff --git a/stgit/out.py b/stgit/out.py\nindex 3464175..d3c86b4 100644\n--- a/stgit/out.py\n+++ b/stgit/out.py\n@@ -85,12 +85,12 @@ class MessagePrinter(object):\n     def info(self, *msgs):\n         for msg in msgs:\n             self.__out.single_line(msg)\n-    def note(self, *msgs):\n-        self.__out.tagged_lines('Notice', msgs)\n-    def warn(self, *msgs):\n-        self.__err.tagged_lines('Warning', msgs)\n-    def error(self, *msgs):\n-        self.__err.tagged_lines('Error', msgs)\n+    def note(self, *msgs, **kw):\n+        self.__out.tagged_lines(kw.get('title', 'Notice'), msgs)\n+    def warn(self, *msgs, **kw):\n+        self.__err.tagged_lines(kw.get('title', 'Warning'), msgs)\n+    def error(self, *msgs, **kw):\n+        self.__err.tagged_lines(kw.get('title', 'Error'), msgs)\n     def start(self, msg):\n         \"\"\"Start a long-running operation.\"\"\"\n         self.__out.single_line('%s ... ' % msg, print_newline = False)\n"},{"id":"55169","messageId":"20071008085518.9734.44584.stgit@yoghurt","threadId":"10190","inReplyTo":"20071008085430.9734.75797.stgit@yoghurt","subject":"[StGit PATCH 2/6] Use our nice message printout wrapping system","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2007-10-08T08:55:18Z","receivedAt":"2007-10-08T08:55:18Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"Signed-off-by: Karl Hasselström <kha@treskal.com>\n\n---\n\n stgit/main.py |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\n\ndiff --git a/stgit/main.py b/stgit/main.py\nindex 15582dd..8e00217 100644\n--- a/stgit/main.py\n+++ b/stgit/main.py\n@@ -282,7 +282,7 @@ def main():\n \n         command.func(parser, options, args)\n     except (StgException, IOError, ParsingError, NoSectionError), err:\n-        print >> sys.stderr, '%s %s: %s' % (prog, cmd, err)\n+        out.error(str(err), title = '%s %s' % (prog, cmd))\n         if debug_level > 0:\n             raise\n         else:\n"},{"id":"55174","messageId":"20071008085523.9734.44817.stgit@yoghurt","threadId":"10190","inReplyTo":"20071008085430.9734.75797.stgit@yoghurt","subject":"[StGit PATCH 3/6] Properly detect that HEAD is detached","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2007-10-08T08:55:23Z","receivedAt":"2007-10-08T08:55:23Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"We still error out on a lot of places we shouldn't, e.g. \"stg branch\"\nwhen on a detached HEAD, but at least now we give a sane error\nmessage.\n\nSigned-off-by: Karl Hasselström <kha@treskal.com>\n\n---\n\n stgit/git.py |   23 +++++++++++++++++------\n 1 files changed, 17 insertions(+), 6 deletions(-)\n\n\ndiff --git a/stgit/git.py b/stgit/git.py\nindex 812b77a..cc6acb1 100644\n--- a/stgit/git.py\n+++ b/stgit/git.py\n@@ -246,11 +246,19 @@ def get_head():\n         __head = rev_parse('HEAD')\n     return __head\n \n+class DetachedHeadException(GitException):\n+    def __init__(self):\n+        GitException.__init__(self, 'Not on any branch')\n+\n 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-                        GRun('git-symbolic-ref', 'HEAD').output_one_line())\n+    \"\"\"Return the name of the file pointed to by the HEAD symref.\n+    Throw an exception if HEAD is detached.\"\"\"\n+    try:\n+        return strip_prefix(\n+            'refs/heads/', GRun('git-symbolic-ref', '-q', 'HEAD'\n+                                ).output_one_line())\n+    except GitRunException:\n+        raise DetachedHeadException()\n \n def set_head_file(ref):\n     \"\"\"Resets HEAD to point to a new ref\n@@ -385,8 +393,11 @@ def rename_ref(from_ref, to_ref):\n def rename_branch(from_name, to_name):\n     \"\"\"Rename a git branch.\"\"\"\n     rename_ref('refs/heads/%s' % from_name, 'refs/heads/%s' % to_name)\n-    if get_head_file() == from_name:\n-        set_head_file(to_name)\n+    try:\n+        if get_head_file() == from_name:\n+            set_head_file(to_name)\n+    except DetachedHeadException:\n+        pass # detached HEAD, so the renamee can't be the current branch\n     reflog_dir = os.path.join(basedir.get(), 'logs', 'refs', 'heads')\n     if os.path.exists(reflog_dir) \\\n            and os.path.exists(os.path.join(reflog_dir, from_name)):\n"},{"id":"55173","messageId":"20071008085529.9734.42383.stgit@yoghurt","threadId":"10190","inReplyTo":"20071008085430.9734.75797.stgit@yoghurt","subject":"[StGit PATCH 4/6] Refactor crt_series creation","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2007-10-08T08:55:29Z","receivedAt":"2007-10-08T08:55:29Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"Instead of hard-coding in main.py which commands do and don't need a\ncurrent series, let them speak for themselves.\n\nSigned-off-by: Karl Hasselström <kha@treskal.com>\n\n---\n\n stgit/commands/clone.py  |    2 +-\n stgit/commands/common.py |    2 ++\n stgit/main.py            |    5 ++---\n 3 files changed, 5 insertions(+), 4 deletions(-)\n\n\ndiff --git a/stgit/commands/clone.py b/stgit/commands/clone.py\nindex a150010..c3b0bbe 100644\n--- a/stgit/commands/clone.py\n+++ b/stgit/commands/clone.py\n@@ -29,7 +29,7 @@ usage = \"\"\"%prog [options] <repository> <dir>\n Clone a GIT <repository> into the local <dir> and initialise the\n patch stack.\"\"\"\n \n-directory = DirectoryAnywhere()\n+directory = DirectoryAnywhere(needs_current_series = False)\n options = []\n \n \ndiff --git a/stgit/commands/common.py b/stgit/commands/common.py\nindex 27ef465..652039f 100644\n--- a/stgit/commands/common.py\n+++ b/stgit/commands/common.py\n@@ -497,6 +497,8 @@ class DirectoryException(StgException):\n     pass\n \n class _Directory(object):\n+    def __init__(self, needs_current_series = True):\n+        self.needs_current_series =  needs_current_series\n     @readonly_constant_property\n     def git_dir(self):\n         try:\ndiff --git a/stgit/main.py b/stgit/main.py\nindex 8e00217..db327f1 100644\n--- a/stgit/main.py\n+++ b/stgit/main.py\n@@ -271,9 +271,8 @@ def main():\n         directory.setup()\n         config_setup()\n \n-        # 'clone' doesn't expect an already initialised GIT tree. A Series\n-        # object will be created after the GIT tree is cloned\n-        if cmd != 'clone':\n+        # Some commands don't (always) need an initialized series.\n+        if directory.needs_current_series:\n             if hasattr(options, 'branch') and options.branch:\n                 command.crt_series = Series(options.branch)\n             else:\n"},{"id":"55172","messageId":"20071008085535.9734.21876.stgit@yoghurt","threadId":"10190","inReplyTo":"20071008085430.9734.75797.stgit@yoghurt","subject":"[StGit PATCH 5/6] Don't have a global crt_series in stgit.commans.common","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2007-10-08T08:55:35Z","receivedAt":"2007-10-08T08:55:35Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"Global variables baaad. Instead, pass it as a parameter to the\nfunctions that need it.\n\nSigned-off-by: Karl Hasselström <kha@treskal.com>\n\n---\n\n stgit/commands/branch.py   |    8 ++++----\n stgit/commands/clean.py    |    4 ++--\n stgit/commands/commit.py   |    2 +-\n stgit/commands/common.py   |   22 ++++++++++------------\n stgit/commands/delete.py   |    4 ++--\n stgit/commands/diff.py     |    7 ++++---\n stgit/commands/edit.py     |    6 +++---\n stgit/commands/files.py    |    4 ++--\n stgit/commands/float.py    |    6 +++---\n stgit/commands/fold.py     |    5 +++--\n stgit/commands/goto.py     |    8 ++++----\n stgit/commands/id.py       |    2 +-\n stgit/commands/imprt.py    |    7 ++++---\n stgit/commands/mail.py     |   16 +++++++++-------\n stgit/commands/new.py      |    2 +-\n stgit/commands/pick.py     |   12 ++++++------\n stgit/commands/pop.py      |    8 ++++----\n stgit/commands/pull.py     |   14 +++++++-------\n stgit/commands/push.py     |    8 ++++----\n stgit/commands/rebase.py   |   12 ++++++------\n stgit/commands/refresh.py  |   10 +++++-----\n stgit/commands/series.py   |    5 +++--\n stgit/commands/show.py     |    2 +-\n stgit/commands/sink.py     |    6 +++---\n stgit/commands/sync.py     |    8 ++++----\n stgit/commands/uncommit.py |    2 +-\n stgit/main.py              |    1 -\n 27 files changed, 97 insertions(+), 94 deletions(-)\n\n\ndiff --git a/stgit/commands/branch.py b/stgit/commands/branch.py\nindex 6e0a6d8..cbb97f6 100644\n--- a/stgit/commands/branch.py\n+++ b/stgit/commands/branch.py\n@@ -112,7 +112,7 @@ def func(parser, options, args):\n \n         check_local_changes()\n         check_conflicts()\n-        check_head_top_equal()\n+        check_head_top_equal(crt_series)\n \n         tree_id = None\n         if len(args) >= 2:\n@@ -141,7 +141,7 @@ def func(parser, options, args):\n                 # exception in branch = rev_parse() leaves branchpoint unbound\n                 branchpoint = None\n \n-            tree_id = branchpoint or git_id(args[1])\n+            tree_id = branchpoint or git_id(crt_series, args[1])\n \n             if parentbranch:\n                 out.info('Recording \"%s\" as parent branch' % parentbranch)\n@@ -182,7 +182,7 @@ def func(parser, options, args):\n \n         check_local_changes()\n         check_conflicts()\n-        check_head_top_equal()\n+        check_head_top_equal(crt_series)\n \n         out.start('Cloning current branch to \"%s\"' % clone)\n         crt_series.clone(clone)\n@@ -294,7 +294,7 @@ def func(parser, options, args):\n \n         check_local_changes()\n         check_conflicts()\n-        check_head_top_equal()\n+        check_head_top_equal(crt_series)\n \n         out.start('Switching to branch \"%s\"' % args[0])\n         git.switch_branch(args[0])\ndiff --git a/stgit/commands/clean.py b/stgit/commands/clean.py\nindex d8bbe71..4484ecd 100644\n--- a/stgit/commands/clean.py\n+++ b/stgit/commands/clean.py\n@@ -61,7 +61,7 @@ def func(parser, options, args):\n \n     check_local_changes()\n     check_conflicts()\n-    check_head_top_equal()\n+    check_head_top_equal(crt_series)\n \n     if not (options.applied or options.unapplied):\n         options.applied = options.unapplied = True\n@@ -74,4 +74,4 @@ def func(parser, options, args):\n         unapplied = crt_series.get_unapplied()\n         __delete_empty(unapplied, False)\n \n-    print_crt_patch()\n+    print_crt_patch(crt_series)\ndiff --git a/stgit/commands/commit.py b/stgit/commands/commit.py\nindex 2b45c0d..23b4dc1 100644\n--- a/stgit/commands/commit.py\n+++ b/stgit/commands/commit.py\n@@ -45,7 +45,7 @@ def func(parser, options, args):\n \n     check_local_changes()\n     check_conflicts()\n-    check_head_top_equal()\n+    check_head_top_equal(crt_series)\n \n     applied = crt_series.get_applied()\n     if not applied:\ndiff --git a/stgit/commands/common.py b/stgit/commands/common.py\nindex 652039f..2a80e8c 100644\n--- a/stgit/commands/common.py\n+++ b/stgit/commands/common.py\n@@ -28,8 +28,6 @@ from stgit.run import *\n from stgit import stack, git, basedir\n from stgit.config import config, file_extensions\n \n-crt_series = None\n-\n \n # Command exception class\n class CmdException(StgException):\n@@ -74,7 +72,7 @@ def parse_rev(rev):\n     # No, we can't parse that.\n     raise RevParseException\n \n-def git_id(rev):\n+def git_id(crt_series, rev):\n     \"\"\"Return the GIT id\n     \"\"\"\n     if not rev:\n@@ -112,7 +110,7 @@ def check_local_changes():\n         raise CmdException, \\\n               'local changes in the tree. Use \"refresh\" or \"status --reset\"'\n \n-def check_head_top_equal():\n+def check_head_top_equal(crt_series):\n     if not crt_series.head_top_equal():\n         raise CmdException(\n \"\"\"HEAD and top are not the same. This can happen if you\n@@ -125,7 +123,7 @@ def check_conflicts():\n               'Unsolved conflicts. Please resolve them first or\\n' \\\n               '  revert the changes with \"status --reset\"'\n \n-def print_crt_patch(branch = None):\n+def print_crt_patch(crt_series, branch = None):\n     if not branch:\n         patch = crt_series.get_current()\n     else:\n@@ -158,7 +156,7 @@ def resolved_all(reset = None):\n             resolved(filename, reset)\n         os.remove(os.path.join(basedir.get(), 'conflicts'))\n \n-def push_patches(patches, check_merged = False):\n+def push_patches(crt_series, patches, check_merged = False):\n     \"\"\"Push multiple patches onto the stack. This function is shared\n     between the push and pull commands\n     \"\"\"\n@@ -197,7 +195,7 @@ def push_patches(patches, check_merged = False):\n             else:\n                 out.done()\n \n-def pop_patches(patches, keep = False):\n+def pop_patches(crt_series, patches, keep = False):\n     \"\"\"Pop the patches in the list from the stack. It is assumed that\n     the patches are listed in the stack reverse order.\n     \"\"\"\n@@ -319,7 +317,7 @@ def address_or_alias(addr_str):\n                  for addr in addr_str.split(',')]\n     return ', '.join([addr for addr in addr_list if addr])\n \n-def prepare_rebase():\n+def prepare_rebase(crt_series):\n     # pop all patches\n     applied = crt_series.get_applied()\n     if len(applied) > 0:\n@@ -328,9 +326,9 @@ def prepare_rebase():\n         out.done()\n     return applied\n \n-def rebase(target):\n+def rebase(crt_series, target):\n     try:\n-        tree_id = git_id(target)\n+        tree_id = git_id(crt_series, target)\n     except:\n         # it might be that we use a custom rebase command with its own\n         # target type\n@@ -345,12 +343,12 @@ def rebase(target):\n     git.rebase(tree_id = tree_id)\n     out.done()\n \n-def post_rebase(applied, nopush, merged):\n+def post_rebase(crt_series, applied, nopush, merged):\n     # memorize that we rebased to here\n     crt_series._set_field('orig-base', git.get_head())\n     # push the patches back\n     if not nopush:\n-        push_patches(applied, merged)\n+        push_patches(crt_series, applied, merged)\n \n #\n # Patch description/e-mail/diff parsing\ndiff --git a/stgit/commands/delete.py b/stgit/commands/delete.py\nindex 8462857..fdb254e 100644\n--- a/stgit/commands/delete.py\n+++ b/stgit/commands/delete.py\n@@ -71,7 +71,7 @@ def func(parser, options, args):\n     if applied and not options.branch:\n         check_local_changes()\n         check_conflicts()\n-        check_head_top_equal()\n+        check_head_top_equal(crt_series)\n \n     # delete the patches\n     for patch in applied + patches:\n@@ -79,4 +79,4 @@ def func(parser, options, args):\n         out.info('Patch \"%s\" successfully deleted' % patch)\n \n     if not options.branch:\n-        print_crt_patch()\n+        print_crt_patch(crt_series)\ndiff --git a/stgit/commands/diff.py b/stgit/commands/diff.py\nindex f3b0ea2..42e8367 100644\n--- a/stgit/commands/diff.py\n+++ b/stgit/commands/diff.py\n@@ -86,9 +86,10 @@ def func(parser, options, args):\n         diff_flags = []\n \n     if options.stat:\n-        out.stdout_raw(git.diffstat(args, git_id(rev1), git_id(rev2)) + '\\n')\n+        out.stdout_raw(git.diffstat(args, git_id(crt_series, rev1),\n+                                    git_id(crt_series, rev2)) + '\\n')\n     else:\n-        diff_str = git.diff(args, git_id(rev1), git_id(rev2),\n-                            diff_flags = diff_flags )\n+        diff_str = git.diff(args, git_id(crt_series, rev1),\n+                            git_id(crt_series, rev2), diff_flags = diff_flags )\n         if diff_str:\n             pager(diff_str)\ndiff --git a/stgit/commands/edit.py b/stgit/commands/edit.py\nindex 02970bc..89d534a 100644\n--- a/stgit/commands/edit.py\n+++ b/stgit/commands/edit.py\n@@ -203,13 +203,13 @@ def func(parser, options, args):\n \n     check_local_changes()\n     check_conflicts()\n-    check_head_top_equal()\n+    check_head_top_equal(crt_series)\n \n     if pname != crt_pname:\n         # Go to the patch to be edited\n         applied = crt_series.get_applied()\n         between = applied[:applied.index(pname):-1]\n-        pop_patches(between)\n+        pop_patches(crt_series, between)\n \n     if options.author:\n         options.authname, options.authemail = name_email(options.author)\n@@ -241,4 +241,4 @@ def func(parser, options, args):\n     if pname != crt_pname:\n         # Push the patches back\n         between.reverse()\n-        push_patches(between)\n+        push_patches(crt_series, between)\ndiff --git a/stgit/commands/files.py b/stgit/commands/files.py\nindex 07cc955..4550251 100644\n--- a/stgit/commands/files.py\n+++ b/stgit/commands/files.py\n@@ -57,8 +57,8 @@ def func(parser, options, args):\n     else:\n         parser.error('incorrect number of arguments')\n \n-    rev1 = git_id('%s//bottom' % patch)\n-    rev2 = git_id('%s//top' % patch)\n+    rev1 = git_id(crt_series, '%s//bottom' % patch)\n+    rev2 = git_id(crt_series, '%s//top' % patch)\n \n     if options.stat:\n         out.stdout_raw(git.diffstat(rev1 = rev1, rev2 = rev2) + '\\n')\ndiff --git a/stgit/commands/float.py b/stgit/commands/float.py\nindex d5299fb..6c07136 100644\n--- a/stgit/commands/float.py\n+++ b/stgit/commands/float.py\n@@ -46,7 +46,7 @@ def func(parser, options, args):\n \n     check_local_changes()\n     check_conflicts()\n-    check_head_top_equal()\n+    check_head_top_equal(crt_series)\n \n     unapplied = crt_series.get_unapplied()\n     applied = crt_series.get_applied()\n@@ -85,7 +85,7 @@ def func(parser, options, args):\n     # check whether the operation is really needed\n     if topop != topush:\n         if topop:\n-            pop_patches(topop)\n+            pop_patches(crt_series, topop)\n         if topush:\n             topush.reverse()\n-            push_patches(topush)\n+            push_patches(crt_series, topush)\ndiff --git a/stgit/commands/fold.py b/stgit/commands/fold.py\nindex 6e43101..3930a1f 100644\n--- a/stgit/commands/fold.py\n+++ b/stgit/commands/fold.py\n@@ -50,7 +50,7 @@ def func(parser, options, args):\n \n     check_local_changes()\n     check_conflicts()\n-    check_head_top_equal()\n+    check_head_top_equal(crt_series)\n \n     if len(args) == 1:\n         filename = args[0]\n@@ -74,7 +74,8 @@ def func(parser, options, args):\n         bottom = crt_patch.get_bottom()\n         git.apply_patch(filename = filename, base = bottom)\n     elif options.base:\n-        git.apply_patch(filename = filename, base = git_id(options.base))\n+        git.apply_patch(filename = filename,\n+                        base = git_id(crt_series, options.base))\n     else:\n         git.apply_patch(filename = filename)\n \ndiff --git a/stgit/commands/goto.py b/stgit/commands/goto.py\nindex 9e008a9..e7aa588 100644\n--- a/stgit/commands/goto.py\n+++ b/stgit/commands/goto.py\n@@ -44,7 +44,7 @@ def func(parser, options, args):\n         parser.error('incorrect number of arguments')\n \n     check_conflicts()\n-    check_head_top_equal()\n+    check_head_top_equal(crt_series)\n \n     if not options.keep:\n         check_local_changes()\n@@ -56,13 +56,13 @@ def func(parser, options, args):\n     if patch in applied:\n         applied.reverse()\n         patches = applied[:applied.index(patch)]\n-        pop_patches(patches, options.keep)\n+        pop_patches(crt_series, patches, options.keep)\n     elif patch in unapplied:\n         if options.keep:\n             raise CmdException, 'Cannot use --keep with patch pushing'\n         patches = unapplied[:unapplied.index(patch)+1]\n-        push_patches(patches)\n+        push_patches(crt_series, patches)\n     else:\n         raise CmdException, 'Patch \"%s\" does not exist' % patch\n \n-    print_crt_patch()\n+    print_crt_patch(crt_series)\ndiff --git a/stgit/commands/id.py b/stgit/commands/id.py\nindex 3e28f2f..94b0229 100644\n--- a/stgit/commands/id.py\n+++ b/stgit/commands/id.py\n@@ -48,4 +48,4 @@ def func(parser, options, args):\n     else:\n         parser.error('incorrect number of arguments')\n \n-    out.stdout(git_id(id_str))\n+    out.stdout(git_id(crt_series, id_str))\ndiff --git a/stgit/commands/imprt.py b/stgit/commands/imprt.py\nindex 045f185..d6e950c 100644\n--- a/stgit/commands/imprt.py\n+++ b/stgit/commands/imprt.py\n@@ -165,7 +165,8 @@ def __create_patch(filename, message, author_name, author_email,\n     else:\n         out.start('Importing patch \"%s\"' % patch)\n         if options.base:\n-            git.apply_patch(diff = diff, base = git_id(options.base))\n+            git.apply_patch(diff = diff,\n+                            base = git_id(crt_series, options.base))\n         else:\n             git.apply_patch(diff = diff)\n         crt_series.refresh_patch(edit = options.edit,\n@@ -270,7 +271,7 @@ def func(parser, options, args):\n \n     check_local_changes()\n     check_conflicts()\n-    check_head_top_equal()\n+    check_head_top_equal(crt_series)\n \n     if len(args) == 1:\n         filename = args[0]\n@@ -286,4 +287,4 @@ def func(parser, options, args):\n     else:\n         __import_file(filename, options)\n \n-    print_crt_patch()\n+    print_crt_patch(crt_series)\ndiff --git a/stgit/commands/mail.py b/stgit/commands/mail.py\nindex 4a4158a..883a4f3 100644\n--- a/stgit/commands/mail.py\n+++ b/stgit/commands/mail.py\n@@ -350,8 +350,8 @@ def __build_cover(tmpl, patches, msg_id, options):\n                  'shortlog':     stack.shortlog(crt_series.get_patch(p)\n                                                 for p in patches),\n                  'diffstat':     git.diffstat(\n-                                     rev1 = git_id('%s//bottom' % patches[0]),\n-                                     rev2 = git_id('%s//top' % patches[-1]))}\n+                     rev1 = git_id(crt_series, '%s//bottom' % patches[0]),\n+                     rev2 = git_id(crt_series, '%s//top' % patches[-1]))}\n \n     try:\n         msg_string = tmpl % tmpl_dict\n@@ -435,11 +435,13 @@ def __build_message(tmpl, patch, patch_nr, total_nr, msg_id, ref_id, options):\n                  'longdescr':    long_descr,\n                  # for backward template compatibility\n                  'endofheaders': '',\n-                 'diff':         git.diff(rev1 = git_id('%s//bottom' % patch),\n-                                          rev2 = git_id('%s//top' % patch),\n-                                          diff_flags = diff_flags ),\n-                 'diffstat':     git.diffstat(rev1 = git_id('%s//bottom'%patch),\n-                                              rev2 = git_id('%s//top' % patch)),\n+                 'diff':         git.diff(\n+                     rev1 = git_id(crt_series, '%s//bottom' % patch),\n+                     rev2 = git_id(crt_series, '%s//top' % patch),\n+                     diff_flags = diff_flags),\n+                 'diffstat':     git.diffstat(\n+                     rev1 = git_id(crt_series, '%s//bottom'%patch),\n+                     rev2 = git_id(crt_series, '%s//top' % patch)),\n                  # for backward template compatibility\n                  'date':         '',\n                  'version':      version_str,\ndiff --git a/stgit/commands/new.py b/stgit/commands/new.py\nindex ccc8141..b0a57d1 100644\n--- a/stgit/commands/new.py\n+++ b/stgit/commands/new.py\n@@ -70,7 +70,7 @@ def func(parser, options, args):\n         parser.error('incorrect number of arguments')\n \n     check_conflicts()\n-    check_head_top_equal()\n+    check_head_top_equal(crt_series)\n \n     if options.author:\n         options.authname, options.authemail = name_email(options.author)\ndiff --git a/stgit/commands/pick.py b/stgit/commands/pick.py\nindex 3acec32..1fcc2e2 100644\n--- a/stgit/commands/pick.py\n+++ b/stgit/commands/pick.py\n@@ -65,10 +65,10 @@ def func(parser, options, args):\n     if not options.unapplied:\n         check_local_changes()\n         check_conflicts()\n-        check_head_top_equal()\n+        check_head_top_equal(crt_series)\n \n     commit_str = args[0]\n-    commit_id = git_id(commit_str)\n+    commit_id = git_id(crt_series, commit_str)\n     commit = git.Commit(commit_id)\n \n     if options.fold or options.update:\n@@ -84,7 +84,7 @@ def func(parser, options, args):\n             patchname = None\n \n     if options.parent:\n-        parent = git_id(options.parent)\n+        parent = git_id(crt_series, options.parent)\n     else:\n         parent = commit.get_parent()\n \n@@ -104,8 +104,8 @@ def func(parser, options, args):\n \n         out.done()\n     elif options.update:\n-        rev1 = git_id('//bottom')\n-        rev2 = git_id('//top')\n+        rev1 = git_id(crt_series, '//bottom')\n+        rev2 = git_id(crt_series, '//top')\n         files = git.barefiles(rev1, rev2).split('\\n')\n \n         out.start('Updating with commit %s' % commit_id)\n@@ -163,4 +163,4 @@ def func(parser, options, args):\n         else:\n             out.done()\n \n-    print_crt_patch()\n+    print_crt_patch(crt_series)\ndiff --git a/stgit/commands/pop.py b/stgit/commands/pop.py\nindex a1d73e4..246cc34 100644\n--- a/stgit/commands/pop.py\n+++ b/stgit/commands/pop.py\n@@ -51,7 +51,7 @@ def func(parser, options, args):\n     \"\"\"Pop the topmost patch from the stack\n     \"\"\"\n     check_conflicts()\n-    check_head_top_equal()\n+    check_head_top_equal(crt_series)\n \n     if not options.keep:\n         check_local_changes()\n@@ -83,8 +83,8 @@ def func(parser, options, args):\n         raise CmdException, 'Cannot pop arbitrary patches with --keep'\n \n     topop.reverse()\n-    pop_patches(topop, options.keep)\n+    pop_patches(crt_series, topop, options.keep)\n     if topush:\n-        push_patches(topush)\n+        push_patches(crt_series, topush)\n \n-    print_crt_patch()\n+    print_crt_patch(crt_series)\ndiff --git a/stgit/commands/pull.py b/stgit/commands/pull.py\nindex 5fcf2cc..e5ee17d 100644\n--- a/stgit/commands/pull.py\n+++ b/stgit/commands/pull.py\n@@ -74,12 +74,12 @@ def func(parser, options, args):\n \n     check_local_changes()\n     check_conflicts()\n-    check_head_top_equal()\n+    check_head_top_equal(crt_series)\n \n     if policy not in ['pull', 'fetch-rebase', 'rebase']:\n         raise GitConfigException, 'Unsupported pull-policy \"%s\"' % policy\n \n-    applied = prepare_rebase()\n+    applied = prepare_rebase(crt_series)\n \n     # pull the remote changes\n     if policy == 'pull':\n@@ -92,17 +92,17 @@ def func(parser, options, args):\n             target = git.fetch_head()\n         except git.GitException:\n             out.error('Could not find the remote head to rebase onto, pushing any patches back...')\n-            post_rebase(applied, False, False)\n+            post_rebase(crt_series, applied, False, False)\n             raise CmdException, 'Could not find the remote head to rebase onto - fix branch.%s.merge in .git/config' % crt_series.get_name()\n \n-        rebase(target)\n+        rebase(crt_series, target)\n     elif policy == 'rebase':\n-        rebase(crt_series.get_parent_branch())\n+        rebase(crt_series, crt_series.get_parent_branch())\n \n-    post_rebase(applied, options.nopush, options.merged)\n+    post_rebase(crt_series, applied, options.nopush, options.merged)\n \n     # maybe tidy up\n     if config.get('stgit.keepoptimized') == 'yes':\n         git.repack()\n \n-    print_crt_patch()\n+    print_crt_patch(crt_series)\ndiff --git a/stgit/commands/push.py b/stgit/commands/push.py\nindex 4d5de26..979835b 100644\n--- a/stgit/commands/push.py\n+++ b/stgit/commands/push.py\n@@ -72,13 +72,13 @@ def func(parser, options, args):\n             out.done()\n         else:\n             out.done('patch unchanged')\n-        print_crt_patch()\n+        print_crt_patch(crt_series)\n \n         return\n \n     check_local_changes()\n     check_conflicts()\n-    check_head_top_equal()\n+    check_head_top_equal(crt_series)\n \n     unapplied = crt_series.get_unapplied()\n     if not unapplied:\n@@ -99,6 +99,6 @@ def func(parser, options, args):\n     if options.reverse:\n         patches.reverse()\n \n-    push_patches(patches, options.merged)\n+    push_patches(crt_series, patches, options.merged)\n \n-    print_crt_patch()\n+    print_crt_patch(crt_series)\ndiff --git a/stgit/commands/rebase.py b/stgit/commands/rebase.py\nindex bbb3e12..c4d74b7 100644\n--- a/stgit/commands/rebase.py\n+++ b/stgit/commands/rebase.py\n@@ -48,14 +48,14 @@ def func(parser, options, args):\n \n     check_local_changes()\n     check_conflicts()\n-    check_head_top_equal()\n+    check_head_top_equal(crt_series)\n \n     # ensure an exception is raised before popping on non-existent target\n-    if git_id(args[0]) == None:\n+    if git_id(crt_series, args[0]) == None:\n         raise GitException, 'Unknown revision: %s' % args[0]\n         \n-    applied = prepare_rebase()\n-    rebase(args[0])\n-    post_rebase(applied, options.nopush, options.merged)\n+    applied = prepare_rebase(crt_series)\n+    rebase(crt_series, args[0])\n+    post_rebase(crt_series, applied, options.nopush, options.merged)\n \n-    print_crt_patch()\n+    print_crt_patch(crt_series)\ndiff --git a/stgit/commands/refresh.py b/stgit/commands/refresh.py\nindex f032375..7cde392 100644\n--- a/stgit/commands/refresh.py\n+++ b/stgit/commands/refresh.py\n@@ -73,7 +73,7 @@ def func(parser, options, args):\n             raise CmdException, 'No patches applied'\n \n     if not options.force:\n-        check_head_top_equal()\n+        check_head_top_equal(crt_series)\n \n     if options.undo:\n         out.start('Undoing the refresh of \"%s\"' % patch)\n@@ -89,10 +89,10 @@ def func(parser, options, args):\n         if options.patch:\n             applied = crt_series.get_applied()\n             between = applied[:applied.index(patch):-1]\n-            pop_patches(between, keep = True)\n+            pop_patches(crt_series, between, keep = True)\n         elif options.update:\n-            rev1 = git_id('//bottom')\n-            rev2 = git_id('//top')\n+            rev1 = git_id(crt_series, '//bottom')\n+            rev2 = git_id(crt_series, '//top')\n             patch_files = git.barefiles(rev1, rev2).split('\\n')\n             files = [f for f in files if f in patch_files]\n             if not files:\n@@ -113,7 +113,7 @@ def func(parser, options, args):\n \n         if options.patch:\n             between.reverse()\n-            push_patches(between)\n+            push_patches(crt_series, between)\n     elif options.annotate:\n         # only annotate the top log entry as there is no need to\n         # refresh the patch and generate a full commit\ndiff --git a/stgit/commands/series.py b/stgit/commands/series.py\nindex 2c75876..4c6d07e 100644\n--- a/stgit/commands/series.py\n+++ b/stgit/commands/series.py\n@@ -195,12 +195,13 @@ def func(parser, options, args):\n             raise CmdException, '--graphical not supported with --missing'\n \n         if applied:\n-            gitk_args = ' %s^..%s' % (git_id(applied[0]), git_id(applied[-1]))\n+            gitk_args = ' %s^..%s' % (git_id(crt_series, applied[0]),\n+                                      git_id(crt_series, applied[-1]))\n         else:\n             gitk_args = ''\n \n         for p in unapplied:\n-            patch_id = git_id(p)\n+            patch_id = git_id(crt_series, p)\n             gitk_args += ' %s^..%s' % (patch_id, patch_id)\n \n         if os.system('gitk%s' % gitk_args) != 0:\ndiff --git a/stgit/commands/show.py b/stgit/commands/show.py\nindex 7efb4e1..e4e70a5 100644\n--- a/stgit/commands/show.py\n+++ b/stgit/commands/show.py\n@@ -69,7 +69,7 @@ def func(parser, options, args):\n     else:\n         diff_flags = []\n \n-    commit_ids = [git_id(patch) for patch in patches]\n+    commit_ids = [git_id(crt_series, patch) for patch in patches]\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:\ndiff --git a/stgit/commands/sink.py b/stgit/commands/sink.py\nindex 737dde0..b177337 100644\n--- a/stgit/commands/sink.py\n+++ b/stgit/commands/sink.py\n@@ -45,7 +45,7 @@ def func(parser, options, args):\n \n     check_local_changes()\n     check_conflicts()\n-    check_head_top_equal()\n+    check_head_top_equal(crt_series)\n \n     oldapplied = crt_series.get_applied()\n     unapplied = crt_series.get_unapplied()\n@@ -61,10 +61,10 @@ def func(parser, options, args):\n         patches = [ crt_series.get_current() ]\n \n     crt_series.pop_patch(options.to or oldapplied[0])\n-    push_patches(patches)\n+    push_patches(crt_series, patches)\n \n     if not options.nopush:\n         newapplied = crt_series.get_applied()\n         def not_reapplied_yet(p):\n             return not p in newapplied\n-        push_patches(filter(not_reapplied_yet, oldapplied))\n+        push_patches(crt_series, filter(not_reapplied_yet, oldapplied))\ndiff --git a/stgit/commands/sync.py b/stgit/commands/sync.py\nindex 8a31c29..6066f82 100644\n--- a/stgit/commands/sync.py\n+++ b/stgit/commands/sync.py\n@@ -51,7 +51,7 @@ options = [make_option('-a', '--all',\n def __check_all():\n     check_local_changes()\n     check_conflicts()\n-    check_head_top_equal()\n+    check_head_top_equal(crt_series)\n \n def __branch_merge_patch(remote_series, pname):\n     \"\"\"Merge a patch from a remote branch into the current tree.\n@@ -131,13 +131,13 @@ def func(parser, options, args):\n     # pop to the one before the first patch to be synchronised\n     popped = applied[applied.index(sync_patches[0]) + 1:]\n     if popped:\n-        pop_patches(popped[::-1])\n+        pop_patches(crt_series, popped[::-1])\n \n     for p in sync_patches:\n         if p in popped:\n             # push to this patch\n             idx = popped.index(p) + 1\n-            push_patches(popped[:idx])\n+            push_patches(crt_series, popped[:idx])\n             del popped[:idx]\n \n         # the actual sync\n@@ -166,4 +166,4 @@ def func(parser, options, args):\n \n     # push the remaining patches\n     if popped:\n-        push_patches(popped)\n+        push_patches(crt_series, popped)\ndiff --git a/stgit/commands/uncommit.py b/stgit/commands/uncommit.py\nindex a23ae20..8e62d23 100644\n--- a/stgit/commands/uncommit.py\n+++ b/stgit/commands/uncommit.py\n@@ -66,7 +66,7 @@ def func(parser, options, args):\n         if len(args) != 0:\n             parser.error('cannot specify patch name with --to')\n         patch_nr = patchnames = None\n-        to_commit = git_id(options.to)\n+        to_commit = git_id(crt_series, options.to)\n     elif options.number:\n         if options.number <= 0:\n             parser.error('invalid value passed to --number')\ndiff --git a/stgit/main.py b/stgit/main.py\nindex db327f1..e8242c2 100644\n--- a/stgit/main.py\n+++ b/stgit/main.py\n@@ -277,7 +277,6 @@ def main():\n                 command.crt_series = Series(options.branch)\n             else:\n                 command.crt_series = Series()\n-            stgit.commands.common.crt_series = command.crt_series\n \n         command.func(parser, options, args)\n     except (StgException, IOError, ParsingError, NoSectionError), err:\n"},{"id":"55175","messageId":"20071008085540.9734.60137.stgit@yoghurt","threadId":"10190","inReplyTo":"20071008085430.9734.75797.stgit@yoghurt","subject":"[StGit PATCH 6/6] Let some commands work with detached HEAD","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2007-10-08T08:55:41Z","receivedAt":"2007-10-08T08:55:41Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"add, diff, resolved, and status didn't use the crt_series that was\ninitialized for them. So don't initialize it, since that means (1)\nless work and (2) they won't fail when HEAD is detached.\n\nNote that this doesn't completely fix the problem with detached HEAD:\na number of other commands (e.g. branch) don't always need to refer to\na current series, but currently fails on a detached HEAD even in those\nsituations.\n\nSigned-off-by: Karl Hasselström <kha@treskal.com>\n\n---\n\n stgit/commands/add.py      |    2 +-\n stgit/commands/diff.py     |    2 +-\n stgit/commands/resolved.py |    2 +-\n stgit/commands/status.py   |    2 +-\n 4 files changed, 4 insertions(+), 4 deletions(-)\n\n\ndiff --git a/stgit/commands/add.py b/stgit/commands/add.py\nindex 264ab9f..ceea188 100644\n--- a/stgit/commands/add.py\n+++ b/stgit/commands/add.py\n@@ -31,7 +31,7 @@ Add the files or directories passed as arguments to the\n repository. When a directory name is given, all the files and\n subdirectories are recursively added.\"\"\"\n \n-directory = DirectoryHasRepository()\n+directory = DirectoryHasRepository(needs_current_series = False)\n options = []\n \n \ndiff --git a/stgit/commands/diff.py b/stgit/commands/diff.py\nindex 42e8367..9ffbb4a 100644\n--- a/stgit/commands/diff.py\n+++ b/stgit/commands/diff.py\n@@ -42,7 +42,7 @@ rev = '([patch][//[bottom | top]]) | <tree-ish> | base'\n If neither bottom nor top are given but a '//' is present, the command\n shows the specified patch (defaulting to the current one).\"\"\"\n \n-directory = DirectoryHasRepository()\n+directory = DirectoryHasRepository(needs_current_series = False)\n options = [make_option('-r', '--range',\n                        metavar = 'rev1[..[rev2]]', dest = 'revs',\n                        help = 'show the diff between revisions'),\ndiff --git a/stgit/commands/resolved.py b/stgit/commands/resolved.py\nindex c2ef678..8b2aba2 100644\n--- a/stgit/commands/resolved.py\n+++ b/stgit/commands/resolved.py\n@@ -34,7 +34,7 @@ Mark a merge conflict as resolved. The conflicts can be seen with the\n 'C'. This command also removes any <file>.{ancestor,current,patched}\n files.\"\"\"\n \n-directory = DirectoryHasRepository()\n+directory = DirectoryHasRepository(needs_current_series = False)\n options = [make_option('-a', '--all',\n                        help = 'mark all conflicts as solved',\n                        action = 'store_true'),\ndiff --git a/stgit/commands/status.py b/stgit/commands/status.py\nindex a688f7e..360fabf 100644\n--- a/stgit/commands/status.py\n+++ b/stgit/commands/status.py\n@@ -40,7 +40,7 @@ under revision control. The files are prefixed as follows:\n A 'refresh' command clears the status of the modified, new and deleted\n files.\"\"\"\n \n-directory = DirectoryHasRepository()\n+directory = DirectoryHasRepository(needs_current_series = False)\n options = [make_option('-m', '--modified',\n                        help = 'show modified files only',\n                        action = 'store_true'),\n"},{"id":"55176","messageId":"20071008085830.GA7983@diana.vm.bytemark.co.uk","threadId":"10190","inReplyTo":"20071008085430.9734.75797.stgit@yoghurt","subject":"Re: [StGit PATCH 0/6] Survive capital punishment","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2007-10-08T08:58:30Z","receivedAt":"2007-10-08T08:58:30Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2007-10-08 10:55:02 +0200, Karl Hasselström wrote:\n\n> Karl Hasselström (6):\n>       Let some commands work with detached HEAD\n>       Don't have a global crt_series in stgit.commans.common\n>       Refactor crt_series creation\n>       Properly detect that HEAD is detached\n>       Use our nice message printout wrapping system\n>       Allow caller to customize title of error/warning message\n\nWill be available from\n\n  git://repo.or.cz/stgit/kha.git safe\n\nmomentarily (I just need to rebase the experimental branch on top of\nit).\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"55178","messageId":"20071008092723.GA8709@diana.vm.bytemark.co.uk","threadId":"10190","inReplyTo":"20071008085830.GA7983@diana.vm.bytemark.co.uk","subject":"Re: [StGit PATCH 0/6] Survive capital punishment","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2007-10-08T09:27:23Z","receivedAt":"2007-10-08T09:27:23Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2007-10-08 10:58:30 +0200, Karl Hasselström wrote:\n\n> Will be available from\n>\n>   git://repo.or.cz/stgit/kha.git safe\n>\n> momentarily (I just need to rebase the experimental branch on top of\n> it).\n\nThere; both safe and experimental are updated. (It takes a while to\nrebase when you run the test suite for every patch ...)\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"55196","messageId":"20071008153450.GA12247@diana.vm.bytemark.co.uk","threadId":"10190","inReplyTo":"20071008085540.9734.60137.stgit@yoghurt","subject":"Re: [StGit PATCH 6/6] Let some commands work with detached HEAD","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2007-10-08T15:34:50Z","receivedAt":"2007-10-08T15:34:50Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2007-10-08 10:55:41 +0200, Karl Hasselström wrote:\n\n> --- a/stgit/commands/diff.py\n> +++ b/stgit/commands/diff.py\n> @@ -42,7 +42,7 @@ rev = '([patch][//[bottom | top]]) | <tree-ish> | base'\n>  If neither bottom nor top are given but a '//' is present, the command\n>  shows the specified patch (defaulting to the current one).\"\"\"\n>  \n> -directory = DirectoryHasRepository()\n> +directory = DirectoryHasRepository(needs_current_series = False)\n>  options = [make_option('-r', '--range',\n>                         metavar = 'rev1[..[rev2]]', dest = 'revs',\n>                         help = 'show the diff between revisions'),\n\nThis hunk shouldn't be here, since diff does use crt_series. (The\ncommit message also has to be modified accordingly.)\n\nSo, we don't have a single test that tries to run \"stg diff\". Duh.\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"55225","messageId":"20071009044149.26624.11429.stgit@yoghurt","threadId":"10190","inReplyTo":"20071008153450.GA12247@diana.vm.bytemark.co.uk","subject":"[StGit PATCH] New test: \"stg diff\"","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2007-10-09T04:42:37Z","receivedAt":"2007-10-09T04:42:37Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"A simple test to make sure that we can run \"stg diff\" without\narguments, just to list local changes.\n\nNote that two subtests currently fail; these are due to plain \"stg\ndiff\" failing on a branch where \"stg init\" hasn't been run, which is\nplainly a bug.\n\nSigned-off-by: Karl Hasselström <kha@treskal.com>\n\n---\n\nOn 2007-10-08 17:34:50 +0200, Karl Hasselström wrote:\n\n> So, we don't have a single test that tries to run \"stg diff\". Duh.\n\n\n t/t2400-diff.sh |   37 +++++++++++++++++++++++++++++++++++++\n 1 files changed, 37 insertions(+), 0 deletions(-)\n create mode 100755 t/t2400-diff.sh\n\n\ndiff --git a/t/t2400-diff.sh b/t/t2400-diff.sh\nnew file mode 100755\nindex 0000000..6d9ed98\n--- /dev/null\n+++ b/t/t2400-diff.sh\n@@ -0,0 +1,37 @@\n+#!/bin/sh\n+\n+test_description='Run \"stg diff\"'\n+\n+. ./test-lib.sh\n+\n+test_expect_failure 'Diff with no StGit data' '\n+    stg diff\n+'\n+\n+test_expect_success 'Make some local changes' '\n+    echo foo >> foo.txt &&\n+    git add foo.txt\n+'\n+\n+test_expect_failure 'Diff with some local changes' '\n+    stg diff\n+'\n+\n+test_expect_success 'Initialize StGit stuff' '\n+    stg init &&\n+    stg new foo -m foo\n+'\n+\n+test_expect_success 'Diff with some local changes' '\n+    stg diff\n+'\n+\n+test_expect_success 'Refresh patch' '\n+    stg refresh\n+'\n+\n+test_expect_success 'Diff with no local changes' '\n+    stg diff\n+'\n+\n+test_done\n"},{"id":"55227","messageId":"20071009051247.GA22750@diana.vm.bytemark.co.uk","threadId":"10190","inReplyTo":"20071008153450.GA12247@diana.vm.bytemark.co.uk","subject":"Re: [StGit PATCH 6/6] Let some commands work with detached HEAD","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2007-10-09T05:12:47Z","receivedAt":"2007-10-09T05:12:47Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2007-10-08 17:34:50 +0200, Karl Hasselström wrote:\n\n> This hunk shouldn't be here, since diff does use crt_series. (The\n> commit message also has to be modified accordingly.)\n\nI've fixed the patch and pushed it out, along with the two new ones.\nFor good measure, I also demoted it from safe to experimental.\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"}]}