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 162F2431FCF for ; Fri, 10 Oct 2014 11:31:40 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.1 X-Spam-Level: X-Spam-Status: No, score=-0.1 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-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 xYhdcFGcZuC4 for ; Fri, 10 Oct 2014 11:31:32 -0700 (PDT) Received: from resqmta-po-09v.sys.comcast.net (resqmta-po-09v.sys.comcast.net [96.114.154.168]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 205DD431FBC for ; Fri, 10 Oct 2014 11:31:32 -0700 (PDT) Received: from resomta-po-03v.sys.comcast.net ([96.114.154.227]) by resqmta-po-09v.sys.comcast.net with comcast id 1WX91p0074ueUHc01WXX0y; Fri, 10 Oct 2014 18:31:31 +0000 Received: from odin.tremily.us ([24.18.63.50]) by resomta-po-03v.sys.comcast.net with comcast id 1WXV1p00N152l3L01WXWFa; Fri, 10 Oct 2014 18:31:31 +0000 Received: by odin.tremily.us (Postfix, from userid 1000) id C8D29141181B; Fri, 10 Oct 2014 11:31:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tremily.us; s=odin; t=1412965888; bh=OHjjnlARVlLbrQNjHDa3IrS4SFCojkp6DOAFewgLaCs=; h=From:To:Cc:Subject:Date; b=Xp9aI3g52MyXGGG5xMfpNE1kPwgOHMSot356kNIxJVD/O595gF/kDM1Xs5ClZd/Qg zzsXPup/a8VMBbf6YC5RiFZ/Cbx7aTMlEnDnwbRXp7kK8YYnlrqC4XHCfwax5LRoOh hBMeP9lOer7rTW4IUz+Bs/VpDay0i2S82MLmViOY= From: "W. Trevor King" To: notmuch@notmuchmail.org Subject: [PATCH v2] nmbug: Add an 'init' command Date: Fri, 10 Oct 2014 11:31:25 -0700 Message-Id: X-Mailer: git-send-email 2.0.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1412965891; bh=KowNf8zl7lx8pl/m3ghpWHr/QG/vFi/U5E5x+NJ5h1g=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=Ws9INXanzvZFEz5RtLBUMSJIi8go6Tm89F5YPWteustyHc5hVDtUcuIP7XttdwWyt ou6N+hM8ldqjgjKWuVhlJpWDRgroMZTpMQyPU8IkjO9hO29c9yrKKrlsCFkfB3J5Yx KnA4rctzdElhxr6Ml7WkqmGXTvBjIZAT/RbAkja5ZwTm+08CR0JZLqG0Tqgk06CRvj v3c0b6Oe/shklYeOSMKJjjuJ5Tl4eVpopRY7Cm4X4wmhW/AwRjOVJKujFCyAJBSEOB 7yWPYJsfDZnF6HOvcZgT1h7LTmamqXHfjVXDEwSB6/JDiYcLEXhbEHRzfI+a4uGg43 U9M1hGlYV33HA== 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: Fri, 10 Oct 2014 18:31:40 -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. [1]: id:87y4vu6uvf.fsf@maritornes.cs.unb.ca http://thread.gmane.org/gmane.mail.notmuch.general/18626/focus=18720 --- This is just like v1 [1], but rebased into the new Python nmbug. I'd initially supported the /dev/null approach [2], but have since gone back to my original --stdin approach for the empty blob object (as explained in the commit message). Sorry for waffling ;). Cheers, Trevor [1]: id:05ccd672f55444f74da62250e2305fb84fdc6c42.1404678709.git.wking@tremily.us http://thread.gmane.org/gmane.mail.notmuch.general/18626/focus=18630 [2]: id:20140716001239.GH30232@odin http://article.gmane.org/gmane.mail.notmuch.general/18722 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