Skip to content

Commit ca71580

Browse files
jltoblergitster
authored andcommitted
fsck: reject misconfigured fsck.skipList
In Git, fsck operations can ignore known broken objects via the `fsck.skipList` configuration. This option expects a path to a file with the list of object names. When the configuration is specified without a path, an error message is printed, but the command continues as if the configuration was not set. Configuring `fsck.skipList` without a value is a misconfiguration so config parsing should be more strict and reject it. Update `git_fsck_config()` to no longer ignore misconfiguration of `fsck.skipList`. The same behavior is also present for `fetch.fsck.skipList` and `receive.fsck.skipList` so the configuration parsers for these are updated to ensure the related operations remain consistent. Signed-off-by: Justin Tobler <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bc2c657 commit ca71580

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

builtin/receive-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static int receive_pack_config(const char *var, const char *value,
174174
char *path;
175175

176176
if (git_config_pathname(&path, var, value))
177-
return 1;
177+
return -1;
178178
strbuf_addf(&fsck_msg_types, "%cskiplist=%s",
179179
fsck_msg_types.len ? ',' : '=', path);
180180
free(path);

fetch-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1867,7 +1867,7 @@ int fetch_pack_fsck_config(const char *var, const char *value,
18671867
char *path ;
18681868

18691869
if (git_config_pathname(&path, var, value))
1870-
return 0;
1870+
return -1;
18711871
strbuf_addf(msg_types, "%cskiplist=%s",
18721872
msg_types->len ? ',' : '=', path);
18731873
free(path);

fsck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,7 @@ int git_fsck_config(const char *var, const char *value,
13531353
struct strbuf sb = STRBUF_INIT;
13541354

13551355
if (git_config_pathname(&path, var, value))
1356-
return 1;
1356+
return -1;
13571357
strbuf_addf(&sb, "skiplist=%s", path);
13581358
free(path);
13591359
fsck_set_msg_types(options, sb.buf);

t/t5504-fetch-receive-strict.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ test_expect_success 'fsck with unsorted skipList' '
167167

168168
test_expect_success 'fsck with invalid or bogus skipList input' '
169169
git -c fsck.skipList=/dev/null -c fsck.missingEmail=ignore fsck &&
170+
test_must_fail git -c fsck.skipList -c fsck.missingEmail=ignore fsck 2>err &&
171+
test_grep "unable to parse '\'fsck.skiplist\'' from command-line config" err &&
170172
test_must_fail git -c fsck.skipList=does-not-exist -c fsck.missingEmail=ignore fsck 2>err &&
171173
test_grep "could not open.*: does-not-exist" err &&
172174
test_must_fail git -c fsck.skipList=.git/config -c fsck.missingEmail=ignore fsck 2>err &&
@@ -213,6 +215,11 @@ test_expect_success 'fsck with exhaustive accepted skipList input (various types
213215
test_must_be_empty err
214216
'
215217

218+
test_expect_success 'receive-pack with missing receive.fsck.skipList path' '
219+
test_must_fail git -c receive.fsck.skipList receive-pack dst 2>err &&
220+
test_grep "unable to parse '\'receive.fsck.skiplist\'' from command-line config" err
221+
'
222+
216223
test_expect_success 'push with receive.fsck.skipList' '
217224
git push . $commit:refs/heads/bogus &&
218225
rm -rf dst &&
@@ -255,6 +262,9 @@ test_expect_success 'fetch with fetch.fsck.skipList' '
255262
test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec &&
256263
257264
# Invalid and/or bogus skipList input
265+
test_must_fail git --git-dir=dst/.git -c fetch.fsck.skipList fetch \
266+
"file://$(pwd)" $refspec 2>err &&
267+
test_grep "unable to parse '\'fetch.fsck.skiplist\'' from command-line config" err &&
258268
git --git-dir=dst/.git config fetch.fsck.skipList /dev/null &&
259269
test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec &&
260270
git --git-dir=dst/.git config fetch.fsck.skipList does-not-exist &&

0 commit comments

Comments
 (0)