Esempio n. 1
0
CTGitPath CTGitPathList::GetCommonRoot() const
{
	if (IsEmpty())
		return CTGitPath();

	if (GetCount() == 1)
		return m_paths[0];

	// first entry is common root for itself
	// (add trailing '\\' to detect partial matches of the last path element)
	CString root = m_paths[0].GetWinPathString() + _T('\\');
	int rootLength = root.GetLength();

	// determine common path string prefix
	for (PathVector::const_iterator it = m_paths.begin() + 1; it != m_paths.end(); ++it)
	{
		CString path = it->GetWinPathString() + _T('\\');

		int newLength = CStringUtils::GetMatchingLength(root, path);
		if (newLength != rootLength)
		{
			root.Delete(newLength, rootLength);
			rootLength = newLength;
		}
	}

	// remove the last (partial) path element
	if (rootLength > 0)
		root.Delete(root.ReverseFind(_T('\\')), rootLength);

	// done
	return CTGitPath(root);
}
Esempio n. 2
0
CTGitPath CDirectoryWatcher::CloseInfoMap(HANDLE hDir)
{
	AutoLocker lock(m_critSec);
	TInfoMap::const_iterator d = watchInfoMap.find(hDir);
	if (d != watchInfoMap.end())
	{
		CTGitPath root = CTGitPath(CTGitPath(d->second->m_DirPath).GetRootPathString());
		RemovePathAndChildren(root);
		BlockPath(root);
	}
	CloseWatchHandles();

	CTGitPath path;
	if (watchInfoMap.empty())
		return path;

	for (TInfoMap::iterator I = watchInfoMap.begin(); I != watchInfoMap.end(); ++I)
	{
		CDirectoryWatcher::CDirWatchInfo * info = I->second;

		ScheduleForDeletion (info);
	}
	watchInfoMap.clear();

	return path;
}
Esempio n. 3
0
CTGitPath CTempFiles::CreateTempPath (bool bRemoveAtEnd, const CTGitPath& path, bool directory)
{
	bool succeeded = false;
	for (int retryCount = 0; retryCount < MAX_RETRIES; ++retryCount)
	{
		CTGitPath tempfile = ConstructTempPath (path);

		// now create the temp file / directory, so that subsequent calls to GetTempFile() return
		// different filenames.
		// Handle races, i.e. name collisions.

		if (directory)
		{
			DeleteFile(tempfile.GetWinPath());
			if (CreateDirectory(tempfile.GetWinPath(), nullptr) == FALSE)
			{
				if (GetLastError() != ERROR_ALREADY_EXISTS)
					return CTGitPath();
			}
			else
				succeeded = true;
		}
		else
		{
			CAutoFile hFile = CreateFile(tempfile.GetWinPath(), GENERIC_READ, FILE_SHARE_READ, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, nullptr);
			if (!hFile)
			{
				if (GetLastError() != ERROR_ALREADY_EXISTS)
					return CTGitPath();
			}
			else
			{
				succeeded = true;
			}
		}

		// done?

		if (succeeded)
		{
			if (bRemoveAtEnd)
				m_TempFileList.AddPath(tempfile);

			return tempfile;
		}
	}

	// give up

	return CTGitPath();
}
void CRequestPullDlg::OnBnClickedButtonLocalBranch()
{
	// use the git log to allow selection of a version
	CLogDlg dlg;
	CString revision;
	m_cStartRevision.GetWindowText(revision);
	dlg.SetParams(CTGitPath(), CTGitPath(), revision, revision, 0);
	// tell the dialog to use mode for selecting revisions
	dlg.SetSelect(true);
	// only one revision must be selected however
	dlg.SingleSelection(true);
	if ( dlg.DoModal() == IDOK )
		m_cStartRevision.SetWindowText(dlg.GetSelectedHash().at(0).ToString());
}
Esempio n. 5
0
void CSetHooks::OnBnClickedEditbutton()
{

	if (m_cHookList.GetSelectedCount() > 1)
		return;
	POSITION pos = m_cHookList.GetFirstSelectedItemPosition();
	if (pos)
	{
		CSetHooksAdv dlg;
		int index = m_cHookList.GetNextSelectedItem(pos);
		dlg.key.htype = CHooks::GetHookType((LPCTSTR)m_cHookList.GetItemText(index, 0));
		dlg.key.path = CTGitPath(m_cHookList.GetItemText(index, 1));
		dlg.cmd.commandline = m_cHookList.GetItemText(index, 2);
		dlg.cmd.bWait = (m_cHookList.GetItemText(index, 3).Compare(_T("true"))==0);
		dlg.cmd.bShow = (m_cHookList.GetItemText(index, 4).Compare(_T("show"))==0);
		hookkey key = dlg.key;
		if (dlg.DoModal() == IDOK)
		{
			CHooks::Instance().Remove(key);
			CHooks::Instance().Add(dlg.key.htype, dlg.key.path, dlg.cmd.commandline, dlg.cmd.bWait, dlg.cmd.bShow);
			RebuildHookList();
			SetModified();
		}
	}

}
Esempio n. 6
0
bool CLogFile::Open()
{
	if (m_maxlines == 0)
		return false;
	CTGitPath logfile = CTGitPath(CPathUtils::GetLocalAppDataDirectory() + _T("logfile.txt"));
	return Open(logfile);
}
Esempio n. 7
0
int CSendMailPatch::SendAsCombinedMail(CTGitPathList &list, CGitProgressList * instance)
{
	ASSERT(instance);

	CStringArray attachments;
	CString body;
	for (int i = 0; i < list.GetCount(); ++i)
	{
		CPatch patch;
		if (patch.Parse((CString &)list[i].GetWinPathString()))
		{
			instance->ReportError(_T("Could not open/parse ") + list[i].GetWinPathString());
			return -2;
		}
		if (m_bAttachment)
		{
			attachments.Add(list[i].GetWinPathString());
			body += patch.m_Subject;
			body += _T("\r\n");
		}
		else
		{
			try
			{
				g_Git.StringAppend(&body, (BYTE*)patch.m_Body.GetBuffer(), CP_UTF8, patch.m_Body.GetLength());
			}
			catch (CMemoryException *)
			{
				instance->ReportError(_T("Out of memory. Could not parse ") + list[i].GetWinPathString());
				return -2;
			}
		}
	}
	return SendMail(CTGitPath(), instance, m_sSenderName, m_sSenderMail, m_sTo, m_sCC, m_sSubject, body, attachments);
}
Esempio n. 8
0
/**
 * Returns the .git-path (if .git is a file, read the repository path and return it)
 * adminDir always ends with "\"
 */
