Skip to content

FIx issue #464 corrupt log file #469

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

Merged
merged 9 commits into from
Aug 2, 2016
Next Next commit
Fix corruption of the ref logs file
It must only have the first line of the
commit messages, not the while multiple line log.
  • Loading branch information
barry-scott committed Jun 13, 2016
commit e0eafc47c307ff0bf589ce43b623bd24fad744fd
5 changes: 3 additions & 2 deletions git/refs/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def from_line(cls, line):
newhexsha = info[41:81]
for hexsha in (oldhexsha, newhexsha):
if not cls._re_hexsha_only.match(hexsha):
raise ValueError("Invalid hexsha: %s" % hexsha)
raise ValueError("Invalid hexsha: %r" % (hexsha,))
# END if hexsha re doesn't match
# END for each hexsha

Expand Down Expand Up @@ -274,11 +274,12 @@ def append_entry(cls, config_reader, filepath, oldbinsha, newbinsha, message):
raise ValueError("Shas need to be given in binary format")
# END handle sha type
assure_directory_exists(filepath, is_file=True)
first_line = message.split('\n')[0]
committer = isinstance(config_reader, Actor) and config_reader or Actor.committer(config_reader)
entry = RefLogEntry((
bin_to_hex(oldbinsha).decode('ascii'),
bin_to_hex(newbinsha).decode('ascii'),
committer, (int(time.time()), time.altzone), message
committer, (int(time.time()), time.altzone), first_line
))

lf = LockFile(filepath)
Expand Down