diff options
Diffstat (limited to 'git')
-rw-r--r-- | git/diff.py | 14 | ||||
m--------- | git/ext/gitdb | 0 | ||||
-rw-r--r-- | git/refs/symbolic.py | 2 | ||||
-rw-r--r-- | git/repo/base.py | 6 | ||||
-rw-r--r-- | git/test/fixtures/diff_abbrev-40_full-index_M_raw_no-color | 1 | ||||
-rw-r--r-- | git/test/test_diff.py | 9 | ||||
-rw-r--r-- | git/test/test_repo.py | 2 |
7 files changed, 23 insertions, 11 deletions
diff --git a/git/diff.py b/git/diff.py index 06193920..fb8faaf6 100644 --- a/git/diff.py +++ b/git/diff.py @@ -183,7 +183,9 @@ class DiffIndex(list): raise ValueError("Invalid change type: %s" % change_type) for diff in self: - if change_type == "A" and diff.new_file: + if diff.change_type == change_type: + yield diff + elif change_type == "A" and diff.new_file: yield diff elif change_type == "D" and diff.deleted_file: yield diff @@ -247,11 +249,12 @@ class Diff(object): NULL_BIN_SHA = b"\0" * 20 __slots__ = ("a_blob", "b_blob", "a_mode", "b_mode", "a_rawpath", "b_rawpath", - "new_file", "deleted_file", "raw_rename_from", "raw_rename_to", "diff") + "new_file", "deleted_file", "raw_rename_from", "raw_rename_to", + "diff", "change_type") def __init__(self, repo, a_rawpath, b_rawpath, a_blob_id, b_blob_id, a_mode, b_mode, new_file, deleted_file, raw_rename_from, - raw_rename_to, diff): + raw_rename_to, diff, change_type): self.a_mode = a_mode self.b_mode = b_mode @@ -286,6 +289,7 @@ class Diff(object): self.raw_rename_to = raw_rename_to or None self.diff = diff + self.change_type = change_type def __eq__(self, other): for name in self.__slots__: @@ -435,7 +439,7 @@ class Diff(object): new_file, deleted_file, rename_from, rename_to, - None)) + None, None)) previous_header = header # end for each header we parse @@ -483,7 +487,7 @@ class Diff(object): # END add/remove handling diff = Diff(repo, a_path, b_path, a_blob_id, b_blob_id, old_mode, new_mode, - new_file, deleted_file, rename_from, rename_to, '') + new_file, deleted_file, rename_from, rename_to, '', change_type) index.append(diff) # END for each line diff --git a/git/ext/gitdb b/git/ext/gitdb -Subproject d1996e04dbf4841b853b60c1365f0f5fd28d170 +Subproject 2389b75280efb1a63e6ea578eae7f897fd4beb1 diff --git a/git/refs/symbolic.py b/git/refs/symbolic.py index ae67a7ee..ec2944c6 100644 --- a/git/refs/symbolic.py +++ b/git/refs/symbolic.py @@ -313,7 +313,7 @@ class SymbolicReference(object): lfd = LockedFD(fpath) fd = lfd.open(write=True, stream=True) - fd.write(write_value.encode('ascii')) + fd.write(write_value.encode('ascii') + b'\n') lfd.commit() # Adjust the reflog diff --git a/git/repo/base.py b/git/repo/base.py index 282dfc15..61864060 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -714,8 +714,7 @@ class Repo(object): authored_date=int(props[b'author-time']), committer=Actor(safe_decode(props[b'committer']), safe_decode(props[b'committer-mail'].lstrip(b'<').rstrip(b'>'))), - committed_date=int(props[b'committer-time']), - message=safe_decode(props[b'summary'])) + committed_date=int(props[b'committer-time'])) commits[hexsha] = c else: # Discard the next line (it's a filename end tag) @@ -815,8 +814,7 @@ class Repo(object): authored_date=info['author_date'], committer=Actor._from_string( info['committer'] + ' ' + info['committer_email']), - committed_date=info['committer_date'], - message=info['summary']) + committed_date=info['committer_date']) commits[sha] = c # END if commit objects needs initial creation if not is_binary: diff --git a/git/test/fixtures/diff_abbrev-40_full-index_M_raw_no-color b/git/test/fixtures/diff_abbrev-40_full-index_M_raw_no-color new file mode 100644 index 00000000..dad85c68 --- /dev/null +++ b/git/test/fixtures/diff_abbrev-40_full-index_M_raw_no-color @@ -0,0 +1 @@ +:100644 100644 739bc65220ad90e9ebfa2d6af1723b97555569a4 0000000000000000000000000000000000000000 M README.md diff --git a/git/test/test_diff.py b/git/test/test_diff.py index ba0d2d13..9fdb26a2 100644 --- a/git/test/test_diff.py +++ b/git/test/test_diff.py @@ -104,6 +104,15 @@ class TestDiff(TestBase): assert diff.rename_to == 'that' assert len(list(diffs.iter_change_type('R'))) == 1 + def test_diff_of_modified_files_not_added_to_the_index(self): + output = StringProcessAdapter(fixture('diff_abbrev-40_full-index_M_raw_no-color')) + diffs = Diff._index_from_raw_format(self.rorepo, output.stdout) + + assert len(diffs) == 1, 'one modification' + assert len(list(diffs.iter_change_type('M'))) == 1, 'one modification' + assert diffs[0].change_type == 'M' + assert diffs[0].b_blob is None + def test_binary_diff(self): for method, file_name in ((Diff._index_from_patch_format, 'diff_patch_binary'), (Diff._index_from_raw_format, 'diff_raw_binary')): diff --git a/git/test/test_repo.py b/git/test/test_repo.py index fc8125fa..87887bad 100644 --- a/git/test/test_repo.py +++ b/git/test/test_repo.py @@ -307,7 +307,7 @@ class TestRepo(TestBase): assert_equal('Tom Preston-Werner', c.committer.name) assert_equal('tom@mojombo.com', c.committer.email) assert_equal(1191997100, c.committed_date) - assert_equal('initial grit setup', c.message) + self.assertRaisesRegexp(ValueError, "634396b2f541a9f2d58b00be1a07f0c358b999b3 missing", lambda: c.message) # test the 'lines per commit' entries tlist = b[0][1] |