X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-fsck.c;h=cbbcaf011a09d1dd9b3f2a01d18e1ab93e26fd3b;hb=1654a3ba0c3a91ee3c0f38c922e3d2d1255ec868;hp=44a02d3120128d4956604c4254fbdd9809a36833;hpb=57059091fad25427bce9b3d47e073ce0518d164b;p=git.git diff --git a/builtin-fsck.c b/builtin-fsck.c index 44a02d312..cbbcaf011 100644 --- a/builtin-fsck.c +++ b/builtin-fsck.c @@ -219,6 +219,7 @@ static int fsck_tree(struct tree *item) { int retval; int has_full_path = 0; + int has_empty_name = 0; int has_zero_pad = 0; int has_bad_modes = 0; int has_dup_entries = 0; @@ -242,6 +243,8 @@ static int fsck_tree(struct tree *item) if (strchr(name, '/')) has_full_path = 1; + if (!*name) + has_empty_name = 1; has_zero_pad |= *(char *)desc.buffer == '0'; update_tree_entry(&desc); @@ -253,6 +256,7 @@ static int fsck_tree(struct tree *item) case S_IFREG | 0644: case S_IFLNK: case S_IFDIR: + case S_IFGITLINK: break; /* * This is nonstandard, but we had a few of these @@ -290,6 +294,9 @@ static int fsck_tree(struct tree *item) if (has_full_path) { objwarning(&item->object, "contains full pathnames"); } + if (has_empty_name) { + objwarning(&item->object, "contains empty pathname"); + } if (has_zero_pad) { objwarning(&item->object, "contains zero-padded file modes"); } @@ -534,7 +541,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; } } @@ -554,15 +561,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; } @@ -695,8 +710,14 @@ int cmd_fsck(int argc, char **argv, const char *prefix) int i; read_cache(); for (i = 0; i < active_nr; i++) { - struct blob *blob = lookup_blob(active_cache[i]->sha1); + unsigned int mode; + struct blob *blob; struct object *obj; + + mode = ntohl(active_cache[i]->ce_mode); + if (S_ISGITLINK(mode)) + continue; + blob = lookup_blob(active_cache[i]->sha1); if (!blob) continue; obj = &blob->object;