| 152 | } |
| 153 | |
| 154 | static 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 | |
| 173 | static int replace_object_oid(const char *object_ref, |
| 174 | struct object_id *object, |
no test coverage detected