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

Function inherit_tracking

branch.c:217–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215}
216
217static int inherit_tracking(struct tracking *tracking, const char *orig_ref)
218{
219 const char *bare_ref;
220 struct branch *branch;
221 int i;
222
223 bare_ref = orig_ref;
224 skip_prefix(orig_ref, "refs/heads/", &bare_ref);
225
226 branch = branch_get(bare_ref);
227 if (!branch->remote_name) {
228 warning(_("asked to inherit tracking from '%s', but no remote is set"),
229 bare_ref);
230 return -1;
231 }
232
233 if (branch->merge_nr < 1 || !branch->merge || !branch->merge[0] || !branch->merge[0]->src) {
234 warning(_("asked to inherit tracking from '%s', but no merge configuration is set"),
235 bare_ref);
236 return -1;
237 }
238
239 tracking->remote = branch->remote_name;
240 for (i = 0; i < branch->merge_nr; i++)
241 string_list_append(tracking->srcs, branch->merge[i]->src);
242 return 0;
243}
244
245/*
246 * Used internally to set the branch.<new_ref>.{remote,merge} config

Callers 1

setup_trackingFunction · 0.85

Calls 3

branch_getFunction · 0.85
warningFunction · 0.85
string_list_appendFunction · 0.70

Tested by

no test coverage detected