summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-02-28 20:29:02 +0100
committerSebastian Thiel <byronimo@gmail.com>2010-02-28 20:29:02 +0100
commit6bfdf93201ea413affd4c8fbe406ea2b4a7c1b6b (patch)
tree24cb60de55a13bf42d9b66e9b459642ed23fb557
parent3e14ab55a060a5637e9a4a40e40714c1f441d952 (diff)
downloadgitpython-6bfdf93201ea413affd4c8fbe406ea2b4a7c1b6b.tar.gz
Commit.iter_items: Will not restrict comits to the ones containing changes to paths anymore as it will only append '--' if paths are actually given.
Added unittest to verify this
-rw-r--r--lib/git/objects/commit.py7
-rw-r--r--test/git/test_commit.py18
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):