Skip to content

Commit

Permalink
git.list_refs: change arg from refnames to patterns
Browse files Browse the repository at this point in the history
...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>
  • Loading branch information
rlbdv committed Jun 18, 2017
1 parent b827191 commit 6d12c53
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cmd/prune-older-cmd.py
Expand Up @@ -20,7 +20,7 @@

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):
Expand Down
16 changes: 8 additions & 8 deletions lib/bup/git.py
Expand Up @@ -880,13 +880,13 @@ def env():
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']
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 6d12c53

Please sign in to comment.