MCPcopy Index your code
hub / github.com/git/git / do_fetch

Function do_fetch

builtin/fetch.c:1885–2177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1883}
1884
1885static int do_fetch(struct transport *transport,
1886 struct refspec *rs,
1887 const struct fetch_config *config,
1888 struct list_objects_filter_options *filter_options)
1889{
1890 struct ref_transaction *transaction = NULL;
1891 struct ref *ref_map = NULL;
1892 struct display_state display_state = { 0 };
1893 int autotags = (transport->remote->fetch_tags == 1);
1894 int retcode = 0;
1895 const struct ref *remote_refs;
1896 struct transport_ls_refs_options transport_ls_refs_options =
1897 TRANSPORT_LS_REFS_OPTIONS_INIT;
1898 struct fetch_head fetch_head = { 0 };
1899 struct strbuf err = STRBUF_INIT;
1900 int do_set_head = 0;
1901 struct ref_update_display_info_array display_array = { 0 };
1902 struct strmap rejected_refs = STRMAP_INIT;
1903 int summary_width = 0;
1904
1905 if (tags == TAGS_DEFAULT) {
1906 if (transport->remote->fetch_tags == 2)
1907 tags = TAGS_SET;
1908 if (transport->remote->fetch_tags == -1)
1909 tags = TAGS_UNSET;
1910 }
1911
1912 /* if not appending, truncate FETCH_HEAD */
1913 if (!append && write_fetch_head) {
1914 retcode = truncate_fetch_head();
1915 if (retcode)
1916 goto cleanup;
1917 }
1918
1919 if (rs->nr) {
1920 refspec_ref_prefixes(rs, &transport_ls_refs_options.ref_prefixes);
1921 } else {
1922 struct branch *branch = branch_get(NULL);
1923
1924 if (transport->remote->fetch.nr) {
1925 refspec_ref_prefixes(&transport->remote->fetch,
1926 &transport_ls_refs_options.ref_prefixes);
1927 if (transport->remote->follow_remote_head != FOLLOW_REMOTE_NEVER)
1928 do_set_head = 1;
1929 }
1930 if (branch && branch_has_merge_config(branch) &&
1931 !strcmp(branch->remote_name, transport->remote->name)) {
1932 int i;
1933 for (i = 0; i < branch->merge_nr; i++) {
1934 strvec_push(&transport_ls_refs_options.ref_prefixes,
1935 branch->merge[i]->src);
1936 }
1937 }
1938
1939 /*
1940 * If there are no refs specified to fetch, then we just
1941 * fetch HEAD; mention that to narrow the advertisement.
1942 */

Callers 1

fetch_oneFunction · 0.85

Calls 15

truncate_fetch_headFunction · 0.85
refspec_ref_prefixesFunction · 0.85
branch_getFunction · 0.85
branch_has_merge_configFunction · 0.85
strvec_pushFunction · 0.85
get_ref_mapFunction · 0.85
check_not_current_branchFunction · 0.85
open_fetch_headFunction · 0.85
display_state_initFunction · 0.85

Tested by

no test coverage detected