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