| 336 | } |
| 337 | |
| 338 | int refs_fsck_symref(struct ref_store *refs UNUSED, struct fsck_options *o, |
| 339 | struct fsck_ref_report *report, |
| 340 | const char *refname, const char *target) |
| 341 | { |
| 342 | const char *stripped_refname; |
| 343 | |
| 344 | parse_worktree_ref(refname, NULL, NULL, &stripped_refname); |
| 345 | |
| 346 | if (!strcmp(stripped_refname, "HEAD") && |
| 347 | !starts_with(target, "refs/heads/") && |
| 348 | fsck_report_ref(o, report, FSCK_MSG_BAD_HEAD_TARGET, |
| 349 | "HEAD points to non-branch '%s'", target)) |
| 350 | return -1; |
| 351 | |
| 352 | if (is_root_ref(target)) |
| 353 | return 0; |
| 354 | |
| 355 | if (check_refname_format(target, 0) && |
| 356 | fsck_report_ref(o, report, FSCK_MSG_BAD_REFERENT_NAME, |
| 357 | "points to invalid refname '%s'", target)) |
| 358 | return -1; |
| 359 | |
| 360 | if (!starts_with(target, "refs/") && |
| 361 | !starts_with(target, "worktrees/") && |
| 362 | fsck_report_ref(o, report, FSCK_MSG_SYMREF_TARGET_IS_NOT_A_REF, |
| 363 | "points to non-ref target '%s'", target)) |
| 364 | return -1; |
| 365 | |
| 366 | return 0; |
| 367 | } |
| 368 | |
| 369 | int refs_fsck(struct ref_store *refs, struct fsck_options *o, |
| 370 | struct worktree *wt) |
no test coverage detected