bool GitAdminDir::GetAdminDirPath(const CString &projectTopDir, CString& adminDir)
{
	if (IsBareRepo(projectTopDir))
	{
		adminDir = projectTopDir;
		adminDir.TrimRight('\\');
		adminDir.Append(_T("\\"));
		return true;
	}

	CString sDotGitPath = projectTopDir + _T("\\") + GetAdminDirName();
	if (CTGitPath(sDotGitPath).IsDirectory())
	{
		sDotGitPath.TrimRight('\\');
		sDotGitPath.Append(_T("\\"));
		adminDir = sDotGitPath;
		return true;
	}
	else
	{
		CString result = ReadGitLink(projectTopDir, sDotGitPath);
		if (result.IsEmpty())
			return false;
		adminDir = result + _T("\\");
		return true;
	}
}
Esempio n. 9
0
int CSendMailCombineable::SendAsCombinedMail(const CTGitPathList &list, CGitProgressList* instance)
{
	ASSERT(instance);

	CStringArray attachments;
	CString body;
	for (int i = 0; i < list.GetCount(); ++i)
	{
		if (m_bAttachment)
		{
			attachments.Add(list[i].GetWinPathString());
		}
		else
		{
			CString filename(list[i].GetWinPathString());
			body += filename + _T(":\n");
			if (GetFileContents(filename, body))
			{
				instance->ReportError(_T("Could not open ") + filename);
				return -2;
			}
			body += _T("\n");
		}
	}
	return SendMail(CTGitPath(), instance, m_sSenderName, m_sSenderMail, m_sTo, m_sCC, m_sSubject, body, attachments);
}
BOOL CSubmoduleUpdateDlg::OnInitDialog()
{
    CStandAloneDialog::OnInitDialog();
    CAppUtils::MarkWindowAsUnpinnable(m_hWnd);

    CString sWindowTitle;
    GetWindowText(sWindowTitle);
    CString dir = g_Git.m_CurrentDir;
    if (m_PathFilterList.size() > 0)
        dir += (g_Git.m_CurrentDir.Right(1) == _T('\\') ? _T("") : _T("\\")) + CTGitPath(m_PathFilterList[0]).GetWinPathString();
    if (m_PathFilterList.size() > 1)
        dir += _T(", ...");
    CAppUtils::SetWindowTitle(m_hWnd, dir, sWindowTitle);

    AdjustControlSize(IDC_CHECK_SUBMODULE_INIT);
    AdjustControlSize(IDC_CHECK_SUBMODULE_RECURSIVE);
    AdjustControlSize(IDC_CHECK_SUBMODULE_NOFETCH);
    AdjustControlSize(IDC_CHECK_SUBMODULE_MERGE);
    AdjustControlSize(IDC_CHECK_SUBMODULE_REBASE);

    Refresh();
    UpdateData(FALSE);

    return TRUE;
}
Esempio n. 11
0
void CSetHooksAdv::OnOK()
{
	UpdateData();
	int cursel = m_cHookTypeCombo.GetCurSel();
	key.htype = unknown_hook;
	if (cursel != CB_ERR)
	{
		key.htype = (hooktype)m_cHookTypeCombo.GetItemData(cursel);
		key.path = CTGitPath(m_sPath);
		cmd.commandline = m_sCommandLine;
		cmd.bWait = !!m_bWait;
		cmd.bShow = !m_bHide;
	}
	if (key.htype == unknown_hook)
	{
		m_tooltips.ShowBalloon(IDC_HOOKTYPECOMBO, IDS_ERR_NOHOOKTYPESPECIFIED, IDS_ERR_ERROR, TTI_ERROR);
		return;
	}
	if (key.path.IsEmpty())
	{
		ShowEditBalloon(IDC_HOOKPATH, IDS_ERR_NOHOOKPATHSPECIFIED, IDS_ERR_ERROR, TTI_ERROR);
		return;
	}
	if (cmd.commandline.IsEmpty())
	{
		ShowEditBalloon(IDC_HOOKCOMMANDLINE, IDS_ERR_NOHOOKCOMMANDPECIFIED, IDS_ERR_ERROR, TTI_ERROR);
		return;
	}

	CResizableStandAloneDialog::OnOK();
}
Esempio n. 12
0
const_hookiterator CHooks::FindItem(hooktype t, const CString& workingTree) const
{
	hookkey key;
	CTGitPath path = workingTree;
	do
	{
		key.htype = t;
		key.path = path;
		auto it = find(key);
		if (it != end())
		{
			return it;
		}
		path = path.GetContainingDirectory();
	} while(!path.IsEmpty());
	// look for a script with a path as '*'
	key.htype = t;
	key.path = CTGitPath(_T("*"));
	auto it = find(key);
	if (it != end())
	{
		return it;
	}

	return end();
}
Esempio n. 13
0
void CRepositoryBrowser::OnBnClickedButtonRevision()
{
		// use the git log to allow selection of a version
		CLogDlg dlg;
		dlg.SetParams(CTGitPath(), CTGitPath(), m_sRevision, m_sRevision, 0);
		// tell the dialog to use mode for selecting revisions
		dlg.SetSelect(true);
		// only one revision must be selected however
		dlg.SingleSelection(true);
		if (dlg.DoModal() == IDOK)
		{
			// get selected hash if any
			m_sRevision = dlg.GetSelectedHash();
			Refresh();
		}
}
Esempio n. 14
0
hookiterator CHooks::FindItem(hooktype t, const CTGitPathList& pathList)
{
	hookkey key;
	for (int i=0; i<pathList.GetCount(); ++i)
	{
		CTGitPath path = pathList[i];
		do 
		{
			key.htype = t;
			key.path = path;
			hookiterator it = find(key);
			if (it != end())
			{
				return it;
			}
			path = path.GetContainingDirectory();
		} while(!path.IsEmpty());
	}
	// look for a script with a path as '*'
	key.htype = t;
	key.path = CTGitPath(_T("*"));
	hookiterator it = find(key);
	if (it != end())
	{
		return it;
	}

	return end();
}
Esempio n. 15
0
void CSyncDlg::RunPostAction()
{
	if (m_bWantToExit)
		return;

	FillNewRefMap();

	if (this->m_CurrentCmd == GIT_COMMAND_PUSH)
	{
		if (!m_GitCmdStatus)
		{
			CTGitPathList list;
			list.AddPath(CTGitPath(g_Git.m_CurrentDir));
			DWORD exitcode;
			CString error;
			if (CHooks::Instance().PostPush(list,exitcode, error))
			{
				if (exitcode)
				{
					CString temp;
					temp.Format(IDS_ERR_HOOKFAILED, (LPCTSTR)error);
					//ReportError(temp);
					CMessageBox::Show(NULL,temp,_T("TortoiseGit"),MB_OK|MB_ICONERROR);
					return;
				}
			}

		}
		EnableControlButton(true);
		SwitchToInput();
		this->FetchOutList(true);
	}
	else if (this->m_CurrentCmd == GIT_COMMAND_PULL)
	{
		PullComplete();
	}
	else if (this->m_CurrentCmd == GIT_COMMAND_FETCH || this->m_CurrentCmd == GIT_COMMAND_FETCHANDREBASE)
	{
		FetchComplete();
	}
	else if (this->m_CurrentCmd == GIT_COMMAND_SUBMODULE)
	{
		//this->m_ctrlCmdOut.SetSel(-1,-1);
		//this->m_ctrlCmdOut.ReplaceSel(_T("Done\r\n"));
		//this->m_ctrlCmdOut.SetSel(-1,-1);
		EnableControlButton(true);
		SwitchToInput();
	}
	else if (this->m_CurrentCmd == GIT_COMMAND_STASH)
	{
		StashComplete();
	}
	else if (this->m_CurrentCmd == GIT_COMMAND_REMOTE)
	{
		this->FetchOutList(true);
		EnableControlButton(true);
		SwitchToInput();
		ShowTab(IDC_REFLIST);
	}
}
Esempio n. 16
0
void CGitBlameLogList::GetPaths(const CGitHash& hash, std::vector<CTGitPath>& paths)
{
	CTortoiseGitBlameView *pView = DYNAMIC_DOWNCAST(CTortoiseGitBlameView,((CMainFrame*)::AfxGetApp()->GetMainWnd())->GetActiveView());
	if (pView)
	{
		{
			std::set<CString> filenames;
			int numberOfLines = pView->m_data.GetNumberOfLines();
			for (int i = 0; i < numberOfLines; ++i)
			{
				if (pView->m_data.GetHash(i) == hash)
				{
					filenames.insert(pView->m_data.GetFilename(i));
				}
			}
			for (auto it = filenames.cbegin(); it != filenames.cend(); ++it)
			{
				paths.push_back(CTGitPath(*it));
			}
		}
		if (paths.empty())
		{
			// in case the hash does not exist in the blame output but it exists in the log follow only the file
			paths.push_back(pView->GetDocument()->m_GitPath);
		}
	}
}
Esempio n. 17
0
const FileStatusCacheEntry * GitFolderStatus::GetCachedItem(const CTGitPath& filepath)
{
	sCacheKey.assign(filepath.GetWinPath());
	FileStatusMap::const_iterator iter;
	const FileStatusCacheEntry *retVal;

	if(m_mostRecentPath.IsEquivalentTo(CTGitPath(sCacheKey.c_str())))
	{
		// We've hit the same result as we were asked for last time
		CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) _T(": fast cache hit for %s\n"), filepath.GetWinPath());
		retVal = m_mostRecentStatus;
	}
	else if ((iter = m_cache.find(sCacheKey)) != m_cache.end())
	{
		CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) _T(": cache found for %s\n"), filepath.GetWinPath());
		retVal = &iter->second;
		m_mostRecentStatus = retVal;
		m_mostRecentPath = CTGitPath(sCacheKey.c_str());
	}
	else
	{
		retVal = NULL;
	}

	if(retVal != NULL)
	{
		// We found something in a cache - check that the cache is not timed-out or force-invalidated
		DWORD now = GetTickCount();

		if ((now >= m_TimeStamp)&&((now - m_TimeStamp) > GetTimeoutValue()))
		{
			// Cache is timed-out
			CTraceToOutputDebugString::Instance()(__FUNCTION__ ": Cache timed-out\n");
			ClearCache();
			retVal = NULL;
		}
		else if(WaitForSingleObject(m_hInvalidationEvent, 0) == WAIT_OBJECT_0)
		{
			// TortoiseGitProc has just done something which has invalidated the cache
			CTraceToOutputDebugString::Instance()(__FUNCTION__ ": Cache invalidated\n");
			ClearCache();
			retVal = NULL;
		}
		return retVal;
	}
	return NULL;
}
Esempio n. 18
0
bool FormatPatchCommand::Execute()
{
	CFormatPatchDlg dlg;
//	dlg.m_bIsTag=TRUE;
	CString startval = parser.GetVal(L"startrev");
	CString endval = parser.GetVal(L"endrev");

	if( endval.IsEmpty() && (!startval.IsEmpty()))
	{
		dlg.m_Since=startval;
		dlg.m_Radio = IDC_RADIO_SINCE;
	}
	else if( (!endval.IsEmpty()) && (!startval.IsEmpty()))
	{
		dlg.m_From=startval;
		dlg.m_To=endval;
		dlg.m_Radio = IDC_RADIO_RANGE;
	}

	if(dlg.DoModal()==IDOK)
	{
		CString cmd;
		CString range;

		switch(dlg.m_Radio)
		{
		case IDC_RADIO_SINCE:
			range=g_Git.FixBranchName(dlg.m_Since);
			break;
		case IDC_RADIO_NUM:
			range.Format(L"-%d", dlg.m_Num);
			break;
		case IDC_RADIO_RANGE:
			range.Format(L"%s..%s", (LPCTSTR)dlg.m_From, (LPCTSTR)dlg.m_To);
			break;
		}
		dlg.m_Dir.Replace(L'\\', L'/');
		cmd.Format(L"git.exe format-patch%s -o \"%s\" %s",
			dlg.m_bNoPrefix ? L" --no-prefix" : L"",
			(LPCTSTR)dlg.m_Dir,
			(LPCTSTR)range
			);

		CProgressDlg progress;
		progress.m_GitCmd=cmd;
		progress.DoModal();

		CShellUpdater::Instance().AddPathForUpdate(CTGitPath(dlg.m_Dir));
		CShellUpdater::Instance().Flush();

		if(!progress.m_GitStatus)
		{
			if(dlg.m_bSendMail)
				CAppUtils::SendPatchMail(cmd, progress.m_LogText, true);
		}
		return !progress.m_GitStatus;
	}
	return FALSE;
}
Esempio n. 19
0
void CFormatPatchDlg::OnBnClickedButtonTo()
{
	CLogDlg dlg;
	CString revision;
	m_cTo.GetWindowText(revision);
	dlg.SetParams(CTGitPath(), CTGitPath(), revision, revision, 0);
	// tell the dialog to use mode for selecting revisions
	dlg.SetSelect(true);
	// only one revision must be selected however
	dlg.SingleSelection(true);
	if (dlg.DoModal() == IDOK && !dlg.GetSelectedHash().empty())
	{
		m_cTo.AddString(dlg.GetSelectedHash().at(0).ToString());
		CheckRadioButton(IDC_RADIO_SINCE, IDC_RADIO_RANGE, IDC_RADIO_RANGE);
		OnBnClickedRadio();
	}
}
Esempio n. 20
0
CGitStatusCache::CGitStatusCache(void)
{
#define forever DWORD(-1)
    AutoLocker lock(m_NoWatchPathCritSec);
    TCHAR path[MAX_PATH];
    SHGetFolderPath(NULL, CSIDL_COOKIES, NULL, 0, path);
    m_NoWatchPaths[CTGitPath(CString(path))] = forever;
    SHGetFolderPath(NULL, CSIDL_HISTORY, NULL, 0, path);
    m_NoWatchPaths[CTGitPath(CString(path))] = forever;
    SHGetFolderPath(NULL, CSIDL_INTERNET_CACHE, NULL, 0, path);
    m_NoWatchPaths[CTGitPath(CString(path))] = forever;
    SHGetFolderPath(NULL, CSIDL_SYSTEM, NULL, 0, path);
    m_NoWatchPaths[CTGitPath(CString(path))] = forever;
    SHGetFolderPath(NULL, CSIDL_WINDOWS, NULL, 0, path);
    m_NoWatchPaths[CTGitPath(CString(path))] = forever;
    m_bClearMemory = false;
    m_mostRecentExpiresAt = 0;
}
git_error_t* GitFolderStatus::findfolderstatus(void * baton, const char * path, git_wc_status2_t * status, apr_pool_t * /*pool*/)
{
    GitFolderStatus * Stat = (GitFolderStatus *)baton;
    if ((Stat)&&(Stat->folderpath.IsEquivalentTo(CTGitPath(CString(path)))))
    {
        Stat->dirstatus = status;
    }

    return GIT_NO_ERROR;
}
Esempio n. 22
0
void CRequestPullDlg::OnBnClickedButtonLocalBranch()
{
	// use the git log to allow selection of a version
	CLogDlg dlg;
	CString revision;
	m_cStartRevision.GetWindowText(revision);
	dlg.SetParams(CTGitPath(), CTGitPath(), revision, revision, 0);
	// tell the dialog to use mode for selecting revisions
	dlg.SetSelect(true);
	// only one revision must be selected however
	dlg.SingleSelection(true);
	if ( dlg.DoModal() == IDOK )
	{
		// get selected hash if any
		CString selectedHash = dlg.GetSelectedHash();
		// load into window, do this even if empty so that it is clear that nothing has been selected
		m_cStartRevision.SetWindowText( selectedHash );
	}
}
Esempio n. 23
0
// ICopyHook member
UINT __stdcall CShellExt::CopyCallback(HWND /*hWnd*/, UINT wFunc, UINT /*wFlags*/, LPCTSTR pszSrcFile, DWORD /*dwSrcAttribs*/, LPCTSTR /*pszDestFile*/, DWORD /*dwDestAttribs*/)
{
	if (wFunc == FO_COPY)
		return IDYES;	// copying is not a problem for us

	m_remoteCacheLink.ReleaseLockForPath(CTGitPath(pszSrcFile));
	// we could now wait a little bit to give the cache time to release the handles.
	// but the explorer/shell already retries any action for about two seconds
	// if it first fails. So if the cache hasn't released the handle yet, the explorer
	// will retry anyway, so we just leave here immediately.
	return IDYES;
}
Esempio n. 24
0
void CSubmoduleUpdateDlg::SetDlgTitle()
{
	if (m_sTitle.IsEmpty())
		GetWindowText(m_sTitle);
	CString dir = g_Git.m_CurrentDir;
	if (!m_bWholeProject)
	{
		if (!m_PathFilterList.empty())
			dir += (CStringUtils::EndsWith(g_Git.m_CurrentDir, L'\\') ? L"" : L"\\") + CTGitPath(m_PathFilterList[0]).GetWinPathString();
		if (m_PathFilterList.size() > 1)
			dir += L", ...";
	}
	CAppUtils::SetWindowTitle(m_hWnd, dir, m_sTitle);
}
Esempio n. 25
0
/**
 * Returns the .git-path (if .git is a file, read the repository path and return it)
 * adminDir always ends with "\"
 */
