diff options
-rw-r--r-- | lib/git/objects/commit.py | 7 | ||||
-rw-r--r-- | test/git/test_commit.py | 18 |
2 files changed, 24 insertions, 1 deletions
diff --git a/lib/git/objects/commit.py b/lib/git/objects/commit.py index 271b8f75..4d0f808d 100644 --- a/lib/git/objects/commit.py +++ b/lib/git/objects/commit.py @@ -165,8 +165,13 @@ class Commit(base.Object, Iterable, diff.Diffable, utils.Traversable): """ options = {'pretty': 'raw', 'as_process' : True } options.update(kwargs) + + args = list() + if paths: + args.extend(('--', paths)) + # END if paths - proc = repo.git.rev_list(rev, '--', paths, **options) + proc = repo.git.rev_list(rev, args, **options) return cls._iter_from_process_or_stream(repo, proc, True) def iter_parents(self, paths='', **kwargs): diff --git a/test/git/test_commit.py b/test/git/test_commit.py index 1e0338d6..da18f275 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -92,6 +92,24 @@ class TestCommit(TestBase): # sha ) assert len(first.parents) == 0 + def test_iteration(self): + # we can iterate commits + all_commits = Commit.list_items(self.rorepo, 'master') + assert all_commits + assert all_commits == list(self.rorepo.iter_commits()) + + # this includes merge commits + mcomit = Commit(self.rorepo, 'd884adc80c80300b4cc05321494713904ef1df2d') + assert mcomit in all_commits + + # we can limit the result to paths + ltd_commits = list(self.rorepo.iter_commits(paths='CHANGES')) + assert ltd_commits and len(ltd_commits) < len(all_commits) + + # show commits of multiple paths, resulting in a union of commits + less_ltd_commits = list(Commit.iter_items(self.rorepo, 'master', paths=('CHANGES', 'AUTHORS'))) + assert len(ltd_commits) < len(less_ltd_commits) + @patch_object(Git, '_call_process') def test_rev_list_bisect_all(self, git): |