257
static unsigned int cmd_save = 100;
258
static uintmax_t next_mark;
259
static struct strbuf new_data = STRBUF_INIT;
260
-static int seen_data_command;
260
static int require_explicit_termination;
262
-static int allow_unsafe_features;
261
262
/* Signal handling */
263
static volatile sig_atomic_t checkpoint_requested;
275
int argc;
276
const char **argv;
277
const char *prefix;
278
+ int seen_data_command;
279
+ int allow_unsafe_features;
280
};
281
282
static void fast_import_state_init(struct fast_import_state *state,
1876
if (stdin_eof)
1877
return EOF;
1878
1879
- if (!seen_data_command
1879
+ if (!state->seen_data_command
1880
&& !starts_with(command_buf.buf, "feature ")
1881
&& !starts_with(command_buf.buf, "option ")) {
1882
parse_argv(state);
3809
return 1;
3810
}
3811
3812
-static void check_unsafe_feature(struct fast_import_state *state UNUSED, const char *feature, int from_stream)
3812
+static void check_unsafe_feature(struct fast_import_state *state, const char *feature, int from_stream)
3813
{
3814
- if (from_stream && !allow_unsafe_features)
3814
+ if (from_stream && !state->allow_unsafe_features)
3815
die(_("feature '%s' forbidden in input without --allow-unsafe-features"),
3816
feature);
3817
}
3860
3861
static void parse_feature(struct fast_import_state *state, const char *feature)
3862
{
3863
- if (seen_data_command)
3863
+ if (state->seen_data_command)
3864
die(_("got feature command '%s' after data command"), feature);
3865
3866
if (parse_one_feature(state, feature, 1))
3871
3872
static void parse_option(struct fast_import_state *state, const char *option)
3873
{
3874
- if (seen_data_command)
3874
+ if (state->seen_data_command)
3875
die(_("got option command '%s' after data command"), option);
3876
3877
if (parse_one_option(state, option))
3939
if (i != state->argc)
3940
usage(fast_import_usage);
3941
3942
- seen_data_command = 1;
3942
+ state->seen_data_command = 1;
3943
if (import_marks_file)
3944
read_marks();
3945
build_mark_map(&sub_marks_from, &sub_marks_to);
3954
3955
show_usage_if_asked(argc, argv, fast_import_usage);
3956
3957
+ fast_import_state_init(&state, argc, argv, prefix);
3958
+
3959
reset_pack_idx_option(&pack_idx_opts);
3960
git_pack_config();
3961
3979
if (*arg != '-' || !strcmp(arg, "--"))
3980
break;
3981
if (!strcmp(arg, "--allow-unsafe-features"))
3980
- allow_unsafe_features = 1;
3982
+ state.allow_unsafe_features = 1;
3983
}
3984
3983
- fast_import_state_init(&state, argc, argv, prefix);
3984
-
3985
rc_free = mem_pool_alloc(&fi_mem_pool, cmd_save * sizeof(*rc_free));
3986
for (unsigned int i = 0; i < (cmd_save - 1); i++)
3987
rc_free[i].next = &rc_free[i + 1];
4028
}
4029
4030
/* argv hasn't been parsed yet, do so */
4031
- if (!seen_data_command)
4031
+ if (!state.seen_data_command)
4032
parse_argv(&state);
4033
4034
if (require_explicit_termination && feof(stdin))