OSDN Git Service

Impliment commit command at log dialog when choose work copy
[tortoisegit/TortoiseGitJp.git] / src / Git / TGitPath.cpp
index 859069c..29e6d6a 100644 (file)
@@ -23,6 +23,8 @@
 #include "PathUtils.h"\r
 #include <regex>\r
 #include "git.h"\r
+#include "Globals.h"\r
+\r
 #if defined(_MFC_VER)\r
 //#include "MessageBox.h"\r
 //#include "AppUtils.h"\r
@@ -760,6 +762,68 @@ bool CTGitPath::HasAdminDir() const
        return m_bHasAdminDir;\r
 }\r
 \r
+bool CTGitPath::HasSubmodules() const\r
+{\r
+       return !g_GitAdminDir.GetSuperProjectRoot(GetWinPathString()).IsEmpty();\r
+}\r
+\r
+int CTGitPath::GetAdminDirMask() const\r
+{\r
+       int status = 0;\r
+       CString topdir,path;\r
+       if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))\r
+       {\r
+               return status;\r
+       }\r
+\r
+       status |= ITEMIS_INSVN|ITEMIS_FOLDERINSVN;\r
+\r
+       path=topdir;\r
+       path+=_T("\\");\r
+       path+=g_GitAdminDir.GetAdminDirName();\r
+       path+=_T("\\refs\\stash");\r
+       if( PathFileExists(path) )\r
+               status |= ITEMIS_STASH;\r
+       \r
+       path=topdir;\r
+       path+=_T("\\");\r
+       path+=g_GitAdminDir.GetAdminDirName();\r
+       path+=_T("\\svn");\r
+       if( PathFileExists(path) )\r
+               status |= ITEMIS_GITSVN;\r
+\r
+       path=topdir;\r
+       path+=_T("\\.gitmodules");\r
+       if( PathFileExists(path) )\r
+               status |= ITEMIS_SUBMODULE;\r
+\r
+       return status;\r
+}\r
+\r
+bool CTGitPath::HasStashDir() const\r
+{\r
+       CString topdir;\r
+       if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))\r
+       {\r
+               return false;\r
+       }\r
+       topdir+=_T("\\");\r
+       topdir+=g_GitAdminDir.GetAdminDirName();\r
+       topdir+=_T("\\refs\stash");\r
+       return PathFileExists(topdir);\r
+}\r
+bool CTGitPath::HasGitSVNDir() const\r
+{\r
+       CString topdir;\r
+       if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))\r
+       {\r
+               return false;\r
+       }\r
+       topdir+=_T("\\");\r
+       topdir+=g_GitAdminDir.GetAdminDirName();\r
+       topdir+=_T("\\svn");\r
+       return PathFileExists(topdir);\r
+}\r
 bool CTGitPath::HasAdminDir(CString *ProjectTopDir) const\r
 {\r
        if (m_bHasAdminDirKnown)\r
@@ -880,12 +944,14 @@ int CTGitPathList::ParserFromLsFile(BYTE_VECTOR &out,bool staged)
        CString one;\r
        CTGitPath path;\r
        CString part;\r
+       this->Clear();\r
+\r
        while(pos>=0 && pos<out.size())\r
        {\r
                one.Empty();\r
                path.Reset();\r
 \r
-               g_Git.StringAppend(&one,&out[pos],CP_OEMCP);\r
+               g_Git.StringAppend(&one,&out[pos],CP_ACP);\r
                int tabstart=0;\r
                path.m_Action=path.ParserAction(out[pos]);\r
                one.Tokenize(_T("\t"),tabstart); \r
@@ -952,7 +1018,7 @@ int CTGitPathList::FillUnRev(int action,CTGitPathList *list)
                while( pos>=0 && pos<out.size())\r
                {\r
                        one.Empty();\r
-                       g_Git.StringAppend(&one,&out[pos],CP_OEMCP);\r
+                       g_Git.StringAppend(&one,&out[pos],CP_ACP);\r
                        if(!one.IsEmpty())\r
                        {\r
                                //SetFromGit will clear all status\r
@@ -983,6 +1049,11 @@ int CTGitPathList::ParserFromLog(BYTE_VECTOR &log)
 \r
                if(log[pos]==':')\r
                {\r
+                       bool merged=false;\r
+                       if(log[pos+1] ==':')\r
+                       {\r
+                               merged=true;\r
+                       }\r
                        int end=log.find(0,pos);\r
                        int actionstart=-1;\r
                        int numfile=1;\r
@@ -1020,24 +1091,33 @@ int CTGitPathList::ParserFromLog(BYTE_VECTOR &log)
                        CString pathname2;\r
 \r
                        if( file1>=0 )\r
-                               g_Git.StringAppend(&pathname1,&log[file1],CP_OEMCP);\r
+                               g_Git.StringAppend(&pathname1,&log[file1],CP_ACP);\r
                        if( file2>=0 )\r
-                               g_Git.StringAppend(&pathname2,&log[file2],CP_OEMCP);\r
+                               g_Git.StringAppend(&pathname2,&log[file2],CP_ACP);\r
 \r
                        CTGitPath *GitPath=LookForGitPath(pathname1);\r
 \r
                        if(GitPath)\r
                        {\r
-                               this->m_Action|=GitPath->ParserAction( log[actionstart] );      \r
-                                                       \r
+                               GitPath->ParserAction( log[actionstart] );      \r
+                               \r
+                               if(merged)\r
+                               {\r
+                                       GitPath->m_Action |= CTGitPath::LOGACTIONS_MERGED;\r
+                                       GitPath->m_Action &= ~CTGitPath::LOGACTIONS_FORWORD;\r
+                               }\r
+                               m_Action |=GitPath->m_Action;\r
+\r
                        }else\r
                        {       \r
                                int ac=path.ParserAction(log[actionstart] );\r
+                               ac |= merged?CTGitPath::LOGACTIONS_MERGED:0;    \r
 \r
                                path.SetFromGit(pathname1,&pathname2);\r
                                path.m_Action=ac;\r
                                        //action must be set after setfromgit. SetFromGit will clear all status. \r
                                this->m_Action|=ac;\r
+                               \r
                                AddPath(path);\r
                                \r
                        }\r
@@ -1071,18 +1151,18 @@ int CTGitPathList::ParserFromLog(BYTE_VECTOR &log)
                        if(log[pos] == 0) //rename\r
                        {\r
                                pos++;\r
-                               g_Git.StringAppend(&file2,&log[pos],CP_OEMCP);\r
+                               g_Git.StringAppend(&file2,&log[pos],CP_ACP);\r
                                int sec=log.find(0,pos);\r
                                if(sec>=0)\r
                                {\r
                                        sec++;\r
-                                       g_Git.StringAppend(&file1,&log[sec],CP_OEMCP);\r
+                                       g_Git.StringAppend(&file1,&log[sec],CP_ACP);\r
                                }\r
                                pos=sec;\r
 \r
                        }else\r
                        {\r
-                               g_Git.StringAppend(&file1,&log[pos],CP_OEMCP);\r
+                               g_Git.StringAppend(&file1,&log[pos],CP_ACP);\r
                        }\r
                        path.SetFromGit(file1,&file2);\r
        \r
@@ -1096,6 +1176,7 @@ int CTGitPathList::ParserFromLog(BYTE_VECTOR &log)
                                //path.SetFromGit(pathname);\r
                                path.m_StatAdd=StatAdd;\r
                                path.m_StatDel=StatDel;\r
+                               path.m_Action |= CTGitPath::LOGACTIONS_FORWORD;\r
                                AddPath(path);\r
                        }\r
 \r
@@ -1303,6 +1384,9 @@ CTGitPath CTGitPathList::GetCommonRoot() const
        int searchStartPos = 0;\r
        while (bEqual)\r
        {\r
+               if(m_paths.empty())\r
+                       break;\r
+\r
                for (it = m_paths.begin(); it != m_paths.end(); ++it)\r
                {\r
                        if (backSlashPos == 0)\r
@@ -1896,12 +1980,19 @@ CString CTGitPath::GetActionName(int action)
                return _T("Added");\r
        if(action  & CTGitPath::LOGACTIONS_DELETED)\r
                return _T("Deleted");\r
+       if(action  & CTGitPath::LOGACTIONS_MERGED )\r
+               return _T("Merged");\r
+\r
        if(action  & CTGitPath::LOGACTIONS_MODIFIED)\r
                return _T("Modified");\r
        if(action  & CTGitPath::LOGACTIONS_REPLACED)\r
                return _T("Rename");\r
        if(action  & CTGitPath::LOGACTIONS_COPY)\r
                return _T("Copy");\r
+\r
+       if(action  & CTGitPath::LOGACTIONS_FORWORD )\r
+               return _T("Forward");\r
+\r
        if(action & CTGitPath::LOGACTIONS_REBASE_EDIT)\r
                return _T("Edit");\r
        if(action & CTGitPath::LOGACTIONS_REBASE_SQUASH)\r