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

Function refspec_append_mapped

builtin/push.c:72–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70static struct string_list push_options_config = STRING_LIST_INIT_DUP;
71
72static void refspec_append_mapped(struct refspec *refspec, const char *ref,
73 struct remote *remote, struct ref *matched)
74{
75 const char *branch_name;
76
77 if (remote->push.nr) {
78 struct refspec_item query = {
79 .src = matched->name,
80 };
81
82 if (!refspec_find_match(&remote->push, &query) && query.dst) {
83 refspec_appendf(refspec, "%s%s:%s",
84 query.force ? "+" : "",
85 query.src, query.dst);
86 free(query.dst);
87 return;
88 }
89 }
90
91 if (push_default == PUSH_DEFAULT_UPSTREAM &&
92 skip_prefix(matched->name, "refs/heads/", &branch_name)) {
93 struct branch *branch = branch_get(branch_name);
94 if (branch->merge_nr == 1 && branch->merge[0]->src) {
95 refspec_appendf(refspec, "%s:%s",
96 ref, branch->merge[0]->src);
97 return;
98 }
99 }
100
101 refspec_append(refspec, ref);
102}
103
104static void set_refspecs(const char **refs, int nr, struct remote *remote)
105{

Callers 1

set_refspecsFunction · 0.85

Calls 4

refspec_find_matchFunction · 0.85
refspec_appendfFunction · 0.85
branch_getFunction · 0.85
refspec_appendFunction · 0.85

Tested by

no test coverage detected