mirror of
https://github.com/git/git.git
synced 2026-01-11 13:23:12 +09:00
builtin/fsck: drop fsck_head_link()
The function `fsck_head_link()` was historically used to perform a
couple of consistency checks for refs. (Almost) all of these checks have
now been moved into the refs subsystem. There's only a single check
remaining that verifies whether `refs_resolve_ref_unsafe()` returns a
`NULL` pointer. This may happen in a couple of cases:
- When `refs_is_safe()` declares the ref to be unsafe. We already have
checks for this as we verify refnames with `check_refname_format()`.
- When the ref doesn't exist. A repository without "HEAD" is
completely broken though, and we would notice this error ahead of
time already.
- In case the caller passes `RESOLVE_REF_READING` and the ref is a
symref that doesn't resolve. We don't pass this flag though.
As such, this check doesn't cover anything anymore that isn't already
covered by `refs_fsck()`. Drop it, which also allows us to inline the
call to `refs_resolve_ref_unsafe()`.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
b2f2a58a25
commit
df7333d8e6
@ -564,10 +564,6 @@ static int fsck_handle_ref(const struct reference *ref, void *cb_data UNUSED)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void fsck_head_link(const char *head_ref_name,
|
||||
const char **head_points_at,
|
||||
struct object_id *head_oid);
|
||||
|
||||
static void get_default_heads(void)
|
||||
{
|
||||
struct worktree **worktrees, **p;
|
||||
@ -583,7 +579,10 @@ static void get_default_heads(void)
|
||||
struct strbuf refname = STRBUF_INIT;
|
||||
|
||||
strbuf_worktree_ref(wt, &refname, "HEAD");
|
||||
fsck_head_link(refname.buf, &head_points_at, &head_oid);
|
||||
|
||||
head_points_at = refs_resolve_ref_unsafe(get_main_ref_store(the_repository),
|
||||
refname.buf, 0, &head_oid, NULL);
|
||||
|
||||
if (head_points_at && !is_null_oid(&head_oid)) {
|
||||
struct reference ref = {
|
||||
.name = refname.buf,
|
||||
@ -713,25 +712,6 @@ static void fsck_source(struct odb_source *source)
|
||||
stop_progress(&progress);
|
||||
}
|
||||
|
||||
static void fsck_head_link(const char *head_ref_name,
|
||||
const char **head_points_at,
|
||||
struct object_id *head_oid)
|
||||
{
|
||||
if (verbose)
|
||||
fprintf_ln(stderr, _("Checking %s link"), head_ref_name);
|
||||
|
||||
*head_points_at = refs_resolve_ref_unsafe(get_main_ref_store(the_repository),
|
||||
head_ref_name, 0, head_oid,
|
||||
NULL);
|
||||
if (!*head_points_at) {
|
||||
errors_found |= ERROR_REFS;
|
||||
error(_("invalid %s"), head_ref_name);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static int fsck_cache_tree(struct cache_tree *it, const char *index_path)
|
||||
{
|
||||
int i;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user