#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
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
{ ShellMenuStashSave, MENUSTASHSAVE, IDI_COMMIT, IDS_MENUSTASHSAVE, IDS_MENUSTASHSAVE,\r
ITEMIS_INSVN, 0, ITEMIS_FOLDERINSVN, 0, 0, 0, 0, 0 },\r
{ ShellMenuStashApply, MENUSTASHAPPLY, IDI_RELOCATE, IDS_MENUSTASHAPPLY, IDS_MENUSTASHAPPLY,\r
- ITEMIS_INSVN, 0, ITEMIS_FOLDERINSVN, 0, 0, 0, 0, 0 },\r
+ ITEMIS_INSVN|ITEMIS_STASH, 0, ITEMIS_FOLDERINSVN|ITEMIS_STASH, 0, 0, 0, 0, 0 },\r
+ { ShellMenuStashPop, MENUSTASHPOP, IDI_RELOCATE, IDS_MENUSTASHPOP, IDS_MENUSTASHPOP,\r
+ ITEMIS_INSVN|ITEMIS_STASH, 0, ITEMIS_FOLDERINSVN|ITEMIS_STASH, 0, 0, 0, 0, 0 },\r
{ ShellMenuStashList, MENUSTASHAPPLY, IDI_LOG, IDS_MENUSTASHLIST, IDS_MENUSTASHLIST,\r
ITEMIS_INSVN|ITEMIS_EXTENDED, 0, ITEMIS_FOLDERINSVN|ITEMIS_EXTENDED, 0, 0, 0, 0, 0 },\r
\r
\r
// TODO: should we really assume any sub-directory to be versioned\r
// or only if it contains versioned files\r
- if ( askedpath.IsDirectory() )\r
- {\r
- if (askedpath.HasAdminDir())\r
- itemStates |= ITEMIS_INSVN;\r
- if (askedpath.HasSubmodules())\r
- {\r
- itemStates |= ITEMIS_SUBMODULE;\r
- }\r
- }\r
- if (askedpath.HasGitSVNDir())\r
- itemStates |= ITEMIS_GITSVN;\r
- if ((status != git_wc_status_unversioned)&&(status != git_wc_status_ignored)&&(status != git_wc_status_none))\r
- itemStates |= ITEMIS_INSVN;\r
+ itemStates |= askedpath.GetAdminDirMask();\r
+ \r
+ if ((status == git_wc_status_unversioned) || (status == git_wc_status_ignored) || (status == git_wc_status_none))\r
+ itemStates &= ~ITEMIS_INSVN;\r
+\r
if (status == git_wc_status_ignored)\r
itemStates |= ITEMIS_IGNORED;\r
if (status == git_wc_status_normal)\r
}\r
}\r
\r
- // TODO: should we really assume any sub-directory to be versioned\r
- // or only if it contains versioned files\r
- if ( strpath.IsDirectory() )\r
- {\r
- if (strpath.HasAdminDir())\r
- itemStates |= ITEMIS_INSVN;\r
- if (strpath.HasSubmodules())\r
- {\r
- itemStates |= ITEMIS_SUBMODULE;\r
- }\r
- }\r
+ itemStates |= strpath.GetAdminDirMask(); \r
\r
- if (strpath.HasGitSVNDir())\r
- itemStates |= ITEMIS_GITSVN; \r
-\r
- if ((status != git_wc_status_unversioned)&&(status != git_wc_status_ignored)&&(status != git_wc_status_none))\r
- itemStates |= ITEMIS_INSVN;\r
+ if ((status == git_wc_status_unversioned)||(status == git_wc_status_ignored)||(status == git_wc_status_none))\r
+ itemStates &= ~ITEMIS_INSVN;\r
if (status == git_wc_status_ignored)\r
{\r
itemStates |= ITEMIS_IGNORED;\r
}\r
\r
//if ((status != git_wc_status_unversioned)&&(status != git_wc_status_ignored)&&(status != git_wc_status_none))\r
- if (askedpath.HasGitSVNDir())\r
- itemStatesFolder |= ITEMIS_GITSVN; \r
- if (askedpath.HasAdminDir())\r
- itemStatesFolder |= ITEMIS_INSVN;\r
+ itemStatesFolder |= askedpath.GetAdminDirMask(); \r
+ \r
if (status == git_wc_status_normal)\r
itemStatesFolder |= ITEMIS_NORMAL;\r
if (status == git_wc_status_conflicted)\r
status = fetchedstatus;\r
}\r
//if ((status != git_wc_status_unversioned)&&(status != git_wc_status_ignored)&&(status != git_wc_status_none))\r
- if (askedpath.HasAdminDir())\r
- {\r
- itemStatesFolder |= ITEMIS_FOLDERINSVN;\r
- }\r
- if (askedpath.HasSubmodules())\r
- {\r
- itemStatesFolder |= ITEMIS_SUBMODULE;\r
- }\r
- if (askedpath.HasGitSVNDir())\r
- {\r
- itemStatesFolder |= ITEMIS_GITSVN;\r
- }\r
+ itemStatesFolder |= askedpath.GetAdminDirMask();\r
+ \r
if (status == git_wc_status_ignored)\r
itemStatesFolder |= ITEMIS_IGNORED;\r
itemStatesFolder |= ITEMIS_FOLDER;\r
status = fetchedstatus;\r
}\r
//if ((status != git_wc_status_unversioned)&&(status != git_wc_status_ignored)&&(status != git_wc_status_none))\r
- if (askedpath.HasAdminDir())\r
- itemStates |= ITEMIS_FOLDERINSVN;\r
- if (askedpath.HasGitSVNDir())\r
- itemStates |= ITEMIS_GITSVN;\r
+ itemStates |= askedpath.GetAdminDirMask();\r
+ \r
if (status == git_wc_status_ignored)\r
itemStates |= ITEMIS_IGNORED;\r
itemStates |= ITEMIS_FOLDER;\r
svnCmd += _T("\"");\r
break;\r
\r
+ case ShellMenuStashPop:\r
+ svnCmd += _T("stashpop /path:\"");\r
+ if (files_.size() > 0)\r
+ svnCmd += files_.front();\r
+ else\r
+ svnCmd += folder_;\r
+ svnCmd += _T("\"");\r
+ break;\r
+\r
+\r
case ShellMenuStashList:\r
svnCmd += _T("reflog /path:\"");\r
if (files_.size() > 0)\r