| 148 | } |
| 149 | |
| 150 | static int add_ref_decoration(const struct reference *ref, void *cb_data) |
| 151 | { |
| 152 | int i; |
| 153 | struct object *obj; |
| 154 | enum object_type objtype; |
| 155 | enum decoration_type deco_type = DECORATION_NONE; |
| 156 | struct decoration_filter *filter = (struct decoration_filter *)cb_data; |
| 157 | const char *git_replace_ref_base = ref_namespace[NAMESPACE_REPLACE].ref; |
| 158 | |
| 159 | if (filter && !ref_filter_match(ref->name, filter)) |
| 160 | return 0; |
| 161 | |
| 162 | if (starts_with(ref->name, git_replace_ref_base)) { |
| 163 | struct object_id original_oid; |
| 164 | if (!replace_refs_enabled(the_repository)) |
| 165 | return 0; |
| 166 | if (get_oid_hex(ref->name + strlen(git_replace_ref_base), |
| 167 | &original_oid)) { |
| 168 | warning("invalid replace ref %s", ref->name); |
| 169 | return 0; |
| 170 | } |
| 171 | obj = parse_object(the_repository, &original_oid); |
| 172 | if (obj) |
| 173 | add_name_decoration(DECORATION_GRAFTED, "replaced", obj); |
| 174 | return 0; |
| 175 | } |
| 176 | |
| 177 | objtype = odb_read_object_info(the_repository->objects, ref->oid, NULL); |
| 178 | if (objtype < 0) |
| 179 | return 0; |
| 180 | obj = lookup_object_by_type(the_repository, ref->oid, objtype); |
| 181 | |
| 182 | for (i = 0; i < ARRAY_SIZE(ref_namespace); i++) { |
| 183 | struct ref_namespace_info *info = &ref_namespace[i]; |
| 184 | |
| 185 | if (!info->decoration) |
| 186 | continue; |
| 187 | if (info->exact) { |
| 188 | if (!strcmp(ref->name, info->ref)) { |
| 189 | deco_type = info->decoration; |
| 190 | break; |
| 191 | } |
| 192 | } else if (starts_with(ref->name, info->ref)) { |
| 193 | deco_type = info->decoration; |
| 194 | break; |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | add_name_decoration(deco_type, ref->name, obj); |
| 199 | while (obj->type == OBJ_TAG) { |
| 200 | if (!obj->parsed) |
| 201 | parse_object(the_repository, &obj->oid); |
| 202 | obj = ((struct tag *)obj)->tagged; |
| 203 | if (!obj) |
| 204 | break; |
| 205 | add_name_decoration(DECORATION_REF_TAG, ref->name, obj); |
| 206 | } |
| 207 | return 0; |
nothing calls this directly
no test coverage detected