OSDN Git Service

Show "fast forward file" at merged commit
[tortoisegit/TortoiseGitJp.git] / src / Git / TGitPath.cpp
index a3ddc54..9bdbed4 100644 (file)
@@ -128,6 +128,18 @@ void CTGitPath::SetFromGit(const char* pPath, bool bIsDirectory)
        m_bIsDirectory = bIsDirectory;\r
 }\r
 \r
+void CTGitPath::SetFromGit(const TCHAR* pPath, bool bIsDirectory)\r
+{\r
+       Reset();\r
+       if (pPath)\r
+       {\r
+               m_sFwdslashPath = pPath;\r
+               SanitizeRootPath(m_sFwdslashPath, true);\r
+       }\r
+       m_bDirectoryKnown = true;\r
+       m_bIsDirectory = bIsDirectory;\r
+}\r
+\r
 void CTGitPath::SetFromGit(const CString& sPath,CString *oldpath)\r
 {\r
        Reset();\r
@@ -416,6 +428,17 @@ void CTGitPath::UpdateAttributes() const
        m_bExistsKnown = true;\r
 }\r
 \r
+CTGitPath CTGitPath::GetSubPath(CTGitPath &root)\r
+{\r
+       CTGitPath path;\r
+       \r
+       if(GetWinPathString().Left(root.GetWinPathString().GetLength()) == root.GetWinPathString())\r
+       {\r
+               CString str=GetWinPathString();\r
+               path.SetFromWin(str.Right(str.GetLength()-root.GetWinPathString().GetLength()-1));\r
+       }\r
+       return path;\r
+}\r
 \r
 void CTGitPath::EnsureBackslashPathSet() const\r
 {\r
@@ -538,7 +561,7 @@ CString CTGitPath::GetBaseFilename() const
        CString filename=GetFilename();\r
        dot = filename.ReverseFind(_T('.'));\r
        if(dot>0)\r
-               return filename.Left(dot-1);\r
+               return filename.Left(dot);\r
        else\r
                return filename;\r
 }\r
@@ -737,6 +760,11 @@ 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
 bool CTGitPath::HasAdminDir(CString *ProjectTopDir) const\r
 {\r
        if (m_bHasAdminDirKnown)\r
@@ -862,7 +890,7 @@ int CTGitPathList::ParserFromLsFile(BYTE_VECTOR &out,bool staged)
                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
@@ -929,7 +957,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
@@ -960,6 +988,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
@@ -997,24 +1030,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
@@ -1048,18 +1090,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
@@ -1073,6 +1115,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
@@ -1867,18 +1910,25 @@ CTGitPath * CTGitPathList::LookForGitPath(CString path)
 }\r
 CString CTGitPath::GetActionName(int action)\r
 {\r
+       if(action  & CTGitPath::LOGACTIONS_UNMERGED)\r
+               return _T("Conflict");\r
        if(action  & CTGitPath::LOGACTIONS_ADDED)\r
                return _T("Added");\r
        if(action  & CTGitPath::LOGACTIONS_DELETED)\r
                return _T("Deleted");\r
-       if(action  & CTGitPath::LOGACTIONS_UNMERGED)\r
-               return _T("Conflict");\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
@@ -1899,3 +1949,4 @@ int CTGitPathList::GetAction()
 {\r
        return m_Action;\r
 }\r
+\r