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

Function check_ref_valid

builtin/replace.c:154–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152}
153
154static int check_ref_valid(struct object_id *object,
155 struct object_id *prev,
156 struct strbuf *ref,
157 int force)
158{
159 const char *git_replace_ref_base = ref_namespace[NAMESPACE_REPLACE].ref;
160
161 strbuf_reset(ref);
162 strbuf_addf(ref, "%s%s", git_replace_ref_base, oid_to_hex(object));
163 if (check_refname_format(ref->buf, 0))
164 return error(_("'%s' is not a valid ref name"), ref->buf);
165
166 if (refs_read_ref(get_main_ref_store(the_repository), ref->buf, prev))
167 oidclr(prev, the_repository->hash_algo);
168 else if (!force)
169 return error(_("replace ref '%s' already exists"), ref->buf);
170 return 0;
171}
172
173static int replace_object_oid(const char *object_ref,
174 struct object_id *object,

Callers 2

replace_object_oidFunction · 0.85
edit_and_replaceFunction · 0.85

Calls 7

strbuf_addfFunction · 0.85
oid_to_hexFunction · 0.85
check_refname_formatFunction · 0.85
errorFunction · 0.85
refs_read_refFunction · 0.85
get_main_ref_storeFunction · 0.85
oidclrFunction · 0.85

Tested by

no test coverage detected