MCPcopy Create free account
hub / github.com/git/git / branch_get_upstream

Function branch_get_upstream

remote.c:1863–1888  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1861}
1862
1863const char *branch_get_upstream(struct branch *branch, struct strbuf *err)
1864{
1865 if (!branch)
1866 return error_buf(err, _("HEAD does not point to a branch"));
1867
1868 if (!branch->merge || !branch->merge[0]) {
1869 /*
1870 * no merge config; is it because the user didn't define any,
1871 * or because it is not a real branch, and get_branch
1872 * auto-vivified it?
1873 */
1874 if (!refs_ref_exists(get_main_ref_store(the_repository), branch->refname))
1875 return error_buf(err, _("no such branch: '%s'"),
1876 branch->name);
1877 return error_buf(err,
1878 _("no upstream configured for branch '%s'"),
1879 branch->name);
1880 }
1881
1882 if (!branch->merge[0]->dst)
1883 return error_buf(err,
1884 _("upstream branch '%s' not stored as a remote-tracking branch"),
1885 branch->merge[0]->src);
1886
1887 return branch->merge[0]->dst;
1888}
1889
1890static char *tracking_for_push_dest(struct remote *remote,
1891 const char *refname,

Callers 10

populate_valueFunction · 0.85
branch_get_push_1Function · 0.85
stat_tracking_infoFunction · 0.85
resolve_compare_branchFunction · 0.85
format_tracking_infoFunction · 0.85
get_base_commitFunction · 0.85
cmd_cherryFunction · 0.85
cmd_rebaseFunction · 0.85
get_upstream_branchFunction · 0.85
branch_mergedFunction · 0.85

Calls 3

error_bufFunction · 0.85
refs_ref_existsFunction · 0.85
get_main_ref_storeFunction · 0.85

Tested by

no test coverage detected