]> arthur.barton.de Git - bup.git/commitdiff
git.list_refs: change arg from refnames to patterns
authorRob Browning <rlb@defaultvalue.org>
Sat, 17 Jun 2017 17:36:22 +0000 (12:36 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sun, 18 Jun 2017 20:48:45 +0000 (15:48 -0500)
...to make it clearer how they're going to be interpreted, since we
pass them straight to git show-ref.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
cmd/prune-older-cmd.py
lib/bup/git.py

index f2ba1d18b661b90dc9525e5bd30705b586483168..208ddf73bb8d6f69ded65bfbd99fa538a91929de 100755 (executable)
@@ -20,7 +20,7 @@ from bup.rm import bup_rm
 
 def branches(refnames=()):
     return ((name[11:], sha) for (name,sha)
-            in git.list_refs(refnames=('refs/heads/' + n for n in refnames),
+            in git.list_refs(patterns=('refs/heads/' + n for n in refnames),
                              limit_to_heads=True))
 
 def save_name(branch, utc):
index 94016a4c7ec59af671b429af382a04e7b65428b3..826c6e5f59d4d698d7a1e21fe967edcdbeff6322 100644 (file)
@@ -880,13 +880,13 @@ def _gitenv(repo_dir = None):
     return env
 
 
-def list_refs(refnames=None, repo_dir=None,
+def list_refs(patterns=None, repo_dir=None,
               limit_to_heads=False, limit_to_tags=False):
     """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.
+    patterns are specified.  In that case, only include tuples for
+    refs matching those patterns (cf. git-show-ref(1)).  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']
@@ -895,8 +895,8 @@ def list_refs(refnames=None, repo_dir=None,
     if limit_to_tags:
         argv.append('--tags')
     argv.append('--')
-    if refnames:
-        argv += refnames
+    if patterns:
+        argv.extend(patterns)
     p = subprocess.Popen(argv,
                          preexec_fn = _gitenv(repo_dir),
                          stdout = subprocess.PIPE)
@@ -912,7 +912,7 @@ def list_refs(refnames=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(refnames=[refname], repo_dir=repo_dir, limit_to_heads=True)
+    refs = list_refs(patterns=[refname], repo_dir=repo_dir, limit_to_heads=True)
     l = tuple(islice(refs, 2))
     if l:
         assert(len(l) == 1)