aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Sunshine <sunshine@sunshineco.com>2015-01-14 08:46:35 +0100
committerAlberto Bertogli <albertito@blitiri.com.ar>2015-01-17 14:11:46 +0100
commit5568fd50c26e0474b3b1e02fa3581053d1478c5f (patch)
tree24c854d3818e5d33337eb6951b0cc41159278b11
parent89a637660fed90af8991d734ea758a07780e9ac1 (diff)
downloadgit-arr-fork-5568fd50c26e0474b3b1e02fa3581053d1478c5f.zip
Repo: retire new_in_branch() and notion of "bound" branch0.14
Binding (or "pegging") a Repo at a particular branch via new_in_branch() increases the cognitive burden since the reader must maintain a mental model of which Repo instances are pegged and which are not. This burden outweighs whatever minor convenience (if any) is gained by pegging the Repo at a particular branch. It is easier to reason about the code when the branch name is passed to clients directly rather than indirectly via a pegged Repo. Preceding patches retired all callers of new_in_branch(), therefore remove it. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
-rw-r--r--git.py16
1 files changed, 3 insertions, 13 deletions
diff --git a/git.py b/git.py
index ad3952d..636f3a2 100644
--- a/git.py
+++ b/git.py
@@ -205,9 +205,8 @@ def unquote(s):
class Repo:
"""A git repository."""
- def __init__(self, path, branch = None, name = None, info = None):
+ def __init__(self, path, name = None, info = None):
self.path = path
- self.branch = branch
self.name = name
self.info = info or SimpleNamespace()
@@ -249,11 +248,6 @@ class Repo:
"""Get the names of the tags."""
return ( name for name, _ in self.tags() )
- def new_in_branch(self, branch):
- """Returns a new Repo, but on the specific branch."""
- return Repo(self.path, branch = branch, name = self.name,
- info = self.info)
-
def commit_ids(self, ref, limit = None):
"""Generate commit ids."""
cmd = self.cmd('rev-list')
@@ -333,16 +327,12 @@ class Repo:
return r
- def tree(self, ref = None):
+ def tree(self, ref):
"""Returns a Tree instance for the given ref."""
- if not ref:
- ref = self.branch
return Tree(self, ref)
- def blob(self, path, ref = None):
+ def blob(self, path, ref):
"""Returns a Blob instance for the given path."""
- if not ref:
- ref = self.branch
cmd = self.cmd('cat-file')
cmd.raw(True)
cmd.batch = '%(objectsize)'