Skip to content

Commit 8bde103

Browse files
committed
add test to detect the corrupt log
- add a second line to commit messages with the "BAD MESSAGE" text - read in the log and confirm that the seond line is not in the log file
1 parent 572ebd6 commit 8bde103

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Diff for: git/test/test_repo.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -775,12 +775,23 @@ def test_empty_repo(self, rw_dir):
775775
new_file_path = os.path.join(rw_dir, "new_file.ext")
776776
touch(new_file_path)
777777
r.index.add([new_file_path])
778-
r.index.commit("initial commit")
778+
r.index.commit("initial commit\nBAD MESSAGE 1\n")
779779

780780
# Now a branch should be creatable
781781
nb = r.create_head('foo')
782782
assert nb.is_valid()
783783

784+
with open( new_file_path, 'w' ) as f:
785+
f.write( 'Line 1\n' )
786+
787+
r.index.add([new_file_path])
788+
r.index.commit("add line 1\nBAD MESSAGE 2\n")
789+
790+
with open( '%s/.git/logs/refs/heads/master' % (rw_dir,), 'r' ) as f:
791+
contents = f.read()
792+
793+
assert 'BAD MESSAGE' not in contents, 'log is corrupt'
794+
784795
def test_merge_base(self):
785796
repo = self.rorepo
786797
c1 = 'f6aa8d1'

0 commit comments

Comments
 (0)