From 87693d28ff2a976accfc085fec400e3cd53341d0 Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Thu, 5 Sep 2013 00:07:24 +0200 Subject: [PATCH] Do not alter index when diffing a file (fixes issue #1751) Signed-off-by: Sven Strickroth --- src/TortoiseProc/Commands/DiffCommand.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/TortoiseProc/Commands/DiffCommand.cpp b/src/TortoiseProc/Commands/DiffCommand.cpp index fff807dfb..9f4cf2319 100644 --- a/src/TortoiseProc/Commands/DiffCommand.cpp +++ b/src/TortoiseProc/Commands/DiffCommand.cpp @@ -25,6 +25,8 @@ #include "ChangedDlg.h" #include "GitDiff.h" #include "GitStatus.h" +#include "../TGitCache/CacheInterface.h" +#include "../Utils/UnicodeUtils.h" bool DiffCommand::Execute() { @@ -56,8 +58,18 @@ bool DiffCommand::Execute() CString topDir; if (orgCmdLinePath.HasAdminDir(&topDir)) { - g_Git.Run(_T("git.exe update-index -- \"") + cmdLinePath.GetGitPathString() + _T("\""), nullptr); // make sure we get the right status + CBlockCacheForPath cacheBlock(topDir); + git_index *index = nullptr; + CString adminDir; + g_GitAdminDir.GetAdminDirPath(topDir, adminDir); + if (!git_index_open(&index, CUnicodeUtils::GetMulti(adminDir + _T("index"), CP_UTF8))) + g_Git.Run(_T("git.exe update-index -- \"") + cmdLinePath.GetGitPathString() + _T("\""), nullptr); // make sure we get the right status GitStatus::GetFileStatus(topDir, cmdLinePath.GetWinPathString(), &status, true); + if (index) + { + git_index_write(index); + git_index_free(index); + } } if (status == git_wc_status_added) { -- 2.11.4.GIT