Skip to content

Commit f75d6ce

Browse files
jltoblergitster
authored andcommitted
fetch-pack: introduce fetch_pack_options
When `fetch_pack_config()` is invoked, fetch-pack configuration is parsed from the config. As part of this operation, fsck message severity configuration is assigned to the `fsck_msg_types` global variable. This is optionally used to configure the downstream git-index-pack(1) when the `--strict` option is specified. In a subsequent commit, the same fetch-pack fsck message configuration needs to be reused. To facilitate this, introduce `fetch_pack_options` which gets written to during the `fetch_pack_config_cb()` instead of directly modifying the `fsck_msg_types` global. Signed-off-by: Justin Tobler <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4c24750 commit f75d6ce

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

fetch-pack.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ static int server_supports_filtering;
4848
static int advertise_sid;
4949
static struct shallow_lock shallow_lock;
5050
static const char *alternate_shallow_file;
51+
static struct fetch_pack_options fetch_pack_options = FETCH_PACK_OPTIONS_INIT;
5152
static struct fsck_options fsck_options = FSCK_OPTIONS_MISSING_GITMODULES;
52-
static struct strbuf fsck_msg_types = STRBUF_INIT;
5353
static struct string_list uri_protocols = STRING_LIST_INIT_DUP;
5454

5555
/* Remember to update object flag allocation in object.h */
@@ -1017,7 +1017,7 @@ static int get_pack(struct fetch_pack_args *args,
10171017
strvec_push(&cmd.args, "--fsck-objects");
10181018
else
10191019
strvec_pushf(&cmd.args, "--strict%s",
1020-
fsck_msg_types.buf);
1020+
fetch_pack_options.fsck_msg_types.buf);
10211021
}
10221022

10231023
if (index_pack_args) {
@@ -1860,15 +1860,16 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
18601860
static int fetch_pack_config_cb(const char *var, const char *value,
18611861
const struct config_context *ctx, void *cb)
18621862
{
1863+
struct fetch_pack_options *opts = cb;
18631864
const char *msg_id;
18641865

18651866
if (strcmp(var, "fetch.fsck.skiplist") == 0) {
18661867
char *path ;
18671868

18681869
if (git_config_pathname(&path, var, value))
18691870
return 1;
1870-
strbuf_addf(&fsck_msg_types, "%cskiplist=%s",
1871-
fsck_msg_types.len ? ',' : '=', path);
1871+
strbuf_addf(&opts->fsck_msg_types, "%cskiplist=%s",
1872+
opts->fsck_msg_types.len ? ',' : '=', path);
18721873
free(path);
18731874
return 0;
18741875
}
@@ -1877,8 +1878,9 @@ static int fetch_pack_config_cb(const char *var, const char *value,
18771878
if (!value)
18781879
return config_error_nonbool(var);
18791880
if (is_valid_msg_type(msg_id, value))
1880-
strbuf_addf(&fsck_msg_types, "%c%s=%s",
1881-
fsck_msg_types.len ? ',' : '=', msg_id, value);
1881+
strbuf_addf(&opts->fsck_msg_types, "%c%s=%s",
1882+
opts->fsck_msg_types.len ? ',' : '=',
1883+
msg_id, value);
18821884
else
18831885
warning("Skipping unknown msg id '%s'", msg_id);
18841886
return 0;
@@ -1904,7 +1906,7 @@ static void fetch_pack_config(void)
19041906
}
19051907
}
19061908

1907-
git_config(fetch_pack_config_cb, NULL);
1909+
git_config(fetch_pack_config_cb, &fetch_pack_options);
19081910
}
19091911

19101912
static void fetch_pack_setup(void)

fetch-pack.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,12 @@ int report_unmatched_refs(struct ref **sought, int nr_sought);
106106
*/
107107
int fetch_pack_fsck_objects(void);
108108

109+
struct fetch_pack_options {
110+
struct strbuf fsck_msg_types;
111+
};
112+
113+
#define FETCH_PACK_OPTIONS_INIT { \
114+
.fsck_msg_types = STRBUF_INIT, \
115+
}
116+
109117
#endif

0 commit comments

Comments
 (0)