#include "fsck.h"
#include "refs.h"
#include "utf8.h"
-#include "sha1-array.h"
#include "decorate.h"
#include "oidset.h"
#include "packfile.h"
#include "submodule-config.h"
#include "config.h"
-#include "credential.h"
#include "help.h"
static struct oidset gitmodules_found = OIDSET_INIT;
return msg_type;
}
-static void init_skiplist(struct fsck_options *options, const char *path)
-{
- static struct oid_array skiplist = OID_ARRAY_INIT;
- int sorted, fd;
- char buffer[GIT_MAX_HEXSZ + 1];
- struct object_id oid;
-
- if (options->skiplist)
- sorted = options->skiplist->sorted;
- else {
- sorted = 1;
- options->skiplist = &skiplist;
- }
-
- fd = open(path, O_RDONLY);
- if (fd < 0)
- die("Could not open skip list: %s", path);
- for (;;) {
- const char *p;
- int result = read_in_full(fd, buffer, sizeof(buffer));
- if (result < 0)
- die_errno("Could not read '%s'", path);
- if (!result)
- break;
- if (parse_oid_hex(buffer, &oid, &p) || *p != '\n')
- die("Invalid SHA-1: %s", buffer);
- oid_array_append(&skiplist, &oid);
- if (sorted && skiplist.nr > 1 &&
- oidcmp(&skiplist.oid[skiplist.nr - 2],
- &oid) > 0)
- sorted = 0;
- }
- close(fd);
-
- if (sorted)
- skiplist.sorted = 1;
-}
-
static int parse_msg_type(const char *str)
{
if (!strcmp(str, "error"))
if (!strcmp(buf, "skiplist")) {
if (equal == len)
die("skiplist requires a path");
- init_skiplist(options, buf + equal + 1);
+ oidset_parse_file(&options->skiplist, buf + equal + 1);
buf += len + 1;
continue;
}
static int object_on_skiplist(struct fsck_options *opts, struct object *obj)
{
- if (opts && opts->skiplist && obj)
- return oid_array_lookup(opts->skiplist, &obj->oid) >= 0;
- return 0;
+ return opts && obj && oidset_contains(&opts->skiplist, &obj->oid);
}
__attribute__((format (printf, 4, 5)))
continue;
if (S_ISDIR(entry.mode)) {
- obj = (struct object *)lookup_tree(the_repository, entry.oid);
+ obj = (struct object *)lookup_tree(the_repository, &entry.oid);
if (name && obj)
put_object_name(options, obj, "%s%s/", name,
entry.path);
result = options->walk(obj, OBJ_TREE, data, options);
}
else if (S_ISREG(entry.mode) || S_ISLNK(entry.mode)) {
- obj = (struct object *)lookup_blob(the_repository, entry.oid);
+ obj = (struct object *)lookup_blob(the_repository, &entry.oid);
if (name && obj)
put_object_name(options, obj, "%s%s", name,
entry.path);
o_name = NULL;
while (desc.size) {
- unsigned mode;
+ unsigned short mode;
const char *name, *backslash;
const struct object_id *oid;
return fsck_tag_buffer(tag, data, size, options);
}
-static int check_submodule_url(const char *url)
-{
- struct credential c = CREDENTIAL_INIT;
- int ret;
-
- if (looks_like_command_line_option(url))
- return -1;
-
- ret = credential_from_url_gently(&c, url, 1);
- credential_clear(&c);
- return ret;
-}
-
struct fsck_gitmodules_data {
struct object *obj;
struct fsck_options *options;
"disallowed submodule name: %s",
name);
if (!strcmp(key, "url") && value &&
- check_submodule_url(value) < 0)
+ looks_like_command_line_option(value))
data->ret |= report(data->options, data->obj,
FSCK_MSG_GITMODULES_URL,
"disallowed submodule url: %s",
blob = lookup_blob(the_repository, oid);
if (!blob) {
- struct object *obj = lookup_unknown_object(oid->hash);
+ struct object *obj = lookup_unknown_object(oid);
ret |= report(options, obj,
FSCK_MSG_GITMODULES_BLOB,
"non-blob found at .gitmodules");