From 91783895835650a407c669044eb039ea8d1428f0 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 7 Jul 2014 13:40:22 +1700 Subject: [PATCH] [PATCH 4/4] nmbug: Add an 'init' command --- 48/a4a530ff05fb8a278447595623327b6ed9f97f | 130 ++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 48/a4a530ff05fb8a278447595623327b6ed9f97f diff --git a/48/a4a530ff05fb8a278447595623327b6ed9f97f b/48/a4a530ff05fb8a278447595623327b6ed9f97f new file mode 100644 index 000000000..803d1b607 --- /dev/null +++ b/48/a4a530ff05fb8a278447595623327b6ed9f97f @@ -0,0 +1,130 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id C0F7B431FBD + for ; Sun, 6 Jul 2014 13:48:58 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id qBvRrPVHO24L for ; + Sun, 6 Jul 2014 13:48:52 -0700 (PDT) +Received: from qmta15.westchester.pa.mail.comcast.net + (qmta15.westchester.pa.mail.comcast.net [76.96.59.228]) + by olra.theworths.org (Postfix) with ESMTP id B23D0431FAF + for ; Sun, 6 Jul 2014 13:48:52 -0700 (PDT) +Received: from omta13.westchester.pa.mail.comcast.net ([76.96.62.52]) + by qmta15.westchester.pa.mail.comcast.net with comcast + id P8iR1o00117dt5G5F8osKw; Sun, 06 Jul 2014 20:48:52 +0000 +Received: from odin.tremily.us ([24.18.63.50]) + by omta13.westchester.pa.mail.comcast.net with comcast + id P8or1o001152l3L3Z8orwA; Sun, 06 Jul 2014 20:48:52 +0000 +Received: from mjolnir.tremily.us (unknown [192.168.0.140]) + by odin.tremily.us (Postfix) with ESMTPS id 87A4612700EB; + Sun, 6 Jul 2014 13:41:01 -0700 (PDT) +Received: (nullmailer pid 1926 invoked by uid 1000); + Sun, 06 Jul 2014 20:40:28 -0000 +From: "W. Trevor King" +To: notmuch@notmuchmail.org +Subject: [PATCH 4/4] nmbug: Add an 'init' command +Date: Sun, 6 Jul 2014 13:40:22 -0700 +Message-Id: + <05ccd672f55444f74da62250e2305fb84fdc6c42.1404678709.git.wking@tremily.us> +X-Mailer: git-send-email 1.9.1.353.gc66d89d +In-Reply-To: +References: +In-Reply-To: +References: +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; + s=q20140121; t=1404679732; + bh=dn0RS2rWBoS7td+5aPxlmgggg5QBozIpMaUOv2R3px4=; + h=Received:Received:Received:Received:From:To:Subject:Date: + Message-Id; + b=PpE88UfamcI/+4wCrdmElSydAXGFEl1MP21FdDFa37EFs2Fnc3B+bXqA9suv5TMMd + BIcrdGfTk/0rgnIKySexA0IJ2f8+t0Ljm2GhwBZc6nRDm7vfoGAC3uBW3B9TMnSGcg + XUmQlIJ8jmZ0E6A0RMXV+bXd38DHvtJqdjmJaS2pIhPFi4I8msOy/UpLRav5pzZXJq + yuUF6lQrvHwTcXlYRVBftQrzYVUw+L3WDXARzw/CWmj28bGqsvJzVDypfR+EdMV0t9 + WuUrSv61C4/e7yoZgcDAjzYDmmUto1tjiDQIcsbN6YHMmxj7ug/5zyGiIuC29sPB7M + 55fWgRWcOIy7A== +Cc: David Bremner +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 06 Jul 2014 20:48:58 -0000 + +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, adding some options to avoid creating a working tree + while preserving remote-tracking branches and upstreams. + ++=item B ++ ++Create a local nmbug repository from scratch. This wraps C ++and performs other setup to support subsequent status and commit ++commands. ++ + =item B + + Update the notmuch database from git. This is mainly useful to discard +-- +1.9.1.353.gc66d89d + -- 2.26.2