From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id QHRUAb4BZGLrRAEAbAwnHQ (envelope-from ) for ; Sat, 23 Apr 2022 15:40:14 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id eE1SAb4BZGJPhQEAauVa8A (envelope-from ) for ; Sat, 23 Apr 2022 15:40:14 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A8FE915201 for ; Sat, 23 Apr 2022 15:40:13 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 84CBF5F79A; Sat, 23 Apr 2022 13:39:20 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 07C175F78E for ; Sat, 23 Apr 2022 13:39:18 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id 0861D5FC01; Sat, 23 Apr 2022 09:39:16 -0400 (EDT) Received: (nullmailer pid 3856552 invoked by uid 1000); Sat, 23 Apr 2022 13:38:57 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 05/16] nmbug: Add an 'init' command Date: Sat, 23 Apr 2022 10:38:37 -0300 Message-Id: <20220423133848.3852688-6-david@tethera.net> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20220423133848.3852688-1-david@tethera.net> References: <20220423133848.3852688-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: CNMTARHVHCGKPYT3JNKYBHFRYZL32ZG5 X-Message-ID-Hash: CNMTARHVHCGKPYT3JNKYBHFRYZL32ZG5 X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: "W. Trevor King" X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1650721213; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=pTHJhH4F3RXX/ObFVz97F78pHF9Bi6PTQRK9HFDTTuQ=; b=iqDaXEG78HAWanYqNN6SVkVxBFqU72pZ5M96h8CP3t8B/TkqWYQ0AfN00E3EUmPcnSFQTF UefafzRhv9TWJLw+t504632eDvh56c1CBSPWIUCOhOWL0dCV5EhsdYeTjKVyezHEAO+wDf j3Siypr6gNT+yb17Ci+HzJanEVxGeORqisBr59eqF1sQg49+r0Q3skyxCVGO+xDWkb0AQS 5zwkwmOAFAST46sNNjAaSeZaWMsN6S2mFDcBEfVF4y9PqssL7KHoAFMBue1BxsjFUFHNlJ tjUvAbHEm7FxgdWqiRcaxOkDKlXWj9jN8K87bUnhecbThvzrNGzpmGXohIVnTg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1650721213; a=rsa-sha256; cv=none; b=r9IOjvlyTe601K42UW59uYF9UtFBjJC3ieN38q+qz5fKMMX0c3id/1RUhdrrQCMo9ua32Z pbI6D9MhWIiQpggphQ1DC2TQIuLm735wiZwJz/aUmPRPpvQZvPEFsedVTR3vuIRnlDPJtN xdOeUvnEPOrwDfgo0YBHBOy/30onh3hXBFMpXxTpnPK18354EWq5Ey8BLqHaT98LQukGKM 20zJXzW4P6JEVjZji6g5nA2mTRpxK3gwcZBjJSLstlWDnyfJc/Pr+r2hqUfnl3z7liaOty ec3NbVhajjyNOkJAU1mspZz4MSmSQxdniDaoBgqN+Hjtmlc6CjAQ/uiXWbGNuA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -0.77 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: A8FE915201 X-Spam-Score: -0.77 X-Migadu-Scanner: scn1.migadu.com X-TUID: sDet/siDOjxE From: "W. Trevor King" 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). 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=18720 [2]: id:87a93a5or2.fsf@resox.2x.cz http://thread.gmane.org/gmane.mail.notmuch.general/19495/focus=19767 --- notmuch-git.in | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/notmuch-git.in b/notmuch-git.in index 81d604bb..d574f19e 100755 --- a/notmuch-git.in +++ b/notmuch-git.in @@ -377,6 +377,25 @@ 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. + """ + _spawn(args=['git', '--git-dir', NMBGIT, 'init', '--bare'], wait=True) + _git(args=['config', 'core.logallrefupdates', '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': NMBGIT}, + wait=True) + + def checkout(): """ Update the notmuch database from Git. @@ -740,6 +759,7 @@ if __name__ == '__main__': 'commit', 'fetch', 'help', + 'init', 'log', 'merge', 'pull', -- 2.35.2