OSDN Git Service

Fix init repos commit\show log problem.
authorFrank Li <lznuaa@gmail.com>
Fri, 2 Jan 2009 02:58:09 +0000 (10:58 +0800)
committerFrank Li <lznuaa@gmail.com>
Fri, 2 Jan 2009 02:58:09 +0000 (10:58 +0800)
Add init repos check

Signed-off-by: Frank Li <lznuaa@gmail.com>
src/Git/Git.cpp
src/Git/Git.h
src/Git/GitStatusListCtrl.cpp
src/Git/GitStatusListCtrl.h
src/Git/TGitPath.cpp
src/TortoiseProc/LogDataVector.cpp
src/TortoiseProc/LogDlg.cpp

index 7a4eede..13b74dd 100644 (file)
@@ -77,7 +77,20 @@ void CGit::StringAppend(CString *str,char *p)
        str->Append(A2W(p));\r
 \r
 }      \r
+BOOL CGit::IsInitRepos()\r
+{\r
+       CString cmdout;\r
+       cmdout.Empty();\r
+       if(g_Git.Run(_T("git.exe rev-parse --revs-only HEAD"),&cmdout))\r
+       {\r
+       //      CMessageBox::Show(NULL,cmdout,_T("TortoiseGit"),MB_OK);\r
+               return TRUE;\r
+       }\r
+       if(cmdout.IsEmpty())\r
+               return TRUE;\r
 \r
+       return FALSE;\r
+}\r
 int CGit::Run(CString cmd, CString* output)\r
 {\r
        PROCESS_INFORMATION pi;\r
index d01987f..d5eeae8 100644 (file)
@@ -55,6 +55,8 @@ public:
        int BuildOutputFormat(CString &format,bool IsFull=TRUE);\r
        int GetShortLog(CString &log,CTGitPath * path=NULL, int count =-1);\r
        static void StringAppend(CString *str,char *p);\r
+\r
+       BOOL IsInitRepos();\r
        \r
 };\r
 extern void GetTempPath(CString &path);\r
index 92c4a96..9fb6a37 100644 (file)
@@ -1047,7 +1047,7 @@ DWORD CGitStatusListCtrl::GetShowFlagsFromGitStatus(git_wc_status_kind status)
        return 0;\r
 }\r
 \r
-void CGitStatusListCtrl::Show(DWORD dwShow, DWORD dwCheck /*=0*/, bool bShowFolders /* = true */)\r
+void CGitStatusListCtrl::Show(DWORD dwShow, DWORD dwCheck /*=0*/, bool bShowFolders /* = true */,BOOL UpdateStatusList)\r
 {\r
        CWinApp * pApp = AfxGetApp();\r
        if (pApp)\r
@@ -1062,6 +1062,24 @@ void CGitStatusListCtrl::Show(DWORD dwShow, DWORD dwCheck /*=0*/, bool bShowFold
        PrepareGroups();\r
        m_nSelected = 0;\r
 \r
+       if(UpdateStatusList)\r
+       {\r
+               m_arStatusArray.clear();\r
+               for(int i=0;i<this->m_StatusFileList.GetCount();i++)\r
+               {\r
+                       m_arStatusArray.push_back((CTGitPath*)&m_StatusFileList[i]);\r
+               }\r
+\r
+               for(int i=0;i<this->m_UnRevFileList.GetCount();i++)\r
+               {\r
+                       m_arStatusArray.push_back((CTGitPath*)&m_UnRevFileList[i]);\r
+               }\r
+\r
+               for(int i=0;i<this->m_IgnoreFileList.GetCount();i++)\r
+               {\r
+                       m_arStatusArray.push_back((CTGitPath*)&m_IgnoreFileList[i]);\r
+               }\r
+       }\r
        for(int i=0;i<this->m_arStatusArray.size();i++)\r
        {\r
                if(((CTGitPath*)m_arStatusArray[i])->m_Action & dwShow)\r
@@ -2357,7 +2375,9 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point)
                                        //      {\r
                                        //              if ((m_dwContextMenus & SVNSLC_POPGNUDIFF)&&(wcStatus != git_wc_status_deleted)&&(wcStatus != git_wc_status_missing))\r
                                        //              {\r
-                                       popup.AppendMenuIcon(IDSVNLC_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);\r
+                                       if(!g_Git.IsInitRepos())\r
+                                               popup.AppendMenuIcon(IDSVNLC_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);\r
+\r
                                        bEntryAdded = true;\r
                                        //              }\r
                                        //      }\r
@@ -2754,7 +2774,7 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point)
                                                        this->m_StatusFileList.AddPath(*path);\r
                                                        this->m_UnRevFileList.RemoveItem(*path);\r
                                                        this->m_IgnoreFileList.RemoveItem(*path);\r
-                                                       Show(this->m_dwShow);\r
+                                                       Show(this->m_dwShow,0,true,true);\r
                                                }\r
                                        }\r
                                        \r
