Skip to content

Commit

Permalink
Merge branch 'jt/fsck-skiplist-parse-fix' into next
Browse files Browse the repository at this point in the history
A misconfigured "fsck.skiplist" configuration variable was not
diagnosed as an error, which has been corrected.

* jt/fsck-skiplist-parse-fix:
  fsck: reject misconfigured fsck.skipList
  • Loading branch information
gitster committed Jan 9, 2025
2 parents bc024b7 + ca71580 commit d08b30f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion builtin/receive-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static int receive_pack_config(const char *var, const char *value,
char *path;

if (git_config_pathname(&path, var, value))
return 1;
return -1;
strbuf_addf(&fsck_msg_types, "%cskiplist=%s",
fsck_msg_types.len ? ',' : '=', path);
free(path);
Expand Down
2 changes: 1 addition & 1 deletion fetch-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -1867,7 +1867,7 @@ int fetch_pack_fsck_config(const char *var, const char *value,
char *path ;

if (git_config_pathname(&path, var, value))
return 0;
return -1;
strbuf_addf(msg_types, "%cskiplist=%s",
msg_types->len ? ',' : '=', path);
free(path);
Expand Down
2 changes: 1 addition & 1 deletion fsck.c
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,7 @@ int git_fsck_config(const char *var, const char *value,
struct strbuf sb = STRBUF_INIT;

if (git_config_pathname(&path, var, value))
return 1;
return -1;
strbuf_addf(&sb, "skiplist=%s", path);
free(path);
fsck_set_msg_types(options, sb.buf);
Expand Down
10 changes: 10 additions & 0 deletions t/t5504-fetch-receive-strict.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ test_expect_success 'fsck with unsorted skipList' '

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

test_expect_success 'receive-pack with missing receive.fsck.skipList path' '
test_must_fail git -c receive.fsck.skipList receive-pack dst 2>err &&
test_grep "unable to parse '\'receive.fsck.skiplist\'' from command-line config" err
'

test_expect_success 'push with receive.fsck.skipList' '
git push . $commit:refs/heads/bogus &&
rm -rf dst &&
Expand Down Expand Up @@ -255,6 +262,9 @@ test_expect_success 'fetch with fetch.fsck.skipList' '
test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec &&
# Invalid and/or bogus skipList input
test_must_fail git --git-dir=dst/.git -c fetch.fsck.skipList fetch \
"file://$(pwd)" $refspec 2>err &&
test_grep "unable to parse '\'fetch.fsck.skiplist\'' from command-line config" err &&
git --git-dir=dst/.git config fetch.fsck.skipList /dev/null &&
test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec &&
git --git-dir=dst/.git config fetch.fsck.skipList does-not-exist &&
Expand Down

0 comments on commit d08b30f

Please sign in to comment.