builtin-am: implement committing applied patch
[gitweb.git] / builtin / fsck.c
index 070909ef208fe6815898b35539540c39da8448ad..f4b87e9b33710e5ae67ec8886aad5259fdb0177f 100644 (file)
@@ -49,6 +49,19 @@ static int show_dangling = 1;
 
 static int fsck_config(const char *var, const char *value, void *cb)
 {
+       if (strcmp(var, "fsck.skiplist") == 0) {
+               const char *path;
+               struct strbuf sb = STRBUF_INIT;
+
+               if (git_config_pathname(&path, var, value))
+                       return 1;
+               strbuf_addf(&sb, "skiplist=%s", path);
+               free((char *)path);
+               fsck_set_msg_types(&fsck_obj_options, sb.buf);
+               strbuf_release(&sb);
+               return 0;
+       }
+
        if (skip_prefix(var, "fsck.", &var)) {
                fsck_set_msg_type(&fsck_obj_options, var, value);
                return 0;
@@ -456,35 +469,41 @@ static void fsck_dir(int i, char *path)
 
 static int default_refs;
 
+static void fsck_handle_reflog_sha1(const char *refname, unsigned char *sha1)
+{
+       struct object *obj;
+
+       if (!is_null_sha1(sha1)) {
+               obj = lookup_object(sha1);
+               if (obj) {
+                       obj->used = 1;
+                       mark_object_reachable(obj);
+               } else {
+                       error("%s: invalid reflog entry %s", refname, sha1_to_hex(sha1));
+                       errors_found |= ERROR_REACHABLE;
+               }
+       }
+}
+
 static int fsck_handle_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
                const char *email, unsigned long timestamp, int tz,
                const char *message, void *cb_data)
 {
-       struct object *obj;
+       const char *refname = cb_data;
 
        if (verbose)
                fprintf(stderr, "Checking reflog %s->%s\n",
                        sha1_to_hex(osha1), sha1_to_hex(nsha1));
 
-       if (!is_null_sha1(osha1)) {
-               obj = lookup_object(osha1);
-               if (obj) {
-                       obj->used = 1;
-                       mark_object_reachable(obj);
-               }
-       }
-       obj = lookup_object(nsha1);
-       if (obj) {
-               obj->used = 1;
-               mark_object_reachable(obj);
-       }
+       fsck_handle_reflog_sha1(refname, osha1);
+       fsck_handle_reflog_sha1(refname, nsha1);
        return 0;
 }
 
 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);
+       for_each_reflog_ent(logname, fsck_handle_reflog_ent, (void *)logname);
        return 0;
 }