@@ -4088,9 +4108,13 @@ void CGitStatusListCtrl::StartDiff(int fileindex)
                return;\r
        if(this->m_CurrentVersion.IsEmpty() || m_CurrentVersion== GIT_REV_ZERO)\r
        {\r
-               CGitDiff::Diff((CTGitPath*)GetItemData(fileindex),\r
+               if(!g_Git.IsInitRepos())\r
+                       CGitDiff::Diff((CTGitPath*)GetItemData(fileindex),\r
                                CString(GIT_REV_ZERO),\r
                                        GitRev::GetHead());\r
+               else\r
+                       CGitDiff::DiffNull((CTGitPath*)GetItemData(fileindex),\r
+                               CString(GIT_REV_ZERO));\r
        }else\r
        {\r
                CGitDiff::Diff((CTGitPath*)GetItemData(fileindex),\r
index 21233a9..06dbad5 100644 (file)
@@ -525,7 +525,7 @@ public:
         * \param dwShow mask of file types to show. Use the GitSLC_SHOWxxx defines.\r
         * \param dwCheck mask of file types to check. Use GitLC_SHOWxxx defines. Default (0) means 'use the entry's stored check status'\r
         */\r
-       void Show(DWORD dwShow, DWORD dwCheck = 0, bool bShowFolders = true);\r
+       void Show(DWORD dwShow, DWORD dwCheck = 0, bool bShowFolders = true,BOOL updateStatusList=FALSE);\r
        void Show(DWORD dwShow, const CTGitPathList& checkedList, bool bShowFolders = true);\r
 \r
        /**\r
index 7a40b7a..b0aec5c 100644 (file)
@@ -855,11 +855,13 @@ int CTGitPathList::FillUnRev(int action,CTGitPathList *list)
                while( pos>=0 )\r
                {\r
                        one=out.Tokenize(_T("\n"),pos);\r
-\r
-                       //SetFromGit will clear all status\r
-                       path.SetFromGit(one);\r
-                       path.m_Action=action;\r
-                       AddPath(path);\r
+                       if(!one.IsEmpty())\r
+                       {\r
+                               //SetFromGit will clear all status\r
+                               path.SetFromGit(one);\r
+                               path.m_Action=action;\r
+                               AddPath(path);\r
+                       }\r
                }\r
        }\r
        return 0;\r
index e33cea1..7852ca5 100644 (file)
@@ -68,6 +68,9 @@ int CLogDataVector::ParserShortLog(CTGitPath *path ,int count  )
        CString log;
        GitRev rev;
 
+       if(g_Git.IsInitRepos())
+               return 0;
+
        CString begin;
        begin.Format(_T("#<%c>"),LOG_REV_ITEM_BEGIN);
 
index 937fca4..2cf2f61 100644 (file)
@@ -526,7 +526,7 @@ void CLogDlg::FillLogMessageCtrl(bool bShow /* = true*/)
 \r
                        m_ChangedFileListCtrl.UpdateWithGitPathList(pLogEntry->m_Files);\r
                        m_ChangedFileListCtrl.m_CurrentVersion=pLogEntry->m_CommitHash;\r
-                       m_ChangedFileListCtrl.Show(0);\r
+                       m_ChangedFileListCtrl.Show(SVNSLC_SHOWVERSIONED);\r
 \r
                        m_ChangedFileListCtrl.SetRedraw(TRUE);\r
                        return;\r