diff options
-rw-r--r-- | lib/git/commit.py | 8 | ||||
-rw-r--r-- | lib/git/repo.py | 11 | ||||
-rw-r--r-- | test/git/test_commit.py | 4 | ||||
-rw-r--r-- | test/git/test_repo.py | 12 |
4 files changed, 17 insertions, 18 deletions
diff --git a/lib/git/commit.py b/lib/git/commit.py index 8b7bdfa8..c50d9d2d 100644 --- a/lib/git/commit.py +++ b/lib/git/commit.py @@ -95,7 +95,7 @@ class Commit(LazyMixin): Returns int """ - return len(repo.git.rev_list(ref).strip().splitlines()) + return len(repo.git.rev_list(ref, '--').strip().splitlines()) @classmethod def find_all(cls, repo, ref, **kwargs): @@ -118,7 +118,7 @@ class Commit(LazyMixin): options = {'pretty': 'raw'} options.update(kwargs) - output = repo.git.rev_list(ref, **options) + output = repo.git.rev_list(ref, '--', **options) return cls.list_from_string(repo, output) @classmethod @@ -214,14 +214,14 @@ class Commit(LazyMixin): @property def stats(self): if not self.parents: - text = self.repo.git.diff(self.id, numstat=True) + text = self.repo.git.diff(self.id, '--', numstat=True) text2 = "" for line in text.splitlines(): (insertions, deletions, filename) = line.split("\t") text2 += "%s\t%s\t%s\n" % (deletions, insertions, filename) text = text2 else: - text = self.repo.git.diff(self.parents[0].id, self.id, numstat=True) + text = self.repo.git.diff(self.parents[0].id, self.id, '--', numstat=True) return stats.Stats.list_from_string(self.repo, text) def __str__(self): diff --git a/lib/git/repo.py b/lib/git/repo.py index a3874259..09215b1e 100644 --- a/lib/git/repo.py +++ b/lib/git/repo.py @@ -192,8 +192,8 @@ class Repo(object): Returns ``git.Commit[]`` """ - repo_refs = self.git.rev_list(ref).strip().splitlines() - other_repo_refs = other_repo.git.rev_list(other_ref).strip().splitlines() + repo_refs = self.git.rev_list(ref, '--').strip().splitlines() + other_repo_refs = other_repo.git.rev_list(other_ref, '--').strip().splitlines() diff_refs = list(set(other_repo_refs) - set(repo_refs)) return map(lambda ref: Commit.find_all(other_repo, ref, max_count=1)[0], diff_refs) @@ -236,10 +236,9 @@ class Repo(object): """ options = {'pretty': 'raw'} options.update(kwargs) + arg = [commit, '--'] if path: - arg = [commit, '--', path] - else: - arg = [commit] + arg.append(path) commits = self.git.log(*arg, **options) return Commit.list_from_string(self, commits) @@ -450,7 +449,7 @@ class Repo(object): # always consired to be clean. return False - return len(self.git.diff('HEAD').strip()) > 0 + return len(self.git.diff('HEAD', '--').strip()) > 0 @property def active_branch(self): diff --git a/test/git/test_commit.py b/test/git/test_commit.py index e9336f2c..df9ea039 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -22,7 +22,7 @@ class TestCommit(object): assert_equal("tom@mojombo.com", commit.author.email) assert_true(git.called) - assert_equal(git.call_args, (('rev_list', '4c8124ffcf4039d292442eeccabdeca5af5c5017'), {'pretty': 'raw', 'max_count': 1})) + assert_equal(git.call_args, (('rev_list', '4c8124ffcf4039d292442eeccabdeca5af5c5017', '--'), {'pretty': 'raw', 'max_count': 1})) @patch_object(Git, '_call_process') def test_id_abbrev(self, git): @@ -184,7 +184,7 @@ class TestCommit(object): assert_equal(["a.txt", "b.txt"], keys) assert_true(git.called) - assert_equal(git.call_args, (('diff', '634396b2f541a9f2d58b00be1a07f0c358b999b3'), {'numstat': True})) + assert_equal(git.call_args, (('diff', '634396b2f541a9f2d58b00be1a07f0c358b999b3', '--'), {'numstat': True})) @patch_object(Git, '_call_process') def test_rev_list_bisect_all(self, git): diff --git a/test/git/test_repo.py b/test/git/test_repo.py index 79c2dd8c..67489b39 100644 --- a/test/git/test_repo.py +++ b/test/git/test_repo.py @@ -70,7 +70,7 @@ class TestRepo(object): assert_equal("Merge branch 'site'", c.message) assert_true(git.called) - assert_equal(git.call_args, (('rev_list', 'master'), {'skip': 0, 'pretty': 'raw', 'max_count': 10})) + assert_equal(git.call_args, (('rev_list', 'master', '--'), {'skip': 0, 'pretty': 'raw', 'max_count': 10})) @patch_object(Git, '_call_process') def test_commit_count(self, git): @@ -79,7 +79,7 @@ class TestRepo(object): assert_equal(655, self.repo.commit_count('master')) assert_true(git.called) - assert_equal(git.call_args, (('rev_list', 'master'), {})) + assert_equal(git.call_args, (('rev_list', 'master', '--'), {})) @patch_object(Git, '_call_process') def test_commit(self, git): @@ -90,7 +90,7 @@ class TestRepo(object): assert_equal("4c8124ffcf4039d292442eeccabdeca5af5c5017", commit.id) assert_true(git.called) - assert_equal(git.call_args, (('rev_list', '4c8124ffcf4039d292442eeccabdeca5af5c5017'), {'pretty': 'raw', 'max_count': 1})) + assert_equal(git.call_args, (('rev_list', '4c8124ffcf4039d292442eeccabdeca5af5c5017', '--'), {'pretty': 'raw', 'max_count': 1})) @patch_object(Git, '_call_process') def test_tree(self, git): @@ -269,7 +269,7 @@ class TestRepo(object): assert_equal('ab25fd8483882c3bda8a458ad2965d2248654335', self.repo.log()[-1].id) assert_true(git.called) assert_equal(git.call_count, 2) - assert_equal(git.call_args, (('log', 'master'), {'pretty': 'raw'})) + assert_equal(git.call_args, (('log', 'master', '--'), {'pretty': 'raw'})) @patch_object(Git, '_call_process') def test_log_with_path_and_options(self, git): @@ -314,14 +314,14 @@ class TestRepo(object): self.repo.bare = False git.return_value = '' assert_false(self.repo.is_dirty) - assert_equal(git.call_args, (('diff', 'HEAD'), {})) + assert_equal(git.call_args, (('diff', 'HEAD', '--'), {})) @patch_object(Git, '_call_process') def test_is_dirty_with_dirty_working_dir(self, git): self.repo.bare = False git.return_value = '''-aaa\n+bbb''' assert_true(self.repo.is_dirty) - assert_equal(git.call_args, (('diff', 'HEAD'), {})) + assert_equal(git.call_args, (('diff', 'HEAD', '--'), {})) @patch_object(Git, '_call_process') def test_active_branch(self, git): |