From 123042dbab4af1bef16b743fa51fc6d8cdcb46c7 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 29 Oct 2014 14:39:37 +1700 Subject: [PATCH] [PATCH v3] nmbug: Add an 'init' command --- 25/f9836e527fc9b45117d2753f2fc6cdee628370 | 153 ++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 25/f9836e527fc9b45117d2753f2fc6cdee628370 diff --git a/25/f9836e527fc9b45117d2753f2fc6cdee628370 b/25/f9836e527fc9b45117d2753f2fc6cdee628370 new file mode 100644 index 000000000..6e68285bb --- /dev/null +++ b/25/f9836e527fc9b45117d2753f2fc6cdee628370 @@ -0,0 +1,153 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 1F60B431FBC + for ; Tue, 28 Oct 2014 14:48:53 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id iVAmIUFyDb92 for ; + Tue, 28 Oct 2014 14:48:45 -0700 (PDT) +X-Greylist: delayed 489 seconds by postgrey-1.32 at olra; + Tue, 28 Oct 2014 14:48:45 PDT +Received: from resqmta-ch2-12v.sys.comcast.net + (resqmta-ch2-12v.sys.comcast.net [69.252.207.44]) + (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 9216D431FB6 + for ; Tue, 28 Oct 2014 14:48:45 -0700 (PDT) +Received: from resomta-ch2-14v.sys.comcast.net ([69.252.207.110]) + by resqmta-ch2-12v.sys.comcast.net with comcast + id 8lfU1p0032PT3Qt01lgaQd; Tue, 28 Oct 2014 21:40:34 +0000 +Received: from odin.tremily.us ([24.18.63.50]) + by resomta-ch2-14v.sys.comcast.net with comcast + id 8lgZ1p00D152l3L01lgZgP; Tue, 28 Oct 2014 21:40:34 +0000 +Received: from mjolnir.tremily.us (unknown [192.168.0.150]) + by odin.tremily.us (Postfix) with ESMTPS id 20379143B66A; + Tue, 28 Oct 2014 14:40:33 -0700 (PDT) +Received: (nullmailer pid 1649 invoked by uid 1000); + Tue, 28 Oct 2014 21:39:38 -0000 +From: "W. Trevor King" +To: notmuch@notmuchmail.org +Subject: [PATCH v3] nmbug: Add an 'init' command +Date: Tue, 28 Oct 2014 14:39:37 -0700 +Message-Id: + <113512958b3fd64902517c1c55576faef816f852.1414532174.git.wking@tremily.us> +X-Mailer: git-send-email 2.1.0.60.g85f0837 +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; + s=q20140121; t=1414532434; + bh=+b4338FE6AR4rbuk0tiZed9tdCuvDYau4XsVIfQaSS8=; + h=Received:Received:Received:Received:From:To:Subject:Date: + Message-Id; + b=umb8KtLVK0aQXSX+N5ME3pVChcKAeRn4cX0RpdnWz+bVihv6NQNsQMbB047priOvT + gpbfdUHc6oT2h6qiF/0rxko65/3fXvRh0orVmt5/Zw5KqLgnbbXa0BIqF4QdhUS1PV + 1nVC9plpRRT71FysS8O0rmPxSuLIhYMeysaCgHZdc7oVRbuZFryw10yFh99RFoQpB8 + qXKRWg3j6FLi5OuAhZXdsp0M6/Vzn7SIkdAxIpIySrP7jsk5BNzbgfMAqm0i5JuYPD + PYkXcJI3EyjeTzfIZerlsZqeA4Cpj1tzAlWNm5+8rxH6eAkScFrqEW90WINOPOiWie + nAV6QShzoroow== +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Tue, 28 Oct 2014 21:48:53 -0000 + +For folks that want to start versioning a new tag-space, instead of +cloning one that someone else has already started. + +The empty-blob hash-object call avoids errors like: + + $ nmbug commit + error: invalid object 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 for +'tags/...' + fatal: git-write-tree: error building trees + 'git HASH(0x9ef3eb8) write-tree' exited with nonzero value + +David Bremner suggested [1]: + + $ git hash-object -w /dev/null + +instead of my Python version of: + + $ git hash-object -w --stdin <&- + +but I expect that closing stdin is more portable than the /dev/null +path (which doesn't exist on Windows, for example). + +[1]: id:87y4vu6uvf.fsf@maritornes.cs.unb.ca + http://thread.gmane.org/gmane.mail.notmuch.general/18626/focus=18720 +--- +The only change since v2 [1] is a commit-message tweak: + +* Mention Windows as an OS with stdin but no /dev/null [2]. + +Cheers, +Trevor + +[1]: id:eaa9cf1cb3c00c591dc675c0f314ca31909ff74c.1412965476.git.wking@tremily.us + http://thread.gmane.org/gmane.mail.notmuch.general/19289 +[2]: id:20141011071000.GB10926@odin.tremily.us + http://article.gmane.org/gmane.mail.notmuch.general/19294 + + devel/nmbug/nmbug | 24 ++++++++++++++++++++++++ + 1 file changed, 24 insertions(+) + +diff --git a/devel/nmbug/nmbug b/devel/nmbug/nmbug +index 9402ead..23bac5c 100755 +--- a/devel/nmbug/nmbug ++++ b/devel/nmbug/nmbug +@@ -373,6 +373,29 @@ def fetch(remote=None): + _git(args=args, wait=True) + + ++def init(remote=None): ++ """ ++ Create an empty nmbug repository. ++ ++ This wraps 'git init' with a few extra steps to support subsequent ++ status and commit commands. ++ """ ++ with _tempfile.TemporaryDirectory(prefix='nmbug-init.') as workdir: ++ _spawn( ++ args=['git', 'init', '--separate-git-dir', NMBGIT, workdir], ++ wait=True) ++ _git(args=['config', '--unset', 'core.worktree'], wait=True) ++ _git(args=['config', 'core.bare', 'true'], wait=True) ++ # create an empty blob (e69de29bb2d1d6434b8b29ae775ad8c2e48c5391) ++ _git(args=['hash-object', '-w', '--stdin'], input='', wait=True) ++ _git( ++ args=[ ++ 'commit', '--allow-empty', '-m', 'Start a new nmbug repository' ++ ], ++ additional_env={'GIT_WORK_TREE': workdir}, ++ wait=True) ++ ++ + def checkout(): + """ + Update the notmuch database from Git. +@@ -703,6 +726,7 @@ if __name__ == '__main__': + 'clone', + 'commit', + 'fetch', ++ 'init', + 'log', + 'merge', + 'pull', +-- +2.1.0.60.g85f0837 + -- 2.26.2