[PATCH v2] nmbug: Add an 'init' command
authorW. Trevor King <wking@tremily.us>
Fri, 10 Oct 2014 18:31:25 +0000 (11:31 +1700)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:05:12 +0000 (10:05 -0800)
dd/60aaef9e895beaa5c204b2b90ea12380ab5ad2 [new file with mode: 0644]

diff --git a/dd/60aaef9e895beaa5c204b2b90ea12380ab5ad2 b/dd/60aaef9e895beaa5c204b2b90ea12380ab5ad2
new file mode 100644 (file)
index 0000000..e106feb
--- /dev/null
@@ -0,0 +1,153 @@
+Return-Path: <wking@tremily.us>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 162F2431FCF\r
+       for <notmuch@notmuchmail.org>; Fri, 10 Oct 2014 11:31:40 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.1\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.1 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id xYhdcFGcZuC4 for <notmuch@notmuchmail.org>;\r
+       Fri, 10 Oct 2014 11:31:32 -0700 (PDT)\r
+Received: from resqmta-po-09v.sys.comcast.net (resqmta-po-09v.sys.comcast.net\r
+       [96.114.154.168])\r
+       (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 205DD431FBC\r
+       for <notmuch@notmuchmail.org>; Fri, 10 Oct 2014 11:31:32 -0700 (PDT)\r
+Received: from resomta-po-03v.sys.comcast.net ([96.114.154.227])\r
+       by resqmta-po-09v.sys.comcast.net with comcast\r
+       id 1WX91p0074ueUHc01WXX0y; Fri, 10 Oct 2014 18:31:31 +0000\r
+Received: from odin.tremily.us ([24.18.63.50])\r
+       by resomta-po-03v.sys.comcast.net with comcast\r
+       id 1WXV1p00N152l3L01WXWFa; Fri, 10 Oct 2014 18:31:31 +0000\r
+Received: by odin.tremily.us (Postfix, from userid 1000)\r
+       id C8D29141181B; Fri, 10 Oct 2014 11:31:28 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tremily.us; s=odin;\r
+       t=1412965888; bh=OHjjnlARVlLbrQNjHDa3IrS4SFCojkp6DOAFewgLaCs=;\r
+       h=From:To:Cc:Subject:Date;\r
+       b=Xp9aI3g52MyXGGG5xMfpNE1kPwgOHMSot356kNIxJVD/O595gF/kDM1Xs5ClZd/Qg\r
+       zzsXPup/a8VMBbf6YC5RiFZ/Cbx7aTMlEnDnwbRXp7kK8YYnlrqC4XHCfwax5LRoOh\r
+       hBMeP9lOer7rTW4IUz+Bs/VpDay0i2S82MLmViOY=\r
+From: "W. Trevor King" <wking@tremily.us>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2] nmbug: Add an 'init' command\r
+Date: Fri, 10 Oct 2014 11:31:25 -0700\r
+Message-Id:\r
+ <eaa9cf1cb3c00c591dc675c0f314ca31909ff74c.1412965476.git.wking@tremily.us>\r
+X-Mailer: git-send-email 2.0.4\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net;\r
+       s=q20140121; t=1412965891;\r
+       bh=KowNf8zl7lx8pl/m3ghpWHr/QG/vFi/U5E5x+NJ5h1g=;\r
+       h=Received:Received:Received:From:To:Subject:Date:Message-Id;\r
+       b=Ws9INXanzvZFEz5RtLBUMSJIi8go6Tm89F5YPWteustyHc5hVDtUcuIP7XttdwWyt\r
+       ou6N+hM8ldqjgjKWuVhlJpWDRgroMZTpMQyPU8IkjO9hO29c9yrKKrlsCFkfB3J5Yx\r
+       KnA4rctzdElhxr6Ml7WkqmGXTvBjIZAT/RbAkja5ZwTm+08CR0JZLqG0Tqgk06CRvj\r
+       v3c0b6Oe/shklYeOSMKJjjuJ5Tl4eVpopRY7Cm4X4wmhW/AwRjOVJKujFCyAJBSEOB\r
+       7yWPYJsfDZnF6HOvcZgT1h7LTmamqXHfjVXDEwSB6/JDiYcLEXhbEHRzfI+a4uGg43\r
+       U9M1hGlYV33HA==\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 10 Oct 2014 18:31:40 -0000\r
+\r
+For folks that want to start versioning a new tag-space, instead of\r
+cloning one that someone else has already started.\r
+\r
+The empty-blob hash-object call avoids errors like:\r
+\r
+  $ nmbug commit\r
+  error: invalid object 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 for\r
+'tags/...'\r
+  fatal: git-write-tree: error building trees\r
+  'git HASH(0x9ef3eb8) write-tree' exited with nonzero value\r
+\r
+David Bremner suggested [1]:\r
+\r
+  $ git hash-object -w /dev/null\r
+\r
+instead of my Python version of:\r
+\r
+  $ git hash-object -w --stdin <&-\r
+\r
+but I expect that closing stdin is more portable than the /dev/null\r
+path.\r
+\r
+[1]: id:87y4vu6uvf.fsf@maritornes.cs.unb.ca\r
+     http://thread.gmane.org/gmane.mail.notmuch.general/18626/focus=18720\r
+---\r
+This is just like v1 [1], but rebased into the new Python nmbug.  I'd\r
+initially supported the /dev/null approach [2], but have since gone\r
+back to my original --stdin approach for the empty blob object (as\r
+explained in the commit message).  Sorry for waffling ;).\r
+\r
+Cheers,\r
+Trevor\r
+\r
+[1]: id:05ccd672f55444f74da62250e2305fb84fdc6c42.1404678709.git.wking@tremily.us\r
+     http://thread.gmane.org/gmane.mail.notmuch.general/18626/focus=18630\r
+[2]: id:20140716001239.GH30232@odin\r
+     http://article.gmane.org/gmane.mail.notmuch.general/18722\r
+ devel/nmbug/nmbug | 24 ++++++++++++++++++++++++\r
+ 1 file changed, 24 insertions(+)\r
+\r
+diff --git a/devel/nmbug/nmbug b/devel/nmbug/nmbug\r
+index 9402ead..23bac5c 100755\r
+--- a/devel/nmbug/nmbug\r
++++ b/devel/nmbug/nmbug\r
+@@ -373,6 +373,29 @@ def fetch(remote=None):\r
+     _git(args=args, wait=True)\r
\r
\r
++def init(remote=None):\r
++    """\r
++    Create an empty nmbug repository.\r
++\r
++    This wraps 'git init' with a few extra steps to support subsequent\r
++    status and commit commands.\r
++    """\r
++    with _tempfile.TemporaryDirectory(prefix='nmbug-init.') as workdir:\r
++        _spawn(\r
++            args=['git', 'init', '--separate-git-dir', NMBGIT, workdir],\r
++            wait=True)\r
++        _git(args=['config', '--unset', 'core.worktree'], wait=True)\r
++        _git(args=['config', 'core.bare', 'true'], wait=True)\r
++        # create an empty blob (e69de29bb2d1d6434b8b29ae775ad8c2e48c5391)\r
++        _git(args=['hash-object', '-w', '--stdin'], input='', wait=True)\r
++        _git(\r
++            args=[\r
++                'commit', '--allow-empty', '-m', 'Start a new nmbug repository'\r
++                ],\r
++            additional_env={'GIT_WORK_TREE': workdir},\r
++            wait=True)\r
++\r
++\r
+ def checkout():\r
+     """\r
+     Update the notmuch database from Git.\r
+@@ -703,6 +726,7 @@ if __name__ == '__main__':\r
+             'clone',\r
+             'commit',\r
+             'fetch',\r
++            'init',\r
+             'log',\r
+             'merge',\r
+             'pull',\r
+-- \r
+2.1.0.60.g85f0837\r
+\r