Skip to content

Commit

Permalink
Fix FileHistory/Blame for files not existing in the working directory
Browse files Browse the repository at this point in the history
The bad behavior comes from the fact that `TryGetExactPath()`
changes the path to the file system path (if not existing, the path is cleared)

Alternative for gitextensions#6893
  • Loading branch information
gerhardol committed Jul 9, 2019
1 parent b33a12e commit eb16d48
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
9 changes: 1 addition & 8 deletions GitUI/CommandsDialogs/FormFileHistory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,20 +207,13 @@ private void LoadFileHistory()
{
var fileName = FileName;

// we will need this later to look up proper casing for the file
var fullFilePath = _fullPathResolver.Resolve(fileName);

if (_controller.TryGetExactPath(fullFilePath, out fileName))
{
fileName = fileName.Substring(Module.WorkingDir.Length);
}

// Replace windows path separator to Linux path separator.
// This is needed to keep the file history working when started from file tree in
// browse dialog.
FileName = fileName.ToPosixPath();

var res = (revision: (string)null, path: $" \"{fileName}\"");
var fullFilePath = _fullPathResolver.Resolve(fileName);

if (AppSettings.FollowRenamesInFileHistory && !Directory.Exists(fullFilePath))
{
Expand Down
5 changes: 5 additions & 0 deletions GitUI/GitUICommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1703,6 +1703,11 @@ private void RunFileHistoryCommand(IReadOnlyList<string> args)
// long while there is room left when the workingdir was not in the path.
string fileHistoryFileName = string.IsNullOrEmpty(Module.WorkingDir) ? args[2] :
args[2].Replace(Module.WorkingDir, "").ToPosixPath();
var fullFilePath = _fullPathResolver.Resolve(fileHistoryFileName);
if (new FormFileHistoryController().TryGetExactPath(fullFilePath, out var exactFileName))
{
fileHistoryFileName = exactFileName.Substring(Module.WorkingDir.Length);
}

StartFileHistoryDialog(null, fileHistoryFileName);
}
Expand Down

0 comments on commit eb16d48

Please sign in to comment.