OSDN Git Service

merge original branch.
[tortoisegit/TortoiseGitJp.git] / src / Git / Git.cpp
index 46bfb66..3353b54 100644 (file)
@@ -6,9 +6,11 @@
 #include "GitConfig.h"\r
 #include <map>\r
 #include "UnicodeUtils.h"\r
+#include "gitdll.h"\r
 \r
 int CGit::m_LogEncode=CP_UTF8;\r
 \r
+\r
 static LPTSTR nextpath(LPCTSTR src, LPTSTR dst, UINT maxlen)\r
 {\r
        LPCTSTR orgsrc;\r
@@ -126,12 +128,18 @@ CGit::CGit(void)
 {\r
        GetCurrentDirectory(MAX_DIRBUFFER,m_CurrentDir.GetBuffer(MAX_DIRBUFFER));\r
        m_CurrentDir.ReleaseBuffer();\r
-\r
+       m_IsGitDllInited = false;\r
+       m_GitDiff=0;\r
        CheckMsysGitDir();\r
 }\r
 \r
 CGit::~CGit(void)\r
 {\r
+       if(this->m_GitDiff)\r
+       {\r
+               git_close_diff(m_GitDiff);\r
+               m_GitDiff=0;\r
+       }\r
 }\r
 \r
 static char g_Buffer[4096];\r
@@ -472,10 +480,8 @@ int CGit::GetLog(BYTE_VECTOR& logOut, CString &hash,  CTGitPath *path ,int count
        return GetLog(&gitCall,hash,path,count,mask,from,to);\r
 }\r
 \r
-//int CGit::GetLog(CGitCall* pgitCall, CString &hash,  CTGitPath *path ,int count,int mask)\r
-int CGit::GetLog(CGitCall* pgitCall, CString &hash, CTGitPath *path, int count, int mask,CString *from,CString *to)\r
+CString CGit::GetLogCmd( CString &hash, CTGitPath *path, int count, int mask,CString *from,CString *to,bool paramonly)\r
 {\r
-\r
        CString cmd;\r
        CString log;\r
        CString num;\r
@@ -534,40 +540,35 @@ int CGit::GetLog(CGitCall* pgitCall, CString &hash, CTGitPath *path, int count,
        }\r
        param+=hash;\r
 \r
-       cmd.Format(_T("git.exe log %s -z --topo-order %s --parents --pretty=format:\""),\r
+       if(paramonly)\r
+               cmd.Format(_T("%s -z --topo-order %s --parents "),\r
+                               num,param);\r
+       else\r
+               cmd.Format(_T("git.exe log %s -z --topo-order %s --parents --pretty=format:\""),\r
                                num,param);\r
 \r
        BuildOutputFormat(log,!(mask&CGit::LOG_INFO_ONLY_HASH));\r
 \r
-       cmd += log;\r
-       cmd += CString(_T("\"  "))+hash+file;\r
+       if(paramonly)\r
+       {\r
+               cmd += hash+file;\r
+       }else\r
+       {\r
+               cmd += log;\r
+               cmd += CString(_T("\"  "))+hash+file;\r
+       }\r
 \r
-       pgitCall->SetCmd(cmd);\r
+       return cmd;\r
+}\r
+//int CGit::GetLog(CGitCall* pgitCall, CString &hash,  CTGitPath *path ,int count,int mask)\r
+int CGit::GetLog(CGitCall* pgitCall, CString &hash, CTGitPath *path, int count, int mask,CString *from,CString *to)\r
+{\r
+       pgitCall->SetCmd( GetLogCmd(hash,path,count,mask,from,to) );\r
 \r
        return Run(pgitCall);\r
 //     return Run(cmd,&logOut);\r
 }\r
 \r
-#if 0\r
-int CGit::GetShortLog(CString &logOut,CTGitPath * path, int count)\r
-{\r
-       CString cmd;\r
-       CString log;\r
-       int n;\r
-       if(count<0)\r
-               n=100;\r
-       else\r
-               n=count;\r
-       cmd.Format(_T("git.exe log --left-right --boundary --topo-order -n%d --pretty=format:\""),n);\r
-       BuildOutputFormat(log,false);\r
-       cmd += log+_T("\"");\r
-       if (path)\r
-               cmd+= _T("  -- \"")+path->GetGitPathString()+_T("\"");\r
-       //cmd += CString(_T("\" HEAD~40..HEAD"));\r
-       return Run(cmd,&logOut);\r
-}\r
-#endif\r
-\r
 #define BUFSIZE 512\r
 void GetTempPath(CString &path)\r
 {\r
@@ -1157,11 +1158,11 @@ BOOL CGit::EnumFiles(const TCHAR *pszProjectPath, const TCHAR *pszSubPath, unsig
                CString sSubPath = pszSubPath;\r
                sSubPath.Replace(_T('\\'), _T('/'));\r
 \r
-               cmd.Format(_T("igit.exe \"%s\" status %s \"%s\""), sProjectPath, sMode, sSubPath);\r
+               cmd.Format(_T("tgit.exe statusex \"%s\" status %s \"%s\""), sProjectPath, sMode, sSubPath);\r
        }\r
        else\r
        {\r
-               cmd.Format(_T("igit.exe \"%s\" status %s"), sProjectPath, sMode);\r
+               cmd.Format(_T("tgit.exe statusex \"%s\" status %s"), sProjectPath, sMode);\r
        }\r
 \r
        //OutputDebugStringA("---");OutputDebugStringW(cmd);OutputDebugStringA("\r\n");\r