Skip to content

Commit 24eb33e

Browse files
Barret Rhodengitster
authored andcommitted
fsck: rename and touch up init_skiplist()
init_skiplist() took a file consisting of SHA-1s and comments and added the objects to an oidset. This functionality is useful for other commands and will be moved to oidset.c in a future commit. In preparation for that move, this commit renames it to oidset_parse_file() to reflect its more generic usage and cleans up a few of the names. Signed-off-by: Barret Rhoden <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7755635 commit 24eb33e

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

fsck.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,34 +181,34 @@ static int fsck_msg_type(enum fsck_msg_id msg_id,
181181
return msg_type;
182182
}
183183

184-
static void init_skiplist(struct fsck_options *options, const char *path)
184+
void oidset_parse_file(struct oidset *set, const char *path)
185185
{
186186
FILE *fp;
187187
struct strbuf sb = STRBUF_INIT;
188188
struct object_id oid;
189189

190190
fp = fopen(path, "r");
191191
if (!fp)
192-
die("Could not open skip list: %s", path);
192+
die("could not open object name list: %s", path);
193193
while (!strbuf_getline(&sb, fp)) {
194194
const char *p;
195-
const char *hash;
195+
const char *name;
196196

197197
/*
198198
* Allow trailing comments, leading whitespace
199199
* (including before commits), and empty or whitespace
200200
* only lines.
201201
*/
202-
hash = strchr(sb.buf, '#');
203-
if (hash)
204-
strbuf_setlen(&sb, hash - sb.buf);
202+
name = strchr(sb.buf, '#');
203+
if (name)
204+
strbuf_setlen(&sb, name - sb.buf);
205205
strbuf_trim(&sb);
206206
if (!sb.len)
207207
continue;
208208

209209
if (parse_oid_hex(sb.buf, &oid, &p) || *p != '\0')
210-
die("Invalid SHA-1: %s", sb.buf);
211-
oidset_insert(&options->skiplist, &oid);
210+
die("invalid object name: %s", sb.buf);
211+
oidset_insert(set, &oid);
212212
}
213213
if (ferror(fp))
214214
die_errno("Could not read '%s'", path);
@@ -284,7 +284,7 @@ void fsck_set_msg_types(struct fsck_options *options, const char *values)
284284
if (!strcmp(buf, "skiplist")) {
285285
if (equal == len)
286286
die("skiplist requires a path");
287-
init_skiplist(options, buf + equal + 1);
287+
oidset_parse_file(&options->skiplist, buf + equal + 1);
288288
buf += len + 1;
289289
continue;
290290
}

t/t5504-fetch-receive-strict.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ test_expect_success 'fsck with unsorted skipList' '
164164
test_expect_success 'fsck with invalid or bogus skipList input' '
165165
git -c fsck.skipList=/dev/null -c fsck.missingEmail=ignore fsck &&
166166
test_must_fail git -c fsck.skipList=does-not-exist -c fsck.missingEmail=ignore fsck 2>err &&
167-
test_i18ngrep "Could not open skip list: does-not-exist" err &&
167+
test_i18ngrep "could not open.*: does-not-exist" err &&
168168
test_must_fail git -c fsck.skipList=.git/config -c fsck.missingEmail=ignore fsck 2>err &&
169-
test_i18ngrep "Invalid SHA-1: \[core\]" err
169+
test_i18ngrep "invalid object name: \[core\]" err
170170
'
171171

172172
test_expect_success 'fsck with other accepted skipList input (comments & empty lines)' '
@@ -193,7 +193,7 @@ test_expect_success 'fsck no garbage output from comments & empty lines errors'
193193
test_expect_success 'fsck with invalid abbreviated skipList input' '
194194
echo $commit | test_copy_bytes 20 >SKIP.abbreviated &&
195195
test_must_fail git -c fsck.skipList=SKIP.abbreviated fsck 2>err-abbreviated &&
196-
test_i18ngrep "^fatal: Invalid SHA-1: " err-abbreviated
196+
test_i18ngrep "^fatal: invalid object name: " err-abbreviated
197197
'
198198

199199
test_expect_success 'fsck with exhaustive accepted skipList input (various types of comments etc.)' '
@@ -226,10 +226,10 @@ test_expect_success 'push with receive.fsck.skipList' '
226226
test_must_fail git push --porcelain dst bogus &&
227227
git --git-dir=dst/.git config receive.fsck.skipList does-not-exist &&
228228
test_must_fail git push --porcelain dst bogus 2>err &&
229-
test_i18ngrep "Could not open skip list: does-not-exist" err &&
229+
test_i18ngrep "could not open.*: does-not-exist" err &&
230230
git --git-dir=dst/.git config receive.fsck.skipList config &&
231231
test_must_fail git push --porcelain dst bogus 2>err &&
232-
test_i18ngrep "Invalid SHA-1: \[core\]" err &&
232+
test_i18ngrep "invalid object name: \[core\]" err &&
233233
234234
git --git-dir=dst/.git config receive.fsck.skipList SKIP &&
235235
git push --porcelain dst bogus
@@ -255,10 +255,10 @@ test_expect_success 'fetch with fetch.fsck.skipList' '
255255
test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec &&
256256
git --git-dir=dst/.git config fetch.fsck.skipList does-not-exist &&
257257
test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec 2>err &&
258-
test_i18ngrep "Could not open skip list: does-not-exist" err &&
258+
test_i18ngrep "could not open.*: does-not-exist" err &&
259259
git --git-dir=dst/.git config fetch.fsck.skipList dst/.git/config &&
260260
test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec 2>err &&
261-
test_i18ngrep "Invalid SHA-1: \[core\]" err &&
261+
test_i18ngrep "invalid object name: \[core\]" err &&
262262
263263
git --git-dir=dst/.git config fetch.fsck.skipList dst/.git/SKIP &&
264264
git --git-dir=dst/.git fetch "file://$(pwd)" $refspec

0 commit comments

Comments
 (0)