OSDN Git Service

Fixed Issue #104: Doubleclicking changed submodule dir in Check For Modifications...
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / GitDiff.cpp
index 3f45e1f..059920c 100644 (file)
@@ -2,7 +2,9 @@
 #include "GitDiff.h"\r
 #include "AppUtils.h"\r
 #include "git.h"\r
+#include "gittype.h"\r
 #include "resource.h"\r
+#include "MessageBox.h"\r
 \r
 CGitDiff::CGitDiff(void)\r
 {\r
@@ -79,6 +81,60 @@ int CGitDiff::Diff(CTGitPath * pPath,CTGitPath * pPath2, git_revnum_t & rev1, gi
        CString file1;\r
        CString title1;\r
        CString cmd;\r
+\r
+       if(pPath->IsDirectory() || pPath2->IsDirectory())\r
+       {\r
+               cmd.Format(_T("git.exe diff-tree -r -z %s %s -- \"%s\""),\r
+                       rev2,rev1,pPath->GetGitPathString());\r
+               \r
+               BYTE_VECTOR bytes;\r
+               if(g_Git.Run(cmd,&bytes))\r
+               {\r
+                       CString err;\r
+                       g_Git.StringAppend(&err,&bytes[0],CP_ACP);\r
+                       CMessageBox::Show(NULL,err,_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+               }\r
+               \r
+               CString oldhash;\r
+               g_Git.StringAppend(&oldhash,&bytes[15],CP_ACP,40);\r
+               CString newhash;\r
+               g_Git.StringAppend(&newhash,&bytes[15+41],CP_ACP,40);\r
+\r
+               CString oldsub;\r
+               CString newsub;\r
+\r
+               CGit subgit; \r
+               subgit.m_CurrentDir=g_Git.m_CurrentDir+_T("\\")+pPath->GetWinPathString();\r
+\r
+               CString cmd;\r
+               if(pPath->HasAdminDir())\r
+               {\r
+                       int encode=CAppUtils::GetLogOutputEncode(&subgit);\r
+\r
+                       if(oldhash != GIT_REV_ZERO)\r
+                       {\r
+                               cmd.Format(_T("git log -n1 HEAD --pretty=format:\"%%s\" %s"),oldhash);\r
+                               subgit.Run(cmd,&oldsub,encode);\r
+                       }\r
+\r
+                       if(newsub != GIT_REV_ZERO)\r
+                       {\r
+                               cmd.Format(_T("git log -n1 HEAD --pretty=format:\"%%s\" %s"),newhash);\r
+                               subgit.Run(cmd,&newsub,encode);\r
+                       }\r
+               }\r
+               CString msg;\r
+               msg.Format(_T("Submodule <b>%s</b> Change\r\n\r\n<b>From:</b> %s\r\n\t%s\r\n\r\n<b>To:</b>     %s\r\n\t\t%s"),\r
+                                  pPath->GetWinPath(),\r
+                                  oldhash,\r
+                                  oldsub ,\r
+                                  newhash,\r
+                                  newsub);\r
+               CMessageBox::Show(NULL,msg,_T("TortoiseGit"),MB_OK);\r
+\r
+               return 0;\r
+       }\r
+\r
        if(rev1 != GIT_REV_ZERO )\r
        {\r
                file1.Format(_T("%s%s_%s%s"),\r