OSDN Git Service

Fixed issue #188: Add Git Properties tab into Windows File Properties
[tortoisegit/TortoiseGitJp.git] / src / TortoiseShell / SVNPropertyPage.cpp
index 2f0817b..874cbfb 100644 (file)
@@ -219,6 +219,80 @@ void CGitPropertyPage::Time64ToTimeString(__time64_t time, TCHAR * buf, size_t b
 \r
 void CGitPropertyPage::InitWorkfileView()\r
 {\r
+       CString username;\r
+       //can't git.exe when create process\r
+       g_Git.Run(_T("tgit config user.name"),&username,CP_ACP);\r
+       CString useremail;\r
+       g_Git.Run(_T("tgit config user.email"),&useremail,CP_ACP);\r
+       CString autocrlf;\r
+       g_Git.Run(_T("tgit config core.autocrlf"),&autocrlf,CP_ACP);\r
+       CString safecrlf;\r
+       g_Git.Run(_T("tgit config core.safecrlf"),&safecrlf,CP_ACP);\r
+\r
+       CString branch;\r
+       CString headhash;\r
+\r
+       BYTE_VECTOR logout;\r
+\r
+       CString cmd,log;\r
+       cmd=_T("tgit log -z --topo-order -n1 --parents --pretty=format:\"");\r
+       \r
+       g_Git.BuildOutputFormat(log,true);\r
+\r
+       cmd += log;\r
+       cmd += CString(_T("\"  "));\r
+\r
+       g_Git.Run(cmd,&logout);\r
+       GitRev rev;\r
+       rev.ParserFromLog(logout);\r
+\r
+       SetDlgItemText(m_hwnd,IDC_CONFIG_USERNAME,username);\r
+       SetDlgItemText(m_hwnd,IDC_CONFIG_USEREMAIL,useremail);\r
+       SetDlgItemText(m_hwnd,IDC_CONFIG_AUTOCRLF,autocrlf);\r
+       SetDlgItemText(m_hwnd,IDC_CONFIG_SAFECRLF,safecrlf);\r
+\r
+       SetDlgItemText(m_hwnd,IDC_HEAD_HASH,rev.m_CommitHash);\r
+       SetDlgItemText(m_hwnd,IDC_HEAD_SUBJECT,rev.m_Subject);\r
+       SetDlgItemText(m_hwnd,IDC_HEAD_AUTHOR,rev.m_AuthorName);\r
+       SetDlgItemText(m_hwnd,IDC_HEAD_DATE,rev.m_AuthorDate.Format(_T("%Y-%m-%d %H:%M:%S")));\r
+\r
+       if (filenames.size() == 1)\r
+       {\r
+               CTGitPath path(filenames.front().c_str());\r
+               CTGitPath relatepath;\r
+               CString strpath=path.GetWinPathString();\r
+               CString ProjectTopDir;\r
+\r
+               if(!path.HasAdminDir(&ProjectTopDir))\r
+                       return;\r
+               \r
+               if(ProjectTopDir[ProjectTopDir.GetLength()-1] == _T('\\'))\r
+               {\r
+                       relatepath.SetFromWin( strpath.Right(strpath.GetLength()-ProjectTopDir.GetLength()));\r
+               }else\r
+               {\r
+                       relatepath.SetFromWin( strpath.Right(strpath.GetLength()-ProjectTopDir.GetLength()-1));\r
+               }\r
+\r
+               cmd+=_T("-- \"");\r
+               cmd+=relatepath.GetGitPathString();     \r
+               cmd+=_T("\"");\r
+\r
+               logout.clear();\r
+               g_Git.Run(cmd,&logout);\r
+               rev.Clear();\r
+               rev.ParserFromLog(logout);\r
+\r
+               SetDlgItemText(m_hwnd,IDC_LAST_HASH,rev.m_CommitHash);\r
+               SetDlgItemText(m_hwnd,IDC_LAST_SUBJECT,rev.m_Subject);\r
+               SetDlgItemText(m_hwnd,IDC_LAST_AUTHOR,rev.m_AuthorName);\r
+               SetDlgItemText(m_hwnd,IDC_LAST_DATE,rev.m_AuthorDate.Format(_T("%Y-%m-%d %H:%M:%S")));\r
+\r
+       }else\r
+       {\r
+\r
+       }\r
+\r
 #if 0\r
        GitStatus svn = GitStatus();\r
        TCHAR tbuf[MAX_STRING_LENGTH];\r