MCPcopy Create free account
hub / github.com/TortoiseGit/TortoiseGit / GetRefsCommitIsOn

Method GetRefsCommitIsOn

src/Git/Git.cpp:1826–1957  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1824}
1825
1826int CGit::GetRefsCommitIsOn(STRING_VECTOR& list, const CGitHash& hash, bool includeTags, bool includeBranches, BRANCH_TYPE type)
1827{
1828 if (!includeTags && !includeBranches || hash.IsEmpty())
1829 return 0;
1830
1831 const size_t prevCount = list.size();
1832 if (UsingLibGit2(GIT_CMD_BRANCH_CONTAINS))
1833 {
1834 CAutoRepository repo(GetGitRepository());
1835 if (!repo)
1836 return -1;
1837
1838 CAutoReferenceIterator it;
1839 if (git_reference_iterator_new(it.GetPointer(), repo))
1840 return -1;
1841
1842 auto checkDescendent = [&list, &hash, &repo](const git_oid* oid, const git_reference* ref) {
1843 if (!oid)
1844 return;
1845 if (git_oid_equal(oid, hash) || git_graph_descendant_of(repo, oid, hash) == 1)
1846 {
1847 const char* name = git_reference_name(ref);
1848 if (!name)
1849 return;
1850
1851 list.push_back(CUnicodeUtils::GetUnicode(name));
1852 }
1853 };
1854
1855 CAutoReference ref;
1856 while (git_reference_next(ref.GetPointer(), it) == 0)
1857 {
1858 if (git_reference_is_tag(ref))
1859 {
1860 if (!includeTags)
1861 continue;
1862
1863 CAutoTag tag;
1864 if (git_tag_lookup(tag.GetPointer(), repo, git_reference_target(ref)) == 0)
1865 {
1866 CAutoObject obj;
1867 if (git_tag_peel(obj.GetPointer(), tag) < 0)
1868 continue;
1869 checkDescendent(git_object_id(obj), ref);
1870 continue;
1871 }
1872 }
1873 else if (git_reference_is_remote(ref))
1874 {
1875 if (!includeBranches || !(type & BRANCH_REMOTE))
1876 continue;
1877 }
1878 else if (git_reference_is_branch(ref))
1879 {
1880 if (!includeBranches || !(type & BRANCH_LOCAL))
1881 continue;
1882 }
1883 else

Callers 2

TEST_PFunction · 0.80
GetRefsThreadMethod · 0.80

Calls 10

eraseMethod · 0.80
StartsWithFunction · 0.50
IsEmptyMethod · 0.45
sizeMethod · 0.45
GetPointerMethod · 0.45
ToStringMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by 1

TEST_PFunction · 0.64