Skip to content

Commit

Permalink
Fix gitextensions#5944 by fixing --follow and revision reading
Browse files Browse the repository at this point in the history
a306eb6 by mistake removed the "--follow" option when getting the git
log for history. This is reverted by this commit.
1f6b0ca by mistake removed parsing of the file name data into
GitRevision.Name. This is also reverted by this commit.
Together, these should fix rename tracking in the file history.
  • Loading branch information
fschmied authored and gerhardol committed Jul 5, 2019
1 parent 98b3915 commit 53ebf95
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 15 additions & 2 deletions GitCommands/RevisionReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public enum RefFilterOptions

public sealed class RevisionReader : IDisposable
{
private const string EndOfBody = "1DEA7CC4-FB39-450A-8DDF-762FCEA28B05";
private const string FullFormat =

// These header entries can all be decoded from the bytes directly.
Expand All @@ -47,7 +48,7 @@ public sealed class RevisionReader : IDisposable
/* Committer name */ "%cN%n" +
/* Committer email */ "%cE%n" +
/* Commit subject */ "%s%n%n" +
/* Commit body */ "%b";
/* Commit body */ "%b" + EndOfBody;

private readonly CancellationTokenSequence _cancellationTokenSequence = new CancellationTokenSequence();

Expand Down Expand Up @@ -380,7 +381,7 @@ DateTime ParseUnixDateTime()

#endregion

#region Encoded string values (names, emails, subject, body)
#region Encoded string values (names, emails, subject, body, name)

// Finally, decode the names, email, subject and body strings using the required text encoding
var s = encoding.GetString(array, offset, lastOffset - offset);
Expand Down Expand Up @@ -415,6 +416,17 @@ DateTime ParseUnixDateTime()
return false;
}

var indexOfEndOfBody = body.LastIndexOf(EndOfBody, StringComparison.InvariantCulture);

string additionalData = null;
var bodyContainsAdditionalData = body.Length > indexOfEndOfBody + EndOfBody.Length;
if (bodyContainsAdditionalData)
{
additionalData = body.Substring(indexOfEndOfBody + EndOfBody.Length).TrimStart();
}

body = body.Substring(0, indexOfEndOfBody);

#endregion

revision = new GitRevision(objectId)
Expand All @@ -430,6 +442,7 @@ DateTime ParseUnixDateTime()
MessageEncoding = encodingName,
Subject = subject,
Body = body,
Name = additionalData,
HasMultiLineMessage = !ReferenceEquals(subject, body),
HasNotes = false
};
Expand Down
1 change: 1 addition & 0 deletions GitUI/CommandsDialogs/FormFileHistory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ private void LoadFileHistory()
{
"--format=\"%n\"",
"--name-only",
"--follow",
GitCommandHelpers.FindRenamesAndCopiesOpts(),
"--",
fileName.Quote()
Expand Down

0 comments on commit 53ebf95

Please sign in to comment.