From: Tomi Ollila Date: Mon, 19 Jan 2015 09:44:16 +0000 (+0200) Subject: Re: [PATCH v4] nmbug: Add an 'init' command X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e122f24d931dfaac134480d983659f9185e44a8a;p=notmuch-archives.git Re: [PATCH v4] nmbug: Add an 'init' command --- diff --git a/5b/bf17c85a379e8375b71dac9cab30173b33c3b3 b/5b/bf17c85a379e8375b71dac9cab30173b33c3b3 new file mode 100644 index 000000000..db23f3b16 --- /dev/null +++ b/5b/bf17c85a379e8375b71dac9cab30173b33c3b3 @@ -0,0 +1,191 @@ +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 991A3431FB6 + for ; Mon, 19 Jan 2015 01:44:48 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 2.438 +X-Spam-Level: ** +X-Spam-Status: No, score=2.438 tagged_above=-999 required=5 + tests=[DNS_FROM_AHBL_RHSBL=2.438] 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 4W8muZ0hLuck for ; + Mon, 19 Jan 2015 01:44:44 -0800 (PST) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id 82E5F431FAF + for ; Mon, 19 Jan 2015 01:44:44 -0800 (PST) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id 13C8F1000E0; + Mon, 19 Jan 2015 11:44:17 +0200 (EET) +From: Tomi Ollila +To: "W. Trevor King" , notmuch@notmuchmail.org +Subject: Re: [PATCH v4] nmbug: Add an 'init' command +In-Reply-To: + +References: + +User-Agent: Notmuch/0.19+29~g7367d27 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +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: Mon, 19 Jan 2015 09:44:48 -0000 + +On Mon, Jan 19 2015, "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). + +I agree with this... + +I attempted to try this (being stup^H^H^H^Hadventurous and not backupping +~/.nmbug -- should the existence be checked first ???) and got the followin= +g ;/ + +$ python2.7 devel/nmbug/nmbug init +Reinitialized existing Git repository in /home/too/.nmbug/ +e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 +user.name not defined +[u'git', u'--git-dir', u'/home/too/.nmbug', u'commit', u'--allow-empty', +u'-m', u'Start a new nmbug repository'] exited with 1 +zsh: exit 1 python2.7 devel/nmbug/nmbug init + +This is due to my default /path/to/git-templates/pre-commit forbidding +commits unless I've configured user.name & user.email for that particular +repository.... + +I guess there is not much one can do to handle users' mystic global +hooks -- I'll look (later) whether e.g. '--no-hooks' parameter could be giv= +en +to nmbug from command line... + +... Ok, it was --no-verify and patching that to the command line worked -- +git complained that "Your name and email address were configured +automatically based on your username and hostname..." but commit succeeded = +:). + +... but Now I issued nmbug init twice. now there are 2=20 + + Start a new nmbug repository + +commits. I think it should be checked so that init on already-existing +repository does not succeed. + + +Tomi + +> +> The --bare init and use of NMBGIT as the work tree (what could go +> wrong with an empty commit?) are suggestions from Michal Sojka [2]. +> +> [1]: id:87y4vu6uvf.fsf@maritornes.cs.unb.ca +> http://thread.gmane.org/gmane.mail.notmuch.general/18626/focus=3D187= +20 +> [2]: id:87a93a5or2.fsf@resox.2x.cz +> http://thread.gmane.org/gmane.mail.notmuch.general/19495/focus=3D197= +67 +> --- +> Since v3 [1] I've incorporated Michal's suggestions [2]: +> +> * Start with 'git --git-dir {NMBGIT} init --bare +> * Use NMBGIT instead of a temporary workdir when creating the initial +> =E2=80=9CStart a new nmbug repository=E2=80=9D commit. +> +> As well as the core.logallrefupdates tweak I turned up in testing [3]. +> +> [1]: id:113512958b3fd64902517c1c55576faef816f852.1414532174.git.wking@tre= +mily.us +> http://thread.gmane.org/gmane.mail.notmuch.general/19495 +> [2]: id:87a93a5or2.fsf@resox.2x.cz +> http://thread.gmane.org/gmane.mail.notmuch.general/19495/focus=3D197= +67 +> [3]: id:20141129201829.GI4062@odin.tremily.us +> http://thread.gmane.org/gmane.mail.notmuch.general/19495/focus=3D197= +74 +> +> devel/nmbug/nmbug | 20 ++++++++++++++++++++ +> 1 file changed, 20 insertions(+) +> +> diff --git a/devel/nmbug/nmbug b/devel/nmbug/nmbug +> index 932ec12..1297345 100755 +> --- a/devel/nmbug/nmbug +> +++ b/devel/nmbug/nmbug +> @@ -374,6 +374,25 @@ 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. +> + """ +> + _spawn(args=3D['git', '--git-dir', NMBGIT, 'init', '--bare'], wait= +=3DTrue) +> + _git(args=3D['config', 'core.logallrefupdates', 'true'], wait=3DTrue) +> + # create an empty blob (e69de29bb2d1d6434b8b29ae775ad8c2e48c5391) +> + _git(args=3D['hash-object', '-w', '--stdin'], input=3D'', wait=3DTru= +e) +> + _git( +> + args=3D[ +> + 'commit', '--allow-empty', '-m', 'Start a new nmbug reposito= +ry' +> + ], +> + additional_env=3D{'GIT_WORK_TREE': NMBGIT}, +> + wait=3DTrue) +> + +> + +> def checkout(): +> """ +> Update the notmuch database from Git. +> @@ -725,6 +744,7 @@ if __name__ =3D=3D '__main__': +> 'commit', +> 'fetch', +> 'help', +> + 'init', +> 'log', +> 'merge', +> 'pull', +> --=20 +> 2.1.0.60.g85f0837