Skip to content

Commit

Permalink
git.cp(): don't repeatedly recompute default repo
Browse files Browse the repository at this point in the history
Before, bup would end up calling repo() for every invocation of cp().
Given that constructions like cp().get(id) are common, this could cause
a lot of unecessary calls, given that we already have git.repodir, which
will have the relevant value once initialized.

Discovered after noticing "bup restore" was hammering
"$BUP_DIR"/.git (which didn't exist).

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
  • Loading branch information
rlbdv committed Dec 17, 2016
1 parent 519b7cb commit 53db6ee
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/bup/git.py
Expand Up @@ -22,7 +22,7 @@

verbose = 0
ignore_midx = 0
repodir = None
repodir = None # The default repository, once initialized

_typemap = { 'blob':3, 'tree':2, 'commit':1, 'tag':4 }
_typermap = { 3:'blob', 2:'tree', 1:'commit', 4:'tag' }
Expand Down Expand Up @@ -1228,9 +1228,9 @@ def join(self, id):

def cp(repo_dir=None):
"""Create a CatPipe object or reuse the already existing one."""
global _cp
global _cp, repodir
if not repo_dir:
repo_dir = repo()
repo_dir = repodir or repo()
repo_dir = os.path.abspath(repo_dir)
cp = _cp.get(repo_dir)
if not cp:
Expand Down

0 comments on commit 53db6ee

Please sign in to comment.