Skip to content

create_patch=True breaks in some cases #113

Closed
@louisrli

Description

@louisrli

repo.index.diff(HEAD, create_patch=True) will also break. However, it works without the create_patch flag.

The following two commands succeed as well.

I have one staged file, one tracked but unstaged file, and some untracked files in my repository.

In [13]: repo.index.diff(None)
Out[13]: [<git.diff.Diff at 0x10d0eab18>]

In [14]: repo.index.diff(None, create_patch=True)
Out[14]: [<git.diff.Diff at 0x10d0eaaa0>]

In [11]: repo.index.diff('HEAD~1', create_patch=True)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-11-49c4ff310661> in <module>()
----> 1 repo.index.diff('HEAD~1', create_patch=True)

/Library/Python/2.7/site-packages/git/index/util.pyc in check_default_index(self, *args, **kwargs)
     62                 if self._file_path != self._index_path():
     63                         raise AssertionError( "Cannot call %r on indices that do not represent the default git index" % func.__name__ )---> 64                 return func(self, *args, **kwargs)
     65         # END wrpaper method
     66 /Library/Python/2.7/site-packages/git/index/base.pyc in diff(self, other, paths, create_patch, **kwargs)   1146                         cur_val = kwargs.get('R', False)   1147                         kwargs['R'] = not cur_val
-> 1148                         return other.diff(self.Index, paths, create_patch, **kwargs)
   1149                 # END diff against other item handlin   1150
/Library/Python/2.7/site-packages/git/diff.pyc in diff(self, other, paths, create_patch, **kwargs)
     99                 if create_patch:
    100                         diff_method = Diff._index_from_patch_format
--> 101                 index = diff_method(self.repo, proc.stdout)
    102
    103                 status = proc.wait()

/Library/Python/2.7/site-packages/git/diff.pyc in _index_from_patch_format(cls, repo, stream)
    299                         a_path, b_path, similarity_index, rename_from, rename_to, \
    300                                 old_mode, new_mode, new_file_mode, deleted_file_mode, \
--> 301                                 a_blob_id, b_blob_id, b_mode = header.groups()
    302                         new_file, deleted_file = bool(new_file_mode), bool(deleted_file_mode)
    303

AttributeError: 'NoneType' object has no attribute 'groups'

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions