OSDN Git Service

Fix Issue 31 in tortoisegit: Init Repository, Commit dialog can show added file
authorFrank Li <lznuaa@gmail.com>
Thu, 5 Feb 2009 15:45:28 +0000 (23:45 +0800)
committerFrank Li <lznuaa@gmail.com>
Thu, 5 Feb 2009 15:45:28 +0000 (23:45 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/Git/GitStatusListCtrl.cpp

index 6cb5570..ff45d93 100644 (file)
@@ -5253,40 +5253,62 @@ int CGitStatusListCtrl::UpdateFileList(git_revnum_t hash,CTGitPathList *list)
                        BYTE_VECTOR cmdout;\r
                        cmdout.clear();\r
                        CString cmd;\r
-                       if(list == NULL)\r
-                               cmd=(_T("git.exe diff-index --raw HEAD --numstat -C -M -z"));\r
-                       else\r
-                               cmd.Format(_T("git.exe diff-index  --raw HEAD --numstat -C -M -z -- \"%s\""),(*list)[i].GetGitPathString());\r
-\r
-                       if(g_Git.Run(cmd,&cmdout))\r
+                       if(!g_Git.IsInitRepos())\r
                        {\r
-                               cmdout.clear();\r
-                               CString strout;\r
-                               if(g_Git.Run(_T("git.exe rev-parse --revs-only HEAD"),&strout,CP_UTF8))\r
+                               if(list == NULL)\r
+                                       cmd=(_T("git.exe diff-index --raw HEAD --numstat -C -M -z"));\r
+                               else\r
+                                       cmd.Format(_T("git.exe diff-index  --raw HEAD --numstat -C -M -z -- \"%s\""),(*list)[i].GetGitPathString());\r
+       \r
+                               if(g_Git.Run(cmd,&cmdout))\r
                                {\r
+                                       cmdout.clear();\r
+                                       CString strout;\r
+                                       if(g_Git.Run(_T("git.exe rev-parse --revs-only HEAD"),&strout,CP_UTF8))\r
+                                       {\r
+                                               CMessageBox::Show(NULL,strout,_T("TortoiseGit"),MB_OK);\r
+                                               return -1;\r
+                                       }\r
+                                       if(strout.IsEmpty())\r
+                                               break; //this is initial repositoyr, there are no any history\r
+\r
                                        CMessageBox::Show(NULL,strout,_T("TortoiseGit"),MB_OK);\r
                                        return -1;\r
-                               }\r
-                               if(strout.IsEmpty())\r
-                                       break; //this is initial repositoyr, there are no any history\r
 \r
-                               CMessageBox::Show(NULL,strout,_T("TortoiseGit"),MB_OK);\r
-                               return -1;\r
+                               }\r
+                               \r
+                               if(list == NULL)\r
+                                       cmd=(_T("git.exe diff-index --cached --raw HEAD --numstat -C -M -z"));\r
+                               else\r
+                                       cmd.Format(_T("git.exe diff-index  --cached --raw HEAD --numstat -C -M -z -- \"%s\""),(*list)[i].GetGitPathString());\r
 \r
+                               g_Git.Run(cmd,&cmdout);\r
+                               //out+=cmdout;\r
+                               out.append(cmdout,0);\r
                        }\r
-                       \r
-                       if(list == NULL)\r
-                               cmd=(_T("git.exe diff-index --cached --raw HEAD --numstat -C -M -z"));\r
-                       else\r
-                               cmd.Format(_T("git.exe diff-index  --cached --raw HEAD --numstat -C -M -z -- \"%s\""),(*list)[i].GetGitPathString());\r
+                       else // Init Repository\r
+                       {\r
+                               if(list == NULL)\r
+                                       cmd=_T("git.exe ls-files -s -t -z");\r
+                               else\r
+                                       cmd.Format(_T("git.exe ls-files -s -t -z -- \"%s\""),(*list)[i].GetGitPathString());\r
 \r
-                       g_Git.Run(cmd,&cmdout);\r
-                       //out+=cmdout;\r
-                       out.append(cmdout,0);\r
+                               g_Git.Run(cmd,&cmdout);\r
+                               //out+=cmdout;\r
+                               out.append(cmdout,0);\r
+                       }\r
                }\r
 \r
+               if(g_Git.IsInitRepos())\r
+               {\r
+                       m_StatusFileList.ParserFromLsFile(out);\r
+                       for(int i=0;i<m_StatusFileList.GetCount();i++)\r
+                               ((CTGitPath&)(m_StatusFileList[i])).m_Action=CTGitPath::LOGACTIONS_ADDED;\r
+               }\r
+               else\r
+                       this->m_StatusFileList.ParserFromLog(out);\r
 \r
-               this->m_StatusFileList.ParserFromLog(out);\r
+               \r
        }else\r
        {\r
                int count = 0;\r