diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2021-03-03 15:14:38 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2021-03-03 15:14:38 +0900 |
commit | 5ff6a8462f7461075fb39cd0d6d76e6c51ffbc9f (patch) | |
tree | ae4581c010d54ff4c58c050bb38a34ed80b42eb1 /fsck.c | |
parent | 19729fb7029c2bb287c72c7dcc5e5a293a069d09 (diff) | |
download | git-5ff6a8462f7461075fb39cd0d6d76e6c51ffbc9f.tar.gz git-5ff6a8462f7461075fb39cd0d6d76e6c51ffbc9f.tar.bz2 git-5ff6a8462f7461075fb39cd0d6d76e6c51ffbc9f.zip |
Imported Upstream version 2.1.0upstream/2.1.0
Diffstat (limited to 'fsck.c')
-rw-r--r-- | fsck.c | 40 |
1 files changed, 11 insertions, 29 deletions
@@ -6,7 +6,6 @@ #include "commit.h" #include "tag.h" #include "fsck.h" -#include "utf8.h" static int fsck_walk_tree(struct tree *tree, fsck_walk_func walk, void *data) { @@ -171,9 +170,7 @@ static int fsck_tree(struct tree *item, int strict, fsck_error error_func) has_empty_name |= !*name; has_dot |= !strcmp(name, "."); has_dotdot |= !strcmp(name, ".."); - has_dotgit |= (!strcmp(name, ".git") || - is_hfs_dotgit(name) || - is_ntfs_dotgit(name)); + has_dotgit |= !strcmp(name, ".git"); has_zero_pad |= *(char *)desc.buffer == '0'; update_tree_entry(&desc); @@ -282,54 +279,39 @@ static int fsck_ident(const char **ident, struct object *obj, fsck_error error_f static int fsck_commit_buffer(struct commit *commit, const char *buffer, fsck_error error_func) { - const char *tmp; unsigned char tree_sha1[20], sha1[20]; struct commit_graft *graft; - int parents = 0; + unsigned parent_count, parent_line_count = 0; int err; - buffer = skip_prefix(buffer, "tree "); - if (!buffer) + if (!skip_prefix(buffer, "tree ", &buffer)) return error_func(&commit->object, FSCK_ERROR, "invalid format - expected 'tree' line"); if (get_sha1_hex(buffer, tree_sha1) || buffer[40] != '\n') return error_func(&commit->object, FSCK_ERROR, "invalid 'tree' line format - bad sha1"); buffer += 41; - while ((tmp = skip_prefix(buffer, "parent "))) { - buffer = tmp; + while (skip_prefix(buffer, "parent ", &buffer)) { if (get_sha1_hex(buffer, sha1) || buffer[40] != '\n') return error_func(&commit->object, FSCK_ERROR, "invalid 'parent' line format - bad sha1"); buffer += 41; - parents++; + parent_line_count++; } graft = lookup_commit_graft(commit->object.sha1); + parent_count = commit_list_count(commit->parents); if (graft) { - struct commit_list *p = commit->parents; - parents = 0; - while (p) { - p = p->next; - parents++; - } - if (graft->nr_parent == -1 && !parents) + if (graft->nr_parent == -1 && !parent_count) ; /* shallow commit */ - else if (graft->nr_parent != parents) + else if (graft->nr_parent != parent_count) return error_func(&commit->object, FSCK_ERROR, "graft objects missing"); } else { - struct commit_list *p = commit->parents; - while (p && parents) { - p = p->next; - parents--; - } - if (p || parents) + if (parent_count != parent_line_count) return error_func(&commit->object, FSCK_ERROR, "parent objects missing"); } - buffer = skip_prefix(buffer, "author "); - if (!buffer) + if (!skip_prefix(buffer, "author ", &buffer)) return error_func(&commit->object, FSCK_ERROR, "invalid format - expected 'author' line"); err = fsck_ident(&buffer, &commit->object, error_func); if (err) return err; - buffer = skip_prefix(buffer, "committer "); - if (!buffer) + if (!skip_prefix(buffer, "committer ", &buffer)) return error_func(&commit->object, FSCK_ERROR, "invalid format - expected 'committer' line"); err = fsck_ident(&buffer, &commit->object, error_func); if (err) |