Skip to content

Commit

Permalink
Fix renames in FileHistory/Blame form
Browse files Browse the repository at this point in the history
  • Loading branch information
pmiossec committed Jul 1, 2019
1 parent 038af21 commit 453cf2f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions GitCommands/RevisionReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,18 @@ DateTime ParseUnixDateTime()
// If there are not enough characters remaining for a body, then just assign the subject string directly.
var body = reader.Remaining - subject.Length == 2 ? subject : reader.ReadToEnd();

string filename = null;
if (body == null)
{
// TODO log this parse error
Debug.Fail("Unable to read body from the log -- this should not happen");
revision = default;
return false;
}
else
{
filename = body.Split('\n').LastOrDefault();
}

#endregion

Expand All @@ -430,6 +435,7 @@ DateTime ParseUnixDateTime()
MessageEncoding = encodingName,
Subject = subject,
Body = body,
Name = filename,
HasMultiLineMessage = !ReferenceEquals(subject, body),
HasNotes = false
};
Expand Down
3 changes: 2 additions & 1 deletion GitUI/CommandsDialogs/FormFileHistory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ private void LoadFileHistory()

if (AppSettings.FollowRenamesInFileHistory && !Directory.Exists(fullFilePath))
{
// git log --follow is not working as expected (see http://kerneltrap.org/mailarchive/git/2009/1/30/4856404/thread)
// git log --follow is not working as expected (see https://web.archive.org/web/20110113233428/http://kerneltrap.org/mailarchive/git/2009/1/30/4856404/ )
//
// But we can take a more complicated path to get reasonable results:
// 1. use git log --follow to get all previous filenames of the file we are interested in
Expand All @@ -237,6 +237,7 @@ private void LoadFileHistory()
{
"--format=\"%n\"",
"--name-only",
"--follow",
GitCommandHelpers.FindRenamesAndCopiesOpts(),
"--",
fileName.Quote()
Expand Down

0 comments on commit 453cf2f

Please sign in to comment.