From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id MMcnEzaVm2LQTgEAbAwnHQ (envelope-from ) for ; Sat, 04 Jun 2022 19:24:06 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id mFw1EjaVm2J8kgAAG6o9tA (envelope-from ) for ; Sat, 04 Jun 2022 19:24:06 +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 DC1051CB6F for ; Sat, 4 Jun 2022 19:24:05 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 83B765F7E2; Sat, 4 Jun 2022 17:23:39 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id DC1CA5F7DA for ; Sat, 4 Jun 2022 17:23:35 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id 0CC6F5FC2C; Sat, 4 Jun 2022 13:23:34 -0400 (EDT) Received: (nullmailer pid 1150065 invoked by uid 1000); Sat, 04 Jun 2022 17:23:25 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH v3 05/17] CLI/git: Add an 'init' command Date: Sat, 4 Jun 2022 14:23:01 -0300 Message-Id: <20220604172313.1149879-6-david@tethera.net> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20220604172313.1149879-1-david@tethera.net> References: <20220604172313.1149879-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: CTAJRMUKYGWY7MWLKHN3LSXRLZ25JFCJ X-Message-ID-Hash: CTAJRMUKYGWY7MWLKHN3LSXRLZ25JFCJ 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=1654363445; 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=dU7kJMpLD3aXBizuLb1OK+mxVoQ1+mCs7U5gpmAGxmo=; b=KGmxvB6x5GQeoJeLmhCdPlXn2bSueEYhTsEgbPxh97On6JV8ygKVp7L3Gw3Vc0OjaYEo7b lPU7eltiW0QZ5vMWUv5Qsn1tGQ83HeP3SuYukphD3apB8kGIu4rS/JXDZSDO50FR9tClSF bD8aJJR7vZVRk4rWFbeUyj/12OHV5nbm5kA34FhemJkLuoqG2cbxytFwPuOw3Osrc9iFb6 21i2pLGbDQ0tsrwluyqS/b5DVKUo2HhMau66RBJeHeQfXgM8DJoKXRxPlprb6MBozyqfxx XVgO/w3X5Tp6wzXYheUXC9txzk7CN6UpR77693AWqS4YeWUdO9a5tZBd0p8oDA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1654363445; a=rsa-sha256; cv=none; b=gPni7RL1q2yVUH19ykk1YtTj8hXrz4zIRQARLzF+szonN/yZ+c9BFTCVR7kZ+pq40zKhrP kuam1VAkf7NaUVyRpiMuumqJ52toi14uiTWYCXo2pVUBAnhVOJnPDHZhi+fe/PrE+UJ5Im Q2KAkOEoVcmVRyQNuY1q2LoLQ8WsEZwiSwHUoPBB8ph123Cg1R5+pePp5myLH/EKpBfPDH HLw4FWoPsTdkyJ31Uex/VGJnpjEam+tx0Ex4g4mjK6MpS7kcxy5eQ8NAlCX/SZyBhBn/7e GRmjAT6x47xzn0FmCqCRX7QgW56NdOhBj36st9R3rLTg4XXzBJC1Qdy6HQ0Sqw== 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: -1.55 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: DC1051CB6F X-Spam-Score: -1.55 X-Migadu-Scanner: scn0.migadu.com X-TUID: lGnlISee89T/ 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.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/notmuch-git.py b/notmuch-git.py index 0cbfec61..ce3c07bb 100644 --- a/notmuch-git.py +++ b/notmuch-git.py @@ -351,6 +351,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. @@ -711,6 +730,7 @@ if __name__ == '__main__': 'commit', 'fetch', 'help', + 'init', 'log', 'merge', 'pull', -- 2.35.2