OSDN Git Service

GitBlame Use command Line argument to open file
[tortoisegit/TortoiseGitJp.git] / src / TortoiseGitBlame / TortoiseGitBlameDoc.cpp
index 5fececb..32a9a63 100644 (file)
@@ -48,14 +48,20 @@ BOOL CTortoiseGitBlameDoc::OnNewDocument()
 \r
        return TRUE;\r
 }\r
 \r
        return TRUE;\r
 }\r
-\r
 BOOL CTortoiseGitBlameDoc::OnOpenDocument(LPCTSTR lpszPathName)\r
 {\r
 BOOL CTortoiseGitBlameDoc::OnOpenDocument(LPCTSTR lpszPathName)\r
 {\r
+       return OnOpenDocument(lpszPathName,_T(""));\r
+}\r
+\r
+BOOL CTortoiseGitBlameDoc::OnOpenDocument(LPCTSTR lpszPathName,CString Rev)\r
+{\r
        if (!CDocument::OnOpenDocument(lpszPathName))\r
                return FALSE;\r
 \r
        m_CurrentFileName=lpszPathName;\r
 \r
        if (!CDocument::OnOpenDocument(lpszPathName))\r
                return FALSE;\r
 \r
        m_CurrentFileName=lpszPathName;\r
 \r
+       m_Rev=Rev;\r
+\r
        // TODO: add reinitialization code here\r
        // (SDI documents will reuse this document)\r
        if(!CGit::CheckMsysGitDir())\r
        // TODO: add reinitialization code here\r
        // (SDI documents will reuse this document)\r
        if(!CGit::CheckMsysGitDir())\r
@@ -78,7 +84,7 @@ BOOL CTortoiseGitBlameDoc::OnOpenDocument(LPCTSTR lpszPathName)
                CString cmd;\r
                CTGitPath path;\r
                path.SetFromWin(lpszPathName);\r
                CString cmd;\r
                CTGitPath path;\r
                path.SetFromWin(lpszPathName);\r
-               cmd.Format(_T("git.exe blame -s -l -- \"%s\""),path.GetGitPathString());\r
+               cmd.Format(_T("git.exe blame -s -l %s -- \"%s\""),Rev,path.GetGitPathString());\r
                m_BlameData.Empty();\r
                if(g_Git.Run(cmd,&m_BlameData))\r
                {\r
                m_BlameData.Empty();\r
                if(g_Git.Run(cmd,&m_BlameData))\r
                {\r
@@ -86,13 +92,36 @@ BOOL CTortoiseGitBlameDoc::OnOpenDocument(LPCTSTR lpszPathName)
 \r
                }\r
                CTortoiseGitBlameView *pView=DYNAMIC_DOWNCAST(CTortoiseGitBlameView,GetMainFrame()->GetActiveView());\r
 \r
                }\r
                CTortoiseGitBlameView *pView=DYNAMIC_DOWNCAST(CTortoiseGitBlameView,GetMainFrame()->GetActiveView());\r
-               pView->UpdateInfo();\r
-               \r
+               if(pView == NULL)\r
+               {\r
+                       CWnd* pWnd = GetMainFrame()->GetDescendantWindow(AFX_IDW_PANE_FIRST, TRUE);\r
+                       if (pWnd != NULL && pWnd->IsKindOf(RUNTIME_CLASS(CTortoiseGitBlameView)))\r
+                       {\r
+                               pView = (CTortoiseGitBlameView*)pWnd;\r
+                       }\r
+                       else\r
+                       {\r
+                               return FALSE;\r
+                       }\r
+               }\r
+               pView->UpdateInfo();            \r
        }\r
 \r
        return TRUE;\r
 }\r
 \r
        }\r
 \r
        return TRUE;\r
 }\r
 \r
+void CTortoiseGitBlameDoc::SetPathName(LPCTSTR lpszPathName, BOOL bAddToMRU)\r
+{\r
+       CDocument::SetPathName(lpszPathName,bAddToMRU);\r
+\r
+       CString title;\r
+       if(m_Rev.IsEmpty())\r
+               title=CString(lpszPathName)+_T(":HEAD");\r
+       else\r
+               title=CString(lpszPathName)+_T(":")+m_Rev;\r
+\r
+       this->SetTitle(title);\r
+}\r
 \r
 // CTortoiseGitBlameDoc serialization\r
 \r
 \r
 // CTortoiseGitBlameDoc serialization\r
 \r