bool GitAdminDir::GetAdminDirPath(const CString &projectTopDir, CString &adminDir) const
{
	if (IsBareRepo(projectTopDir))
	{
		adminDir = projectTopDir;
		adminDir.TrimRight('\\');
		adminDir.Append(_T("\\"));
		return true;
	}

	CString sDotGitPath = projectTopDir + _T("\\") + g_GitAdminDir.GetAdminDirName();
	if (CTGitPath(sDotGitPath).IsDirectory())
	{
		sDotGitPath.TrimRight('\\');
		sDotGitPath.Append(_T("\\"));
		adminDir = sDotGitPath;
		return true;
	}
	else
	{
		FILE *pFile;
		_tfopen_s(&pFile, sDotGitPath, _T("r"));

		if (!pFile)
			return false;

		int size = 65536;
		std::unique_ptr<char[]> buffer(new char[size]);
		SecureZeroMemory(buffer.get(), size);
		fread(buffer.get(), sizeof(char), size, pFile);
		fclose(pFile);
		CStringA gitPathA(buffer.get());
		if (gitPathA.Left(8) != "gitdir: ")
			return false;
		CString gitPath = CUnicodeUtils::GetUnicode(gitPathA.Trim().Mid(8)); // 8 = len("gitdir: ")
		gitPath.Replace('/', '\\');
		gitPath.TrimRight('\\');
		gitPath.Append(_T("\\"));
		if (gitPath.GetLength() > 0 && gitPath[0] == _T('.'))
		{
			gitPath = projectTopDir + _T("\\") + gitPath;
			PathCanonicalize(adminDir.GetBuffer(MAX_PATH), gitPath.GetBuffer());
			adminDir.ReleaseBuffer();
			gitPath.ReleaseBuffer();
			return true;
		}
		adminDir = gitPath;
		return true;
	}
}
Esempio n. 26
0
void CTGitPathList::LoadFromAsteriskSeparatedString(const CString& sPathString)
{
	int pos = 0;
	CString temp;
	for(;;)
	{
		temp = sPathString.Tokenize(_T("*"),pos);
		if(temp.IsEmpty())
		{
			break;
		}
		AddPath(CTGitPath(CPathUtils::GetLongPathname(temp)));
	}
}
Esempio n. 27
0
void CSubmoduleUpdateDlg::SetDlgTitle()
{
	if (m_sTitle.IsEmpty())
		GetWindowText(m_sTitle);
	CString dir = g_Git.m_CurrentDir;
	if (!m_bWholeProject)
	{
		if (!m_PathFilterList.empty())
			dir += (g_Git.m_CurrentDir.Right(1) == _T('\\') ? _T("") : _T("\\")) + CTGitPath(m_PathFilterList[0]).GetWinPathString();
		if (m_PathFilterList.size() > 1)
			dir += _T(", ...");
	}
	CAppUtils::SetWindowTitle(m_hWnd, dir, m_sTitle);
}
Esempio n. 28
0
void CSetBugTraq::OnBnClickedRemovebutton()
{
	// traversing from the end to the beginning so that the indices are not skipped
	int index = m_cBugTraqList.GetItemCount()-1;
	while (index >= 0)
	{
		if (m_cBugTraqList.GetItemState(index, LVIS_SELECTED) & LVIS_SELECTED)
		{
			CTGitPath path = CTGitPath(m_cBugTraqList.GetItemText(index, 0));
			m_cBugTraqList.DeleteItem(index);
			m_associations.RemoveByPath(path);
			SetModified();
		}
		index--;
	}
}
Esempio n. 29
0
//this is the thread function which calls the subversion function
UINT CCacheDlg::TestThread()
{
	CDirFileEnum direnum(m_sRootPath);
	m_filelist.RemoveAll();
	CString filepath;
	bool bIsDir = false;
	while (direnum.NextFile(filepath, &bIsDir))
		if (filepath.Find(L".git") < 0)
			m_filelist.Add(filepath);

	CTime starttime = CTime::GetCurrentTime();
	GetDlgItem(IDC_STARTTIME)->SetWindowText(starttime.Format(L"%H:%M:%S"));

	ULONGLONG startticks = GetTickCount64();

	CString sNumber;
	std::random_device rd;
	std::mt19937 mt(rd());
	std::uniform_int_distribution<INT_PTR> dist(0, max(0, m_filelist.GetCount() - 1));
	std::uniform_int_distribution<INT_PTR> dist2(0, 9);
	for (int i=0; i < 1; ++i)
	{
		CString filepath2;
		//do {
			filepath2 = m_filelist.GetAt(dist(mt));
		//}while(filepath.Find(L".git") >= 0);
		GetDlgItem(IDC_FILEPATH)->SetWindowText(filepath2);
		GetStatusFromRemoteCache(CTGitPath(filepath2), true);
		sNumber.Format(L"%d", i);
		GetDlgItem(IDC_DONE)->SetWindowText(sNumber);
		if ((GetTickCount64()%10)==1)
			Sleep(10);
		if (dist2(mt) == 3)
			RemoveFromCache(filepath2);
	}
	CTime endtime = CTime::GetCurrentTime();
	CString sEnd = endtime.Format(L"%H:%M:%S");

	ULONGLONG endticks = GetTickCount64();

	CString sEndText;
	sEndText.Format(L"%s  - %I64u ms", (LPCTSTR)sEnd, endticks - startticks);

	GetDlgItem(IDC_ENDTIME)->SetWindowText(sEndText);

	return 0;
}
Esempio n. 30
0
//this is the thread function which calls the subversion function
UINT CCacheDlg::TestThread()
{
	CDirFileEnum direnum(m_sRootPath);
	m_filelist.RemoveAll();
	CString filepath;
	bool bIsDir = false;
	while (direnum.NextFile(filepath, &bIsDir))
		if(filepath.Find(_T(".git"))<0)
			m_filelist.Add(filepath);

	CTime starttime = CTime::GetCurrentTime();
	GetDlgItem(IDC_STARTTIME)->SetWindowText(starttime.Format(_T("%H:%M:%S")));
	int filecounter = 0;

	DWORD startticks = GetTickCount();

	CString sNumber;
	srand(GetTickCount());
	for (int i=0; i < 1; ++i)
	{
		CString filepath;
		//do {
			filepath = m_filelist.GetAt(rand() % m_filelist.GetCount());
		//}while(filepath.Find(_T(".git"))>=0);
		GetDlgItem(IDC_FILEPATH)->SetWindowText(filepath);
		GetStatusFromRemoteCache(CTGitPath(filepath), true);
		sNumber.Format(_T("%d"), i);
		GetDlgItem(IDC_DONE)->SetWindowText(sNumber);
		if ((GetTickCount()%10)==1)
			Sleep(10);
		if ((rand()%10)==3)
			RemoveFromCache(filepath);
	}
	CTime endtime = CTime::GetCurrentTime();
	CString sEnd = endtime.Format(_T("%H:%M:%S"));

	DWORD endticks = GetTickCount();

	CString sEndText;
	sEndText.Format(_T("%s  - %d ms"), sEnd, endticks-startticks);

	GetDlgItem(IDC_ENDTIME)->SetWindowText(sEndText);

	return 0;
}