From c9328dd67a63dfcc3d8c83ba6332b02ffc22bcbf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20Strau=C3=9F?= Date: Fri, 22 Nov 2013 14:49:22 +0100 Subject: [PATCH] Provide parents in case a log entry is only available either in the log or the blame output MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Strauß Signed-off-by: Sven Strickroth --- src/TortoiseGitBlame/LogListBlameAction.cpp | 17 +++++++++++++++++ src/TortoiseGitBlame/PropertiesWnd.cpp | 11 +++++++++++ src/TortoiseGitBlame/TortoiseGitBlameView.cpp | 13 +++++++++++++ 3 files changed, 41 insertions(+) diff --git a/src/TortoiseGitBlame/LogListBlameAction.cpp b/src/TortoiseGitBlame/LogListBlameAction.cpp index 0dfcdce7e..7846789cd 100644 --- a/src/TortoiseGitBlame/LogListBlameAction.cpp +++ b/src/TortoiseGitBlame/LogListBlameAction.cpp @@ -209,11 +209,28 @@ void CGitBlameLogList::GetPaths(const CGitHash& hash, std::vector& pa paths.push_back(CTGitPath(*it)); } } + if (paths.empty()) + { + // in case the hash does not exist in the blame output but it exists in the log follow only the file + paths.push_back(pView->GetDocument()->m_GitPath); + } } } void CGitBlameLogList::GetParentNumbers(GitRev *pRev, const std::vector& paths, std::set &parentNos) { + if (pRev->m_ParentHash.empty()) + { + try + { + pRev->GetParentFromHash(pRev->m_CommitHash); + } + catch (const char* msg) + { + MessageBox(_T("Could not get parent.\nlibgit reports:\n") + CString(msg), _T("TortoiseGit"), MB_ICONERROR); + } + } + GIT_REV_LIST allParentHash; CGitLogListBase::GetParentHashes(pRev, allParentHash); diff --git a/src/TortoiseGitBlame/PropertiesWnd.cpp b/src/TortoiseGitBlame/PropertiesWnd.cpp index 0ad657634..baf38d830 100644 --- a/src/TortoiseGitBlame/PropertiesWnd.cpp +++ b/src/TortoiseGitBlame/PropertiesWnd.cpp @@ -241,6 +241,17 @@ void CPropertiesWnd::UpdateProperties(GitRev *pRev) { if (pRev) { + if (pRev->m_ParentHash.empty()) + { + try + { + pRev->GetParentFromHash(pRev->m_CommitHash); + } + catch (const char* msg) + { + MessageBox(_T("Could not get parent.\nlibgit reports:\n") + CString(msg), _T("TortoiseGit"), MB_ICONERROR); + } + } CString hash = pRev->m_CommitHash.ToString(); m_CommitHash->SetValue(hash); m_AuthorName->SetValue(pRev->GetAuthorName()); diff --git a/src/TortoiseGitBlame/TortoiseGitBlameView.cpp b/src/TortoiseGitBlame/TortoiseGitBlameView.cpp index 63245b1c2..f4c168399 100644 --- a/src/TortoiseGitBlame/TortoiseGitBlameView.cpp +++ b/src/TortoiseGitBlame/TortoiseGitBlameView.cpp @@ -371,7 +371,20 @@ void CTortoiseGitBlameView::OnRButtonUp(UINT /*nFlags*/, CPoint point) if (logIndex >= 0) pRev = &GetLogData()->GetGitRevAt(logIndex); else + { pRev = m_data.GetRev(line, GetLogData()->m_pLogCache->m_HashMap); + if (pRev->m_ParentHash.empty()) + { + try + { + pRev->GetParentFromHash(pRev->m_CommitHash); + } + catch (const char* msg) + { + MessageBox(_T("Could not get parent.\nlibgit reports:\n") + CString(msg), _T("TortoiseGit"), MB_ICONERROR); + } + } + } if (!pRev) return; -- 2.11.4.GIT