summaryrefslogtreecommitdiff
path: root/builtin/fsck.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/fsck.c')
-rw-r--r--builtin/fsck.c46
1 files changed, 4 insertions, 42 deletions
diff --git a/builtin/fsck.c b/builtin/fsck.c
index f671288026..0512f78a87 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -596,10 +596,6 @@ static int fsck_handle_ref(const struct reference *ref, void *cb_data UNUSED)
return 0;
}
-static int fsck_head_link(const char *head_ref_name,
- const char **head_points_at,
- struct object_id *head_oid);
-
static void snapshot_refs(struct snapshot *snap, int argc, const char **argv)
{
struct worktree **worktrees, **p;
@@ -636,7 +632,10 @@ static void snapshot_refs(struct snapshot *snap, int argc, const char **argv)
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,
@@ -803,43 +802,6 @@ static void fsck_source(struct odb_source *source)
stop_progress(&progress);
}
-static int fsck_head_link(const char *head_ref_name,
- const char **head_points_at,
- struct object_id *head_oid)
-{
- int null_is_error = 0;
-
- 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;
- return error(_("invalid %s"), head_ref_name);
- }
- if (!strcmp(*head_points_at, head_ref_name))
- /* detached HEAD */
- null_is_error = 1;
- else if (!starts_with(*head_points_at, "refs/heads/")) {
- errors_found |= ERROR_REFS;
- return error(_("%s points to something strange (%s)"),
- head_ref_name, *head_points_at);
- }
- if (is_null_oid(head_oid)) {
- if (null_is_error) {
- errors_found |= ERROR_REFS;
- return error(_("%s: detached HEAD points at nothing"),
- head_ref_name);
- }
- fprintf_ln(stderr,
- _("notice: %s points to an unborn branch (%s)"),
- head_ref_name, *head_points_at + 11);
- }
- return 0;
-}
-
static int fsck_cache_tree(struct cache_tree *it, const char *index_path)
{
int i;