Skip to content

create_patch=True breaks in some cases #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
louisrli opened this issue Jun 30, 2013 · 1 comment
Closed

create_patch=True breaks in some cases #113

louisrli opened this issue Jun 30, 2013 · 1 comment
Assignees

Comments

@louisrli
Copy link

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'
@Byron Byron added this to the v0.3.5 - bugfixes milestone Nov 19, 2014
@Byron Byron self-assigned this Jan 9, 2015
@Byron Byron closed this as completed in c767b52 Jan 9, 2015
@Byron
Copy link
Member

Byron commented Jan 9, 2015

I could surprisingly easily reproduce this issue, and added a new test-case to assure it's fixed for good.
Additionally, handling of encodings was overhauled and is now (what I believe to be) correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants