| 108 | const struct object_id *oid); |
| 109 | |
| 110 | static 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 | |
| 145 | static int delete_replace_ref(const char *name, const char *ref, |
| 146 | const struct object_id *oid) |
no test coverage detected