diff options
author | Junio C Hamano <junkio@cox.net> | 2007-04-11 01:28:43 -0700 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-04-11 14:05:36 -0700 |
commit | 8eb2d0bee8813ac37dc602d12b0abba632e96152 (patch) | |
tree | 4f3b03cd07bb9607e0cbdf4709ff1cccb8ac441e /builtin-fsck.c | |
parent | f98157720239f0dd94d03632dc873e3eb3135e2f (diff) | |
download | git-8eb2d0bee8813ac37dc602d12b0abba632e96152.tar.gz |
fsck: do not complain on detached HEAD.
Detached HEAD is just a normal state of a repository. Do not
say anything about it.
Do not give worrying "error:" messages when we let the user know
that the HEAD points at nothing (i.e. yet to be born branch),
nor we do not have any default refs to start following the
objects chain. Reword them as "notice:".
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-fsck.c')
-rw-r--r-- | builtin-fsck.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/builtin-fsck.c b/builtin-fsck.c index 21f1f9e91d..7c3b0a535f 100644 --- a/builtin-fsck.c +++ b/builtin-fsck.c @@ -532,7 +532,7 @@ static void get_default_heads(void) * "show_unreachable" flag. */ if (!default_refs) { - error("No default references"); + fprintf(stderr, "notice: No default references\n"); show_unreachable = 0; } } @@ -552,15 +552,23 @@ static int fsck_head_link(void) { unsigned char sha1[20]; int flag; - const char *head_points_at = resolve_ref("HEAD", sha1, 1, &flag); - - if (!head_points_at || !(flag & REF_ISSYMREF)) - return error("HEAD is not a symbolic ref"); - if (prefixcmp(head_points_at, "refs/heads/")) + int null_is_error = 0; + const char *head_points_at = resolve_ref("HEAD", sha1, 0, &flag); + + if (!head_points_at) + return error("Invalid HEAD"); + if (!strcmp(head_points_at, "HEAD")) + /* detached HEAD */ + null_is_error = 1; + else if (prefixcmp(head_points_at, "refs/heads/")) return error("HEAD points to something strange (%s)", head_points_at); - if (is_null_sha1(sha1)) - return error("HEAD: not a valid git pointer"); + if (is_null_sha1(sha1)) { + if (null_is_error) + return error("HEAD: detached HEAD points at nothing"); + fprintf(stderr, "notice: HEAD points to an unborn branch (%s)\n", + head_points_at + 11); + } return 0; } |