]> arthur.barton.de Git - bup.git/commitdiff
git: allow multiple refnames in list_refs calls
authorRob Browning <rlb@defaultvalue.org>
Sun, 18 Sep 2016 04:23:26 +0000 (23:23 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sun, 30 Oct 2016 17:06:59 +0000 (12:06 -0500)
Tested-by: Rob Browning <rlb@defaultvalue.org>
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/git.py

index 460d6b11a2d9273aa0b2dfd4f0bfcb2599df5fe4..fa2ad2152893d1ec289ae82302d4e371f40d3560 100644 (file)
@@ -842,13 +842,13 @@ def _gitenv(repo_dir = None):
     return env
 
 
-def list_refs(refname=None, repo_dir=None,
+def list_refs(refnames=None, repo_dir=None,
               limit_to_heads=False, limit_to_tags=False):
-    """Yield (refname, hash) tuples for all repository refs unless a ref
-    name is specified.  Given a ref name, only include tuples for that
-    particular ref.  The limits restrict the result items to
-    refs/heads or refs/tags.  If both limits are specified, items from
-    both sources will be included.
+    """Yield (refname, hash) tuples for all repository refs unless
+    refnames are specified.  In that case, only include tuples for
+    those refs.  The limits restrict the result items to refs/heads or
+    refs/tags.  If both limits are specified, items from both sources
+    will be included.
 
     """
     argv = ['git', 'show-ref']
@@ -857,8 +857,8 @@ def list_refs(refname=None, repo_dir=None,
     if limit_to_tags:
         argv.append('--tags')
     argv.append('--')
-    if refname:
-        argv += [refname]
+    if refnames:
+        argv += refnames
     p = subprocess.Popen(argv,
                          preexec_fn = _gitenv(repo_dir),
                          stdout = subprocess.PIPE)
@@ -874,7 +874,7 @@ def list_refs(refname=None, repo_dir=None,
 
 def read_ref(refname, repo_dir = None):
     """Get the commit id of the most recent commit made on a given ref."""
-    refs = list_refs(refname, repo_dir=repo_dir, limit_to_heads=True)
+    refs = list_refs(refnames=[refname], repo_dir=repo_dir, limit_to_heads=True)
     l = tuple(islice(refs, 2))
     if l:
         assert(len(l) == 1)