unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: "W. Trevor King" <wking@tremily.us>
To: notmuch@notmuchmail.org
Subject: [PATCH v4] nmbug: Add an 'init' command
Date: Sun, 18 Jan 2015 16:40:10 -0800	[thread overview]
Message-ID: <b3d22d1d587a626e91f536f6393e476a41de84c9.1421627321.git.wking@tremily.us> (raw)

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
---
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
  “Start a new nmbug repository” commit.

As well as the core.logallrefupdates tweak I turned up in testing [3].

[1]: id:113512958b3fd64902517c1c55576faef816f852.1414532174.git.wking@tremily.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=19767
[3]: id:20141129201829.GI4062@odin.tremily.us
     http://thread.gmane.org/gmane.mail.notmuch.general/19495/focus=19774

 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=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.
@@ -725,6 +744,7 @@ if __name__ == '__main__':
             'commit',
             'fetch',
             'help',
+            'init',
             'log',
             'merge',
             'pull',
-- 
2.1.0.60.g85f0837

             reply	other threads:[~2015-01-19  0:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-19  0:40 W. Trevor King [this message]
2015-01-19  9:44 ` [PATCH v4] nmbug: Add an 'init' command Tomi Ollila
2015-01-19 16:55   ` W. Trevor King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b3d22d1d587a626e91f536f6393e476a41de84c9.1421627321.git.wking@tremily.us \
    --to=wking@tremily.us \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).