本文整理汇总了C++中CGitHash::IsEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ CGitHash::IsEmpty方法的具体用法?C++ CGitHash::IsEmpty怎么用?C++ CGitHash::IsEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGitHash
的用法示例。
在下文中一共展示了CGitHash::IsEmpty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(CGitHash, Initial)
{
CGitHash empty;
EXPECT_TRUE(empty.IsEmpty());
EXPECT_STREQ(L"0000000000000000000000000000000000000000", GIT_REV_ZERO);
EXPECT_STREQ(GIT_REV_ZERO, empty.ToString());
EXPECT_TRUE(empty == empty);
EXPECT_FALSE(empty != empty);
CGitHash hash = CGitHash::FromHexStr("8d1861316061748cfee7e075dc138287978102ab");
EXPECT_FALSE(hash.IsEmpty());
EXPECT_STREQ(L"8d1861316061748cfee7e075dc138287978102ab", hash.ToString());
EXPECT_TRUE(hash == hash);
EXPECT_FALSE(hash != hash);
EXPECT_FALSE(hash == empty);
EXPECT_TRUE(hash != empty);
CGitHash hash2 = CGitHash::FromHexStr(L"8d1861316061748cfee7e075dc138287978102ab");
EXPECT_FALSE(hash2.IsEmpty());
EXPECT_STREQ(L"8d1861316061748cfee7e075dc138287978102ab", hash2.ToString());
EXPECT_TRUE(hash2 == hash);
EXPECT_FALSE(hash2 != hash);
EXPECT_FALSE(hash2 == empty);
EXPECT_TRUE(hash2 != empty);
hash2.Empty();
EXPECT_STREQ(GIT_REV_ZERO, hash2.ToString());
EXPECT_TRUE(hash2 == empty);
EXPECT_FALSE(hash2 != empty);
EXPECT_TRUE(hash2.IsEmpty());
unsigned char chararray[20] = { 0x8D, 0x18, 0x61, 0x31, 0x60, 0x61, 0x74, 0x8C, 0xFE, 0xE7, 0xE0, 0x75, 0xDC, 0x13, 0x82, 0x87, 0x97, 0x81, 0x02, 0xAB };
CGitHash hash3 = CGitHash::FromRaw(chararray);
EXPECT_FALSE(hash3.IsEmpty());
EXPECT_STREQ(L"8d1861316061748cfee7e075dc138287978102ab", hash3.ToString());
EXPECT_TRUE(hash3 == hash);
EXPECT_FALSE(hash3 != hash);
EXPECT_FALSE(hash3 == empty);
EXPECT_TRUE(hash3 != empty);
CGitHash hash4;
hash4 = CGitHash::FromHexStr(L"8d1861316061748cfee7e075dc138287978102ab");
EXPECT_TRUE(hash4 == hash);
CGitHash hash5;
hash5 = hash;
EXPECT_TRUE(hash5 == hash);
CGitHash hash6;
hash6 = CGitHash::FromRaw(chararray);
EXPECT_TRUE(hash6 == hash);
CGitHash hash7 = CGitHash::FromHexStrTry(L"invalid");
EXPECT_TRUE(hash7.IsEmpty());
CGitHash hash8 = CGitHash::FromHexStrTry(L"01234567");
EXPECT_TRUE(hash8.IsEmpty());
}
示例2: OnBnClickedButtonPull
void CSyncDlg::OnBnClickedButtonPull()
{
int CurrentEntry;
CurrentEntry = (int)this->m_ctrlPull.GetCurrentEntry();
this->m_regPullButton = CurrentEntry;
this->m_bAbort=false;
this->m_GitCmdList.clear();
m_ctrlCmdOut.SetWindowTextW(_T(""));
m_LogText = "";
this->UpdateData();
UpdateCombox();
if (g_Git.GetHash(m_oldHash, _T("HEAD")))
{
MessageBox(g_Git.GetGitLastErr(_T("Could not get HEAD hash.")), _T("TortoiseGit"), MB_ICONERROR);
return;
}
m_refList.Clear();
m_newHashMap.clear();
m_oldHashMap.clear();
if( CurrentEntry == 0)
{
CGitHash localBranchHash;
if (g_Git.GetHash(localBranchHash, m_strLocalBranch))
{
MessageBox(g_Git.GetGitLastErr(_T("Could not get hash of \"") + m_strLocalBranch + _T("\".")), _T("TortoiseGit"), MB_ICONERROR);
return;
}
if (localBranchHash != m_oldHash)
{
CMessageBox::Show(NULL, IDS_PROC_SYNC_PULLWRONGBRANCH, IDS_APPNAME, MB_OK | MB_ICONERROR);
return;
}
}
if(this->m_strURL.IsEmpty())
{
CMessageBox::Show(NULL, IDS_PROC_GITCONFIG_URLEMPTY, IDS_APPNAME, MB_OK | MB_ICONERROR);
return;
}
if (m_bAutoLoadPuttyKey && CurrentEntry != 3) // CurrentEntry (Remote Update) handles this on its own)
{
CAppUtils::LaunchPAgent(NULL,&this->m_strURL);
}
this->SwitchToRun();
CString force;
if(this->m_bForce)
force = _T(" --force ");
CString cmd;
ShowTab(IDC_CMD_LOG);
this->m_ctrlTabCtrl.ShowTab(IDC_REFLIST-1,true);
this->m_ctrlTabCtrl.ShowTab(IDC_IN_LOGLIST-1,false);
this->m_ctrlTabCtrl.ShowTab(IDC_IN_CHANGELIST-1,false);
this->m_ctrlTabCtrl.ShowTab(IDC_IN_CONFLICT-1,false);
///Pull
if(CurrentEntry == 0) //Pull
{
CString remotebranch;
remotebranch = m_strRemoteBranch;
if(!IsURL())
{
CString configName;
configName.Format(L"branch.%s.merge", this->m_strLocalBranch);
CString pullBranch = CGit::StripRefName(g_Git.GetConfigValue(configName));
configName.Format(L"branch.%s.remote", m_strLocalBranch);
CString pullRemote = g_Git.GetConfigValue(configName);
if(pullBranch == remotebranch && pullRemote == this->m_strURL)
remotebranch.Empty();
}
if(m_Gitverion >= 0x01070203) //above 1.7.0.2
force += _T("--progress ");
cmd.Format(_T("git.exe pull -v %s \"%s\" %s"),
force,
m_strURL,
remotebranch);
m_CurrentCmd = GIT_COMMAND_PULL;
m_GitCmdList.push_back(cmd);
m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);
if (m_pThread==NULL)
{
// ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED)));
}
//.........这里部分代码省略.........
示例3: FetchOutList
void CSyncDlg::FetchOutList(bool force)
{
if(!m_bInited)
return;
m_OutChangeFileList.Clear();
this->m_OutLogList.Clear();
CString remote;
this->m_ctrlURL.GetWindowText(remote);
CString remotebranch;
this->m_ctrlRemoteBranch.GetWindowText(remotebranch);
remotebranch=remote+_T("/")+remotebranch;
CGitHash remotebranchHash;
g_Git.GetHash(remotebranchHash, remotebranch);
if(IsURL())
{
CString str;
str.LoadString(IDS_PROC_SYNC_PUSH_UNKNOWN);
m_OutLogList.ShowText(str);
this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,FALSE);
m_OutLocalBranch.Empty();
m_OutRemoteBranch.Empty();
this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(FALSE);
return ;
}
else if(remotebranchHash.IsEmpty())
{
CString str;
str.Format(IDS_PROC_SYNC_PUSH_UNKNOWNBRANCH, remotebranch);
m_OutLogList.ShowText(str);
this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,FALSE);
m_OutLocalBranch.Empty();
m_OutRemoteBranch.Empty();
this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(FALSE);
return ;
}
else
{
CString localbranch;
localbranch=this->m_ctrlLocalBranch.GetString();
if(localbranch != m_OutLocalBranch || m_OutRemoteBranch != remotebranch || force)
{
m_OutLogList.ClearText();
CGitHash base, localBranchHash;
bool isFastForward = g_Git.IsFastForward(remotebranch, localbranch, &base);
if (g_Git.GetHash(localBranchHash, localbranch))
{
MessageBox(g_Git.GetGitLastErr(_T("Could not get hash of \"") + localbranch + _T("\".")), _T("TortoiseGit"), MB_ICONERROR);
return;
}
if (remotebranchHash == localBranchHash)
{
CString str;
str.Format(IDS_PROC_SYNC_COMMITSAHEAD, 0, remotebranch);
m_OutLogList.ShowText(str);
this->m_ctrlStatus.SetWindowText(str);
this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,FALSE);
this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(FALSE);
}
else if (isFastForward || m_bForce)
{
CString range;
range.Format(_T("%s..%s"), g_Git.FixBranchName(remotebranch), g_Git.FixBranchName(localbranch));
//fast forward
m_OutLogList.FillGitLog(nullptr, &range, CGit::LOG_INFO_STAT | CGit::LOG_INFO_FILESTATE | CGit::LOG_INFO_SHOW_MERGEDFILE);
CString str;
str.Format(IDS_PROC_SYNC_COMMITSAHEAD, m_OutLogList.GetItemCount(), remotebranch);
this->m_ctrlStatus.SetWindowText(str);
if (isFastForward)
AddDiffFileList(&m_OutChangeFileList, &m_arOutChangeList, localbranch, remotebranch);
else
{
AddDiffFileList(&m_OutChangeFileList, &m_arOutChangeList, localbranch, base.ToString());
}
this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,TRUE);
this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(TRUE);
}
else
{
CString str;
str.Format(IDS_PROC_SYNC_NOFASTFORWARD, localbranch, remotebranch);
m_OutLogList.ShowText(str);
this->m_ctrlStatus.SetWindowText(str);
this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID() - 1, FALSE);
this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(FALSE);
}
}
this->m_OutLocalBranch=localbranch;
this->m_OutRemoteBranch=remotebranch;
}
//.........这里部分代码省略.........