summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/config.txt8
-rw-r--r--builtin/receive-pack.c11
-rw-r--r--fsck.c50
-rw-r--r--fsck.h1
-rwxr-xr-xt/t5504-fetch-receive-strict.sh12
5 files changed, 82 insertions, 0 deletions
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 1c657675a7..f6cbd6de8e 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -2222,6 +2222,14 @@ which would not pass pushing when `receive.fsckObjects = true`, allowing
the host to accept repositories with certain known issues but still catch
other issues.
+receive.fsck.skipList::
+ The path to a sorted list of object names (i.e. one SHA-1 per
+ line) that are known to be broken in a non-fatal way and should
+ be ignored. This feature is useful when an established project
+ should be accepted despite early commits containing errors that
+ can be safely ignored such as invalid committer email addresses.
+ Note: corrupt objects cannot be skipped with this setting.
+
receive.unpackLimit::
If the number of objects received in a push is below this
limit then the objects will be unpacked into loose object
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 3afe8f80c1..4ced2eba3c 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -117,6 +117,17 @@ static int receive_pack_config(const char *var, const char *value, void *cb)
return 0;
}
+ if (strcmp(var, "receive.fsck.skiplist") == 0) {
+ const char *path;
+
+ if (git_config_pathname(&path, var, value))
+ return 1;
+ strbuf_addf(&fsck_msg_types, "%cskiplist=%s",
+ fsck_msg_types.len ? ',' : '=', path);
+ free((char *)path);
+ return 0;
+ }
+
if (skip_prefix(var, "receive.fsck.", &var)) {
if (is_valid_msg_type(var, value))
strbuf_addf(&fsck_msg_types, "%c%s=%s",
diff --git a/fsck.c b/fsck.c
index 7a614bba82..1523243f1b 100644
--- a/fsck.c
+++ b/fsck.c
@@ -8,6 +8,7 @@
#include "fsck.h"
#include "refs.h"
#include "utf8.h"
+#include "sha1-array.h"
#define FSCK_FATAL -1
#define FSCK_INFO -2
@@ -127,6 +128,43 @@ static int fsck_msg_type(enum fsck_msg_id msg_id,
return msg_type;
}
+static void init_skiplist(struct fsck_options *options, const char *path)
+{
+ static struct sha1_array skiplist = SHA1_ARRAY_INIT;
+ int sorted, fd;
+ char buffer[41];
+ unsigned char sha1[20];
+
+ 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 (;;) {
+ int result = read_in_full(fd, buffer, sizeof(buffer));
+ if (result < 0)
+ die_errno("Could not read '%s'", path);
+ if (!result)
+ break;
+ if (get_sha1_hex(buffer, sha1) || buffer[40] != '\n')
+ die("Invalid SHA-1: %s", buffer);
+ sha1_array_append(&skiplist, sha1);
+ if (sorted && skiplist.nr > 1 &&
+ hashcmp(skiplist.sha1[skiplist.nr - 2],
+ sha1) > 0)
+ sorted = 0;
+ }
+ close(fd);
+
+ if (sorted)
+ skiplist.sorted = 1;
+}
+
static int parse_msg_type(const char *str)
{
if (!strcmp(str, "error"))
@@ -191,6 +229,14 @@ void fsck_set_msg_types(struct fsck_options *options, const char *values)
buf[equal] = tolower(buf[equal]);
buf[equal] = '\0';
+ if (!strcmp(buf, "skiplist")) {
+ if (equal == len)
+ die("skiplist requires a path");
+ init_skiplist(options, buf + equal + 1);
+ buf += len + 1;
+ continue;
+ }
+
if (equal == len)
die("Missing '=': '%s'", buf);
@@ -229,6 +275,10 @@ static int report(struct fsck_options *options, struct object *object,
if (msg_type == FSCK_IGNORE)
return 0;
+ if (options->skiplist && object &&
+ sha1_array_lookup(options->skiplist, object->sha1) >= 0)
+ return 0;
+
if (msg_type == FSCK_FATAL)
msg_type = FSCK_ERROR;
else if (msg_type == FSCK_INFO)
diff --git a/fsck.h b/fsck.h
index 1dab276899..dded84b5f9 100644
--- a/fsck.h
+++ b/fsck.h
@@ -32,6 +32,7 @@ struct fsck_options {
fsck_error error_func;
unsigned strict:1;
int *msg_type;
+ struct sha1_array *skiplist;
};
#define FSCK_OPTIONS_DEFAULT { NULL, fsck_error_function, 0, NULL }
diff --git a/t/t5504-fetch-receive-strict.sh b/t/t5504-fetch-receive-strict.sh
index 720c121522..44f3d5fb28 100755
--- a/t/t5504-fetch-receive-strict.sh
+++ b/t/t5504-fetch-receive-strict.sh
@@ -123,6 +123,18 @@ committer Bugs Bunny <bugs@bun.ni> 1234567890 +0000
This commit object intentionally broken
EOF
+test_expect_success 'push with receive.fsck.skipList' '
+ commit="$(git hash-object -t commit -w --stdin <bogus-commit)" &&
+ git push . $commit:refs/heads/bogus &&
+ rm -rf dst &&
+ git init dst &&
+ git --git-dir=dst/.git config receive.fsckObjects true &&
+ test_must_fail git push --porcelain dst bogus &&
+ git --git-dir=dst/.git config receive.fsck.skipList SKIP &&
+ echo $commit >dst/.git/SKIP &&
+ git push --porcelain dst bogus
+'
+
test_expect_success 'push with receive.fsck.missingEmail=warn' '
commit="$(git hash-object -t commit -w --stdin <bogus-commit)" &&
git push . $commit:refs/heads/bogus &&