MCPcopy Create free account
hub / github.com/git/git / refs_fsck_symref

Function refs_fsck_symref

refs.c:338–367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

336}
337
338int 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
369int refs_fsck(struct ref_store *refs, struct fsck_options *o,
370 struct worktree *wt)

Callers 2

reftable_be_fsckFunction · 0.85
files_fsck_symref_targetFunction · 0.85

Calls 5

parse_worktree_refFunction · 0.85
starts_withFunction · 0.85
fsck_report_refFunction · 0.85
is_root_refFunction · 0.85
check_refname_formatFunction · 0.85

Tested by

no test coverage detected