From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.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 eEWkOcFDgWJCFQEAbAwnHQ (envelope-from ) for ; Sun, 15 May 2022 20:17:38 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id UFihOMFDgWL9MgEAG6o9tA (envelope-from ) for ; Sun, 15 May 2022 20:17:37 +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 4AF23119E8 for ; Sun, 15 May 2022 20:17:37 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 089565F741; Sun, 15 May 2022 18:17:20 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 5E8835F708 for ; Sun, 15 May 2022 18:17:17 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id A5DF45FBD7; Sun, 15 May 2022 14:17:16 -0400 (EDT) Received: (nullmailer pid 57812 invoked by uid 1000); Sun, 15 May 2022 18:17:13 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 05/17] CLI/git: Add an 'init' command Date: Sun, 15 May 2022 15:14:10 -0300 Message-Id: <20220515181421.57088-6-david@tethera.net> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20220515181421.57088-1-david@tethera.net> References: <20220515181421.57088-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: CUHD53RSRPV64KCAYDP7QKVZ7V7I6WLZ X-Message-ID-Hash: CUHD53RSRPV64KCAYDP7QKVZ7V7I6WLZ 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=1652638657; 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=3RD8yUmRFq2BzdeCwYI2bweDhkYxuO9ae9jmej5a/D0=; b=gmwagEnPC3qsn01wqHM55s1pa0O1bu7edHjVJGP9YxpzWeN433DpDVeUoIgya6zo08bciV ryOMf0H8+MwL/mk8kZv0o/ltnY8WB3i9IprDdl+tyuOe0GhGaYJa+YbGunVndLnGVWx1+F RuJRrjPvr9Zk4i0v08pW3eyIz4lnWu+4gIxUWWLMeiHzTsXM1H1hk4cg6VNC1rEt7cjHcp cAAjXNx97qZ8g2YHKjKATfeXlPmbFE+IR9WIaHWr0gAZ7ZbFzb6I3NT8qEmeNyOJvtqeRN JEWv0sH/HVBbWddppJed3KvMAfEmo+dbj2A4rU2W0mOWyO56Bf03Z7thQLd3pg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1652638657; a=rsa-sha256; cv=none; b=IF44oTNjFX5kTuryfPuj7Y6JGQdqAvVPr9DgXS4bn3alFYXTE71bjb4/SnhHJH0RER7CQU t5Kbf2QMbJwjF/N6fi/GXUnRgoKwAfNWKM5YhqPDQkK5Ee39Pfrkr+XeG5BfA0ThLAb6oN A+T6lnxKK6cE4fy/gKLiaspJtIUZPJgAFcRnjhsgLibDIzfc3z3rueymzi5vIvqvbXPG5C ASxrshHvqZnVL/+ZNUuFxEtt+StN2qUN5rhU4w60+a5wR3fh4kKADVSdDYnHd3MPyKKLe1 i4o8lTMHKgqrjSlLwL/boGEDppOCizgRpJoVGyqXmx9D/Irto9sDdM844EE1eQ== 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.95 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: 4AF23119E8 X-Spam-Score: -0.95 X-Migadu-Scanner: scn1.migadu.com X-TUID: 6f39YMU24VSf 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 57b5a0ec..71a4df72 100755 --- a/notmuch-git.in +++ b/notmuch-git.in @@ -353,6 +353,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. @@ -716,6 +735,7 @@ if __name__ == '__main__': 'commit', 'fetch', 'help', + 'init', 'log', 'merge', 'pull', -- 2.35.2