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

Function for_each_replace_name

builtin/replace.c:110–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108 const struct object_id *oid);
109
110static int for_each_replace_name(const char **argv, each_replace_name_fn fn)
111{
112 const char **p, *full_hex;
113 struct strbuf ref = STRBUF_INIT;
114 size_t base_len;
115 int had_error = 0;
116 struct object_id oid;
117 const char *git_replace_ref_base = ref_namespace[NAMESPACE_REPLACE].ref;
118
119 strbuf_addstr(&ref, git_replace_ref_base);
120 base_len = ref.len;
121
122 for (p = argv; *p; p++) {
123 if (repo_get_oid(the_repository, *p, &oid)) {
124 error("failed to resolve '%s' as a valid ref", *p);
125 had_error = 1;
126 continue;
127 }
128
129 strbuf_setlen(&ref, base_len);
130 strbuf_add_oid_hex(&ref, &oid);
131 full_hex = ref.buf + base_len;
132
133 if (refs_read_ref(get_main_ref_store(the_repository), ref.buf, &oid)) {
134 error(_("replace ref '%s' not found"), full_hex);
135 had_error = 1;
136 continue;
137 }
138 if (fn(full_hex, ref.buf, &oid))
139 had_error = 1;
140 }
141 strbuf_release(&ref);
142 return had_error;
143}
144
145static int delete_replace_ref(const char *name, const char *ref,
146 const struct object_id *oid)

Callers 1

cmd_replaceFunction · 0.85

Calls 8

strbuf_addstrFunction · 0.85
repo_get_oidFunction · 0.85
errorFunction · 0.85
strbuf_setlenFunction · 0.85
strbuf_add_oid_hexFunction · 0.85
refs_read_refFunction · 0.85
get_main_ref_storeFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected