fsck: change functions to use object_id
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
96062b5762
commit
635b99a0c7
@ -25,7 +25,7 @@ static int include_reflogs = 1;
|
||||
static int check_full = 1;
|
||||
static int check_strict;
|
||||
static int keep_cache_objects;
|
||||
static unsigned char head_sha1[20];
|
||||
static struct object_id head_oid;
|
||||
static const char *head_points_at;
|
||||
static int errors_found;
|
||||
static int write_lost_and_found;
|
||||
@ -476,19 +476,21 @@ static int fsck_handle_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fsck_handle_reflog(const char *logname, const unsigned char *sha1, int flag, void *cb_data)
|
||||
static int fsck_handle_reflog(const char *logname, const struct object_id *oid,
|
||||
int flag, void *cb_data)
|
||||
{
|
||||
for_each_reflog_ent(logname, fsck_handle_reflog_ent, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fsck_handle_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
|
||||
static int fsck_handle_ref(const char *refname, const struct object_id *oid,
|
||||
int flag, void *cb_data)
|
||||
{
|
||||
struct object *obj;
|
||||
|
||||
obj = parse_object(sha1);
|
||||
obj = parse_object(oid->hash);
|
||||
if (!obj) {
|
||||
error("%s: invalid sha1 pointer %s", refname, sha1_to_hex(sha1));
|
||||
error("%s: invalid sha1 pointer %s", refname, oid_to_hex(oid));
|
||||
errors_found |= ERROR_REACHABLE;
|
||||
/* We'll continue with the rest despite the error.. */
|
||||
return 0;
|
||||
@ -504,16 +506,11 @@ static int fsck_handle_ref(const char *refname, const unsigned char *sha1, int f
|
||||
|
||||
static void get_default_heads(void)
|
||||
{
|
||||
struct each_ref_fn_sha1_adapter wrapped_fsck_handle_ref =
|
||||
{fsck_handle_ref, NULL};
|
||||
struct each_ref_fn_sha1_adapter wrapped_fsck_handle_reflog =
|
||||
{fsck_handle_reflog, NULL};
|
||||
|
||||
if (head_points_at && !is_null_sha1(head_sha1))
|
||||
fsck_handle_ref("HEAD", head_sha1, 0, NULL);
|
||||
for_each_rawref(each_ref_fn_adapter, &wrapped_fsck_handle_ref);
|
||||
if (head_points_at && !is_null_oid(&head_oid))
|
||||
fsck_handle_ref("HEAD", &head_oid, 0, NULL);
|
||||
for_each_rawref(fsck_handle_ref, NULL);
|
||||
if (include_reflogs)
|
||||
for_each_reflog(each_ref_fn_adapter, &wrapped_fsck_handle_reflog);
|
||||
for_each_reflog(fsck_handle_reflog, NULL);
|
||||
|
||||
/*
|
||||
* Not having any default heads isn't really fatal, but
|
||||
@ -561,7 +558,7 @@ static int fsck_head_link(void)
|
||||
if (verbose)
|
||||
fprintf(stderr, "Checking HEAD link\n");
|
||||
|
||||
head_points_at = resolve_ref_unsafe("HEAD", 0, head_sha1, &flag);
|
||||
head_points_at = resolve_ref_unsafe("HEAD", 0, head_oid.hash, &flag);
|
||||
if (!head_points_at)
|
||||
return error("Invalid HEAD");
|
||||
if (!strcmp(head_points_at, "HEAD"))
|
||||
@ -570,7 +567,7 @@ static int fsck_head_link(void)
|
||||
else if (!starts_with(head_points_at, "refs/heads/"))
|
||||
return error("HEAD points to something strange (%s)",
|
||||
head_points_at);
|
||||
if (is_null_sha1(head_sha1)) {
|
||||
if (is_null_oid(&head_oid)) {
|
||||
if (null_is_error)
|
||||
return error("HEAD: detached HEAD points at nothing");
|
||||
fprintf(stderr, "notice: HEAD points to an unborn branch (%s)\n",
|
||||
|
Loading…
Reference in New Issue
Block a user