| 9 | #include "commit.h" |
| 10 | |
| 11 | static 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 | |
| 36 | void prepare_replace_object(struct repository *r) |
| 37 | { |
nothing calls this directly
no test coverage detected