File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -427,6 +427,19 @@ def __delitem__(self, path):
427
427
def __iter__ (self ):
428
428
return ConflictIterator (self ._index )
429
429
430
+ def __contains__ (self , path ):
431
+ cancestor = ffi .new ('git_index_entry **' )
432
+ cours = ffi .new ('git_index_entry **' )
433
+ ctheirs = ffi .new ('git_index_entry **' )
434
+
435
+ err = C .git_index_conflict_get (cancestor , cours , ctheirs ,
436
+ self ._index ._index , to_bytes (path ))
437
+ if err == C .GIT_ENOTFOUND :
438
+ return False
439
+
440
+ check_error (err )
441
+ return True
442
+
430
443
431
444
class ConflictIterator :
432
445
Original file line number Diff line number Diff line change @@ -100,6 +100,8 @@ def test_merge_no_fastforward_conflicts(mergerepo):
100
100
assert mergerepo .index .conflicts is not None
101
101
with pytest .raises (KeyError ):
102
102
mergerepo .index .conflicts .__getitem__ ('some-file' )
103
+ assert 'some-file' not in mergerepo .index .conflicts
104
+ assert '.gitignore' in mergerepo .index .conflicts
103
105
104
106
status = pygit2 .GIT_STATUS_CONFLICTED
105
107
# Asking twice to assure the reference counting is correct
@@ -126,12 +128,14 @@ def test_merge_remove_conflicts(mergerepo):
126
128
idx = mergerepo .index
127
129
conflicts = idx .conflicts
128
130
assert conflicts is not None
131
+ assert '.gitignore' in conflicts
129
132
try :
130
133
conflicts ['.gitignore' ]
131
134
except KeyError :
132
135
mergerepo .fail ("conflicts['.gitignore'] raised KeyError unexpectedly" )
133
136
del idx .conflicts ['.gitignore' ]
134
137
with pytest .raises (KeyError ): conflicts .__getitem__ ('.gitignore' )
138
+ assert '.gitignore' not in conflicts
135
139
assert idx .conflicts is None
136
140
137
141
You can’t perform that action at this time.
0 commit comments