@@ -27,52 +27,6 @@ static const char * const apply_usage[] = {
2727 NULL
2828};
2929
30- static int parse_whitespace_option (struct apply_state * state , const char * option )
31- {
32- if (!option ) {
33- state -> ws_error_action = warn_on_ws_error ;
34- return 0 ;
35- }
36- if (!strcmp (option , "warn" )) {
37- state -> ws_error_action = warn_on_ws_error ;
38- return 0 ;
39- }
40- if (!strcmp (option , "nowarn" )) {
41- state -> ws_error_action = nowarn_ws_error ;
42- return 0 ;
43- }
44- if (!strcmp (option , "error" )) {
45- state -> ws_error_action = die_on_ws_error ;
46- return 0 ;
47- }
48- if (!strcmp (option , "error-all" )) {
49- state -> ws_error_action = die_on_ws_error ;
50- state -> squelch_whitespace_errors = 0 ;
51- return 0 ;
52- }
53- if (!strcmp (option , "strip" ) || !strcmp (option , "fix" )) {
54- state -> ws_error_action = correct_ws_error ;
55- return 0 ;
56- }
57- return error (_ ("unrecognized whitespace option '%s'" ), option );
58- }
59-
60- static int parse_ignorewhitespace_option (struct apply_state * state ,
61- const char * option )
62- {
63- if (!option || !strcmp (option , "no" ) ||
64- !strcmp (option , "false" ) || !strcmp (option , "never" ) ||
65- !strcmp (option , "none" )) {
66- state -> ws_ignore_action = ignore_ws_none ;
67- return 0 ;
68- }
69- if (!strcmp (option , "change" )) {
70- state -> ws_ignore_action = ignore_ws_change ;
71- return 0 ;
72- }
73- return error (_ ("unrecognized whitespace ignore option '%s'" ), option );
74- }
75-
7630static void set_default_whitespace_mode (struct apply_state * state )
7731{
7832 if (!state -> whitespace_option && !apply_default_whitespace )
@@ -4539,13 +4493,6 @@ static int apply_patch(struct apply_state *state,
45394493 return res ;
45404494}
45414495
4542- static void git_apply_config (void )
4543- {
4544- git_config_get_string_const ("apply.whitespace" , & apply_default_whitespace );
4545- git_config_get_string_const ("apply.ignorewhitespace" , & apply_default_ignorewhitespace );
4546- git_config (git_default_config , NULL );
4547- }
4548-
45494496static int option_parse_exclude (const struct option * opt ,
45504497 const char * arg , int unset )
45514498{
@@ -4604,44 +4551,6 @@ static int option_parse_directory(const struct option *opt,
46044551 return 0 ;
46054552}
46064553
4607- static void init_apply_state (struct apply_state * state ,
4608- const char * prefix ,
4609- struct lock_file * lock_file )
4610- {
4611- memset (state , 0 , sizeof (* state ));
4612- state -> prefix = prefix ;
4613- state -> prefix_length = state -> prefix ? strlen (state -> prefix ) : 0 ;
4614- state -> lock_file = lock_file ;
4615- state -> newfd = -1 ;
4616- state -> apply = 1 ;
4617- state -> line_termination = '\n' ;
4618- state -> p_value = 1 ;
4619- state -> p_context = UINT_MAX ;
4620- state -> squelch_whitespace_errors = 5 ;
4621- state -> ws_error_action = warn_on_ws_error ;
4622- state -> ws_ignore_action = ignore_ws_none ;
4623- state -> linenr = 1 ;
4624- string_list_init (& state -> fn_table , 0 );
4625- string_list_init (& state -> limit_by_name , 0 );
4626- string_list_init (& state -> symlink_changes , 0 );
4627- strbuf_init (& state -> root , 0 );
4628-
4629- git_apply_config ();
4630- if (apply_default_whitespace && parse_whitespace_option (state , apply_default_whitespace ))
4631- exit (1 );
4632- if (apply_default_ignorewhitespace && parse_ignorewhitespace_option (state , apply_default_ignorewhitespace ))
4633- exit (1 );
4634- }
4635-
4636- static void clear_apply_state (struct apply_state * state )
4637- {
4638- string_list_clear (& state -> limit_by_name , 0 );
4639- string_list_clear (& state -> symlink_changes , 0 );
4640- strbuf_release (& state -> root );
4641-
4642- /* &state->fn_table is cleared at the end of apply_patch() */
4643- }
4644-
46454554static void check_apply_state (struct apply_state * state , int force_apply )
46464555{
46474556 int is_not_gitdir = !startup_info -> have_repository ;
0 commit comments