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 19D43431FBF for ; Sat, 29 Nov 2014 02:17:09 -0800 (PST) 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=[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 LRSqvWindEKw for ; Sat, 29 Nov 2014 02:17:00 -0800 (PST) Received: from smtp.nextra.cz (smtp.nextra.cz [212.65.193.3]) by olra.theworths.org (Postfix) with ESMTP id 98F00431FAE for ; Sat, 29 Nov 2014 02:17:00 -0800 (PST) Received: from resox (unknown [213.29.198.144]) by smtp.nextra.cz (Postfix) with ESMTP id 5151C4A768; Sat, 29 Nov 2014 11:16:50 +0100 (CET) Received: from wsh by resox with local (Exim 4.84) (envelope-from ) id 1XueVV-0007F1-VH; Sat, 29 Nov 2014 10:40:01 +0100 From: Michal Sojka To: "W. Trevor King" , notmuch@notmuchmail.org Subject: Re: [PATCH v3] nmbug: Add an 'init' command In-Reply-To: <113512958b3fd64902517c1c55576faef816f852.1414532174.git.wking@tremily.us> References: <113512958b3fd64902517c1c55576faef816f852.1414532174.git.wking@tremily.us> User-Agent: Notmuch/0.19~rc1+7~gdb5e73a (http://notmuchmail.org) Emacs/24.4.1 (x86_64-pc-linux-gnu) Date: Sat, 29 Nov 2014 10:40:01 +0100 Message-ID: <87a93a5or2.fsf@resox.2x.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: Sat, 29 Nov 2014 10:17:09 -0000 Hi Trevor, On =C3=9At, =C5=99=C3=ADj 28 2014, W. Trevor King wrote: > 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 f= or > '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=3D187= 20 > --- > 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@tre= mily.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=3DNone): > _git(args=3Dargs, wait=3DTrue) >=20=20 >=20=20 > +def init(remote=3DNone): > + """ > + 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=3D'nmbug-init.') as workdir: > + _spawn( > + args=3D['git', 'init', '--separate-git-dir', NMBGIT, workdir= ], > + wait=3DTrue) > + _git(args=3D['config', '--unset', 'core.worktree'], wait=3DTrue) > + _git(args=3D['config', 'core.bare', 'true'], wait=3DTrue) Why do you create a non-bare repository and then make it bare? Before I discovered this patch, I created the nmbug repository by hand and it was possible to do it with bare repo from beginning. The following code seems to work and is a bit simpler: def init(remote=3DNone): """ Create an empty nmbug repository. This wraps 'git init' with a few extra steps to support subsequent status and commit commands. """ _spawn( args=3D['git', '--git-dir', NMBGIT, 'init', '--bare'], wait=3DTrue) # create an empty blob (e69de29bb2d1d6434b8b29ae775ad8c2e48c5391) _git(args=3D['hash-object', '-w', '--stdin'], input=3D'', wait=3DTrue) _git( args=3D[ 'commit', '--allow-empty', '-m', 'Start a new nmbug repository' ], additional_env=3D{'GIT_WORK_TREE': NMBGIT}, wait=3DTrue) Note that in the initial commit I set the work tree to NMBGIT. This is because 'git commit' needs some work tree, but in our case it doesn't matter which one because the commit is empty. -Michal > + # create an empty blob (e69de29bb2d1d6434b8b29ae775ad8c2e48c5391) > + _git(args=3D['hash-object', '-w', '--stdin'], input=3D'', wait= =3DTrue) > + _git( > + args=3D[ > + 'commit', '--allow-empty', '-m', 'Start a new nmbug repo= sitory' > + ], > + additional_env=3D{'GIT_WORK_TREE': workdir}, > + wait=3DTrue) > + > + > def checkout(): > """ > Update the notmuch database from Git. > @@ -703,6 +726,7 @@ if __name__ =3D=3D '__main__': > 'clone', > 'commit', > 'fetch', > + 'init', > 'log', > 'merge', > 'pull', > --=20 > 2.1.0.60.g85f0837 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch