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

Function register_replace_ref

replace-object.c:11–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#include "commit.h"
10
11static int register_replace_ref(const struct reference *ref, void *cb_data)
12{
13 struct repository *r = cb_data;
14
15 /* Get sha1 from refname */
16 const char *slash = strrchr(ref->name, '/');
17 const char *hash = slash ? slash + 1 : ref->name;
18 struct replace_object *repl_obj = xmalloc(sizeof(*repl_obj));
19
20 if (get_oid_hex_algop(hash, &repl_obj->original.oid, r->hash_algo)) {
21 free(repl_obj);
22 warning(_("bad replace ref name: %s"), ref->name);
23 return 0;
24 }
25
26 /* Copy sha1 from the read ref */
27 oidcpy(&repl_obj->replacement, ref->oid);
28
29 /* Register new object */
30 if (oidmap_put(&r->objects->replace_map, repl_obj))
31 die(_("duplicate replace ref: %s"), ref->name);
32
33 return 0;
34}
35
36void prepare_replace_object(struct repository *r)
37{

Callers

nothing calls this directly

Calls 6

get_oid_hex_algopFunction · 0.85
warningFunction · 0.85
oidcpyFunction · 0.85
oidmap_putFunction · 0.85
xmallocFunction · 0.70
dieFunction · 0.70

Tested by

no test coverage detected