unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: "W. Trevor King" <wking@tremily.us>
To: notmuch@notmuchmail.org
Cc: David Bremner <bremner@debian.org>
Subject: [PATCH 4/4] nmbug: Add an 'init' command
Date: Sun,  6 Jul 2014 13:40:22 -0700	[thread overview]
Message-ID: <05ccd672f55444f74da62250e2305fb84fdc6c42.1404678709.git.wking@tremily.us> (raw)
In-Reply-To: <cover.1404678709.git.wking@tremily.us>
In-Reply-To: <cover.1404678709.git.wking@tremily.us>

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
---
 devel/nmbug/nmbug | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/devel/nmbug/nmbug b/devel/nmbug/nmbug
index c9ac046..b64dab9 100755
--- a/devel/nmbug/nmbug
+++ b/devel/nmbug/nmbug
@@ -30,6 +30,7 @@ my %command = (
 	     commit	=> \&do_commit,
 	     fetch	=> \&do_fetch,
 	     help	=> \&do_help,
+	     init	=> \&do_init,
 	     log	=> \&do_log,
 	     merge	=> \&do_merge,
 	     pull	=> \&do_pull,
@@ -152,6 +153,18 @@ sub do_clone {
   git ('config', 'core.bare', 'true');
 }
 
+sub do_init {
+  my $tempwork = tempdir ('/tmp/nmbug-init.XXXXXX', CLEANUP => 1);
+  system ('git', 'init', '--separate-git-dir', $NMBGIT, $tempwork) == 0
+    or die "'git init' exited with nonzero value\n";
+  git ('config', '--unset', 'core.worktree');
+  git ('config', 'core.bare', 'true');
+  # create an empty blob (e69de29bb2d1d6434b8b29ae775ad8c2e48c5391)
+  git ('hash-object', '-w', '--stdin');
+  git ( { GIT_WORK_TREE => $tempwork }, 'commit', '--allow-empty',
+        '-m', 'Start a new nmbug repository' );
+}
+
 sub is_committed {
   my $status = shift;
   return scalar (@{$status->{added}} ) + scalar (@{$status->{deleted}} ) == 0;
@@ -610,6 +623,12 @@ Create a local nmbug repository from a remote source.  This wraps
 C<git clone>, adding some options to avoid creating a working tree
 while preserving remote-tracking branches and upstreams.
 
+=item B<init>
+
+Create a local nmbug repository from scratch.  This wraps C<git init>
+and performs other setup to support subsequent status and commit
+commands.
+
 =item B<checkout>
 
 Update the notmuch database from git. This is mainly useful to discard
-- 
1.9.1.353.gc66d89d

  parent reply	other threads:[~2014-07-06 20:48 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-06 20:40 [PATCH 0/4] nmbug without an upstream repository (and init) W. Trevor King
2014-07-06 20:40 ` [PATCH 1/4] nmbug: Add a git_with_status helper function W. Trevor King
2014-07-16  9:36   ` David Bremner
2014-07-06 20:40 ` [PATCH 2/4] nmbug: Handle missing @upstream in is_unmerged W. Trevor King
2014-07-15 23:44   ` David Bremner
2014-07-16  0:11     ` W. Trevor King
2014-07-16 22:36   ` David Bremner
2014-07-16 23:03     ` W. Trevor King
2014-07-17  9:28       ` David Bremner
2014-07-17 18:38         ` W. Trevor King
2014-07-19 12:34       ` David Bremner
2014-07-06 20:40 ` [PATCH 3/4] nmbug: Catch stderr " W. Trevor King
2014-07-15 23:49   ` David Bremner
2014-07-16  0:17     ` W. Trevor King
2014-07-16 10:04       ` David Bremner
2014-07-06 20:40 ` W. Trevor King [this message]
2014-07-15 23:54   ` [PATCH 4/4] nmbug: Add an 'init' command David Bremner
2014-07-16  0:12     ` W. Trevor King
2014-09-15 16:13   ` David Edmondson
2014-09-15 16:25     ` W. Trevor King
2014-09-15 16:32       ` David Edmondson
2014-09-15 16:35         ` W. Trevor King
2014-09-15 18:09           ` David Bremner
2014-09-15 18:13             ` W. Trevor King
2014-09-23 18:44               ` [PATCH] potential fix for nmbug merge problems David Bremner

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=05ccd672f55444f74da62250e2305fb84fdc6c42.1404678709.git.wking@tremily.us \
    --to=wking@tremily.us \
    --cc=bremner@debian.org \
    --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).