[PATCH v3] nmbug-status: Use 'show-ref --heads' for loading configs

W. Trevor King wking at tremily.us
Sun Mar 22 01:31:09 PDT 2015


When loading configs from Git, the bare branch name (without a
refs/heads/ prefix or similar) matches all branches of that name
(including remote-tracking branches):

  .nmbug $ git show-ref config
  48f3bbf1d1492e5f3d2f01de6ea79a30d3840f20 refs/heads/config
  48f3bbf1d1492e5f3d2f01de6ea79a30d3840f20 refs/remotes/origin/config
  4b6dbd9ffd152e7476f5101eff26747f34497cee refs/remotes/wking/config

Instead of relying on the ordering of the matching references, use
--heads to ensure we only match local branches.
---
The only change since v2 [1] is shifting the NEWS entry into the
unreleased 0.20 section [2].

[1]: id:5e97afaab6c01e980ca6194a1c04aa0310e28ab8.1426412504.git.wking at tremily.us
     http://thread.gmane.org/gmane.mail.notmuch.general/20344/
[2]: id:m2bnjm7o16.fsf at guru.guru-group.fi
     http://article.gmane.org/gmane.mail.notmuch.general/20350


 NEWS                     | 31 +++++++++++++++++++++++--------
 devel/nmbug/nmbug        |  1 +
 devel/nmbug/nmbug-status |  2 +-
 3 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/NEWS b/NEWS
index 70ad3f3..de13bbd 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,21 @@ Contrib
 previously provided by `notmuch-deliver` should now be provided by
 `notmuch insert`, provided by the main notmuch binary.
 
+nmbug-status
+------------
+
+`nmbug-status` now only matches local branches when reading
+`status-config.json` from the `config` branch of the `NMBGIT`
+repository.  To help new users running `nmbug-status`, `nmbug clone`
+now creates a local `config` branch tracking `origin/config`.  Folks
+who use `nmbug-status` with an in-Git config (i.e. you don't use the
+`--config` option) who already have `NMBGIT` set up are encouraged to
+run:
+
+    git checkout config origin/config
+
+in their `NMBGIT` repository (usually `~/.nmbug`).
+
 Notmuch 0.19 (2014-11-14)
 =========================
 
@@ -178,14 +193,14 @@ nmbug-status
 `nmbug-status` can now optionally load header and footer templates
 from the config file.  Use something like:
 
-    {
-      "meta": {
-        "header": "<!DOCTYPE html>\n<html lang="en">\n...",
-        "footer": "</body></html>",
-         ...
-      },
-      ...
-    },
+{
+"meta": {
+"header": "<!DOCTYPE html>\n<html lang="en">\n...",
+"footer": "</body></html>",
+...
+},
+...
+},
 
 Python Bindings
 ---------------
diff --git a/devel/nmbug/nmbug b/devel/nmbug/nmbug
index 932ec12..81f582c 100755
--- a/devel/nmbug/nmbug
+++ b/devel/nmbug/nmbug
@@ -308,6 +308,7 @@ def clone(repository):
             wait=True)
     _git(args=['config', '--unset', 'core.worktree'], wait=True)
     _git(args=['config', 'core.bare', 'true'], wait=True)
+    _git(args=['branch', 'config', 'origin/config'], wait=True)
 
 
 def _is_committed(status):
diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index 19dc48a..e845c2a 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -92,7 +92,7 @@ def read_config(path=None, encoding=None):
 
         # read only the first line from the pipe
         sha1_bytes = subprocess.Popen(
-            ['git', '--git-dir', nmbhome, 'show-ref', '-s', branch],
+            ['git', '--git-dir', nmbhome, 'show-ref', '-s', '--heads', branch],
             stdout=subprocess.PIPE).stdout.readline()
         sha1 = sha1_bytes.decode(encoding).rstrip()
         if not sha1:
-- 
2.1.0.60.g85f0837



More information about the notmuch mailing list