From: Frank Li Date: Tue, 30 Jun 2009 07:52:38 +0000 (+0800) Subject: Fixed Issue #104: Doubleclicking changed submodule dir in Check For Modifications... X-Git-Url: http://git.sourceforge.jp/view?a=commitdiff_plain;h=8ccc32dc647f6a5e6626f5395a7bcadde78d87fd;p=tortoisegit%2FTortoiseGitJp.git Fixed Issue #104: Doubleclicking changed submodule dir in Check For Modifications dlg, crashes TGit Signed-off-by: Frank Li --- diff --git a/src/TortoiseProc/AppUtils.cpp b/src/TortoiseProc/AppUtils.cpp index 61f6894..0abb67d 100644 --- a/src/TortoiseProc/AppUtils.cpp +++ b/src/TortoiseProc/AppUtils.cpp @@ -1992,15 +1992,15 @@ bool CAppUtils::SendPatchMail(CTGitPathList &list,bool autoclose) } return false; } -int CAppUtils::GetLogOutputEncode() +int CAppUtils::GetLogOutputEncode(CGit *pGit) { CString cmd,output; int start=0; cmd=_T("git.exe config i18n.logOutputEncoding"); - if(g_Git.Run(cmd,&output,CP_ACP)) + if(pGit->Run(cmd,&output,CP_ACP)) { cmd=_T("git.exe config i18n.commitencoding"); - if(g_Git.Run(cmd,&output,CP_ACP)) + if(pGit->Run(cmd,&output,CP_ACP)) return CP_UTF8; int start=0; diff --git a/src/TortoiseProc/AppUtils.h b/src/TortoiseProc/AppUtils.h index 0f11a38..e2d98f4 100644 --- a/src/TortoiseProc/AppUtils.h +++ b/src/TortoiseProc/AppUtils.h @@ -198,7 +198,7 @@ public: static int SaveCommitUnicodeFile(CString &filename, CString &mesage); - static int GetLogOutputEncode(); + static int GetLogOutputEncode(CGit *pGit=&g_Git); static bool Push(); diff --git a/src/TortoiseProc/GitDiff.cpp b/src/TortoiseProc/GitDiff.cpp index 3f45e1f..059920c 100644 --- a/src/TortoiseProc/GitDiff.cpp +++ b/src/TortoiseProc/GitDiff.cpp @@ -2,7 +2,9 @@ #include "GitDiff.h" #include "AppUtils.h" #include "git.h" +#include "gittype.h" #include "resource.h" +#include "MessageBox.h" CGitDiff::CGitDiff(void) { @@ -79,6 +81,60 @@ int CGitDiff::Diff(CTGitPath * pPath,CTGitPath * pPath2, git_revnum_t & rev1, gi CString file1; CString title1; CString cmd; + + if(pPath->IsDirectory() || pPath2->IsDirectory()) + { + cmd.Format(_T("git.exe diff-tree -r -z %s %s -- \"%s\""), + rev2,rev1,pPath->GetGitPathString()); + + BYTE_VECTOR bytes; + if(g_Git.Run(cmd,&bytes)) + { + CString err; + g_Git.StringAppend(&err,&bytes[0],CP_ACP); + CMessageBox::Show(NULL,err,_T("TortoiseGit"),MB_OK|MB_ICONERROR); + } + + CString oldhash; + g_Git.StringAppend(&oldhash,&bytes[15],CP_ACP,40); + CString newhash; + g_Git.StringAppend(&newhash,&bytes[15+41],CP_ACP,40); + + CString oldsub; + CString newsub; + + CGit subgit; + subgit.m_CurrentDir=g_Git.m_CurrentDir+_T("\\")+pPath->GetWinPathString(); + + CString cmd; + if(pPath->HasAdminDir()) + { + int encode=CAppUtils::GetLogOutputEncode(&subgit); + + if(oldhash != GIT_REV_ZERO) + { + cmd.Format(_T("git log -n1 HEAD --pretty=format:\"%%s\" %s"),oldhash); + subgit.Run(cmd,&oldsub,encode); + } + + if(newsub != GIT_REV_ZERO) + { + cmd.Format(_T("git log -n1 HEAD --pretty=format:\"%%s\" %s"),newhash); + subgit.Run(cmd,&newsub,encode); + } + } + CString msg; + msg.Format(_T("Submodule %s Change\r\n\r\nFrom: %s\r\n\t%s\r\n\r\nTo: %s\r\n\t\t%s"), + pPath->GetWinPath(), + oldhash, + oldsub , + newhash, + newsub); + CMessageBox::Show(NULL,msg,_T("TortoiseGit"),MB_OK); + + return 0; + } + if(rev1 != GIT_REV_ZERO ) { file1.Format(_T("%s%s_%s%s"),