Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita5e607e

Browse files
committed
fix(iter-commit): ambiguous argument error
In repositories like> git branch -a* test> lstest`repo.iter_commits` failed due to an ambigous argument(`'git rev-list test`).Now this cannot happen anymore.fixesgitpython-developers#264
1 parent630d030 commita5e607e

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

‎git/objects/commit.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,12 @@ def iter_items(cls, repo, rev, paths='', **kwargs):
189189
if'pretty'inkwargs:
190190
raiseValueError("--pretty cannot be used as parsing expects single sha's only")
191191
# END handle pretty
192-
args=list()
192+
193+
# use -- in any case, to prevent possibility of ambiguous arguments
194+
# see https://github.com/gitpython-developers/GitPython/issues/264
195+
args= ['--']
193196
ifpaths:
194-
args.extend(('--',paths))
197+
args.extend((paths,))
195198
# END if paths
196199

197200
proc=repo.git.rev_list(rev,args,as_process=True,**kwargs)

‎git/test/test_commit.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,19 @@
1919
Actor,
2020
)
2121
fromgitdbimportIStream
22+
fromgitdb.test.libimportwith_rw_directory
2223
fromgit.compatimport (
2324
string_types,
2425
text_type
2526
)
27+
fromgitimportRepo
28+
fromgit.repo.funimporttouch
2629

2730
fromioimportBytesIO
2831
importtime
2932
importsys
3033
importre
34+
importos
3135

3236

3337
defassert_commit_serialization(rwrepo,commit_id,print_performance_info=False):
@@ -219,6 +223,15 @@ def test_rev_list_bisect_all(self):
219223
forsha1,commitinzip(expected_ids,commits):
220224
assert_equal(sha1,commit.hexsha)
221225

226+
@with_rw_directory
227+
deftest_ambiguous_arg_iteration(self,rw_dir):
228+
rw_repo=Repo.init(os.path.join(rw_dir,'test_ambiguous_arg'))
229+
path=os.path.join(rw_repo.working_tree_dir,'master')
230+
touch(path)
231+
rw_repo.index.add([path])
232+
rw_repo.index.commit('initial commit')
233+
list(rw_repo.iter_commits(rw_repo.head.ref))# should fail unless bug is fixed
234+
222235
deftest_count(self):
223236
assertself.rorepo.tag('refs/tags/0.1.5').commit.count()==143
224237

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp