summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2016-06-03builtin/apply: move 'newfd' global into 'struct apply_state'Libravatar Christian Couder1-4/+5
To libify the apply functionality the 'newfd' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-03builtin/apply: add 'lock_file' pointer into 'struct apply_state'Libravatar Christian Couder1-4/+15
We cannot have a 'struct lock_file' allocated on the stack, as lockfile.c keeps a linked list of all created lock_file structures. Also 'struct apply_state' users might later want the same 'struct lock_file' instance to be reused by different series of calls to the apply api. So let's add a 'struct lock_file *lock_file' pointer into 'struct apply_state' and have the user of 'struct apply_state' allocate memory for the actual 'struct lock_file' instance. Let's also add an argument to init_apply_state(), so that the caller can easily supply a pointer to the allocated instance. Helped-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move applying patches into apply_all_patches()Libravatar Christian Couder1-58/+71
To libify the apply functionality we should provide a function to apply many patches. Let's move the code to do that into a new apply_all_patches() function. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'state' check into check_apply_state()Libravatar Christian Couder1-23/+29
To libify the apply functionality we should provide a function to check that the values in a 'struct apply_state' instance are coherent. Let's move the code to do that into a new check_apply_state() function. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'symlink_changes' global into 'struct apply_state'Libravatar Christian Couder1-22/+28
To libify the apply functionality the 'symlink_changes' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'fn_table' global into 'struct apply_state'Libravatar Christian Couder1-22/+25
To libify the apply functionality the 'fn_table' variable should not be static and global to the file. Let's move it into 'struct apply_state'. As fn_table is cleared at the end of apply_patch(), it is not necessary to clear it in clear_apply_state(). Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'state_linenr' global into 'struct apply_state'Libravatar Christian Couder1-35/+36
To libify the apply functionality the 'state_linenr' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'max_change' and 'max_len' into 'struct apply_state'Libravatar Christian Couder1-24/+25
To libify the apply functionality the 'max_change' and 'max_len' variables should not be static and global to the file. Let's move them into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'ws_ignore_action' into 'struct apply_state'Libravatar Christian Couder1-17/+20
To libify the apply functionality the 'ws_ignore_action' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'ws_error_action' into 'struct apply_state'Libravatar Christian Couder1-28/+33
To libify the apply functionality the 'ws_error_action' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'applied_after_fixing_ws' into 'struct apply_state'Libravatar Christian Couder1-5/+5
To libify the apply functionality the 'applied_after_fixing_ws' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'squelch_whitespace_errors' into 'struct apply_state'Libravatar Christian Couder1-11/+11
To libify the apply functionality the 'squelch_whitespace_errors' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: remove whitespace_option arg from set_default_whitespace_mode()Libravatar Christian Couder1-5/+4
A previous change has move the whitespace_option variable from cmd_apply into 'struct apply_state', so that we can now avoid passing it separately to set_default_whitespace_mode(). Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'whitespace_option' into 'struct apply_state'Libravatar Christian Couder1-7/+6
This will enable further refactoring, and it is more coherent and simpler if all the option_parse_*() functions are passed a 'struct apply_state' instance in opt->value. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'whitespace_error' global into 'struct apply_state'Libravatar Christian Couder1-13/+15
To libify the apply functionality the 'whitespace_error' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'root' global into 'struct apply_state'Libravatar Christian Couder1-33/+49
To libify the apply functionality the 'root' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'p_value_known' global into 'struct apply_state'Libravatar Christian Couder1-5/+4
To libify the apply functionality the 'p_value_known' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'p_value' global into 'struct apply_state'Libravatar Christian Couder1-52/+99
To libify the apply functionality the 'p_value' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'has_include' global into 'struct apply_state'Libravatar Christian Couder1-3/+3
To libify the apply functionality the 'has_include' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'limit_by_name' global into 'struct apply_state'Libravatar Christian Couder1-10/+16
To libify the apply functionality the 'limit_by_name' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'patch_input_file' global into 'struct apply_state'Libravatar Christian Couder1-10/+17
To libify the apply functionality the 'patch_input_file' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'apply' global into 'struct apply_state'Libravatar Christian Couder1-14/+17
To libify the apply functionality the 'apply' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'p_context' global into 'struct apply_state'Libravatar Christian Couder1-3/+4
To libify the apply functionality the 'p_context' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'fake_ancestor' global into 'struct apply_state'Libravatar Christian Couder1-8/+5
To libify the apply functionality the 'fake_ancestor' variable should not be static and global to the file. Let's move it into 'struct apply_state'. By the way remove a comment about '--index-info' that was renamed '--build-fake-ancestor' in commit 26b28007689d27a921ea90e5a29fc8eb74b0d297 (apply: get rid of --index-info in favor of --build-fake-ancestor, Sep 17 2007). Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'line_termination' global into 'struct apply_state'Libravatar Christian Couder1-5/+9
To libify the apply functionality the 'line_termination' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'unsafe_paths' global into 'struct apply_state'Libravatar Christian Couder1-4/+4
To libify the apply functionality the 'unsafe_paths' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'no_add' global into 'struct apply_state'Libravatar Christian Couder1-3/+3
To libify the apply functionality the 'no_add' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'threeway' global into 'struct apply_state'Libravatar Christian Couder1-7/+7
To libify the apply functionality the 'threeway' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'summary' global into 'struct apply_state'Libravatar Christian Couder1-4/+4
To libify the apply functionality the 'summary' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'numstat' global into 'struct apply_state'Libravatar Christian Couder1-5/+4
To libify the apply functionality the 'numstat' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'diffstat' global into 'struct apply_state'Libravatar Christian Couder1-5/+6
To libify the apply functionality the 'diffstat' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'cached' global into 'struct apply_state'Libravatar Christian Couder1-16/+19
To libify the apply functionality the 'cached' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'allow_overlap' global into 'struct apply_state'Libravatar Christian Couder1-5/+6
To libify the apply functionality the 'allow_overlap' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'update_index' global into 'struct apply_state'Libravatar Christian Couder1-19/+26
To libify the apply functionality the 'update_index' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'apply_verbosely' global into 'struct apply_state'Libravatar Christian Couder1-13/+13
To libify the apply functionality the 'apply_verbosely' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'apply_with_reject' global into 'struct apply_state'Libravatar Christian Couder1-7/+7
To libify the apply functionality the 'apply_with_reject' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'apply_in_reverse' global into 'struct apply_state'Libravatar Christian Couder1-19/+31
To libify the apply functionality the 'apply_in_reverse' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'check_index' global into 'struct apply_state'Libravatar Christian Couder1-29/+37
To libify the apply functionality the 'check_index' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'check' global into 'struct apply_state'Libravatar Christian Couder1-7/+7
To libify the apply functionality the 'check' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'unidiff_zero' global into 'struct apply_state'Libravatar Christian Couder1-18/+25
To libify the apply functionality the 'unidiff_zero' variable should not be static and global to the file. Let's move it into 'struct apply_state'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-01builtin/apply: move 'state' init into init_apply_state()Libravatar Christian Couder1-10/+22
When the apply functionality will be libified, the 'struct apply_state' will be used by different pieces of code. To properly initialize a 'struct apply_state', let's provide a nice and easy to use init_apply_state() function. Let's also provide clear_apply_state() to release memory used by 'struct apply_state' members, so that a 'struct apply_state' instance can be easily reused without leaking memory. Note that clear_apply_state() does nothing for now, but it will later. While at it, let's rename 'prefix_' parameter to 'prefix'. Helped-by: Eric Sunshine <sunshine@sunshineco.com> Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-05-12builtin/apply: introduce 'struct apply_state' to start libifyingLibravatar Christian Couder1-38/+56
Currently commands that want to use the apply functionality have to launch a "git apply" process which can be bad for performance. Let's start libifying the apply functionality and to do that we first need to get rid of the global variables in "builtin/apply.c". This patch introduces "struct apply_state" into which all the previously global variables will be moved. A new parameter called "state" that is a pointer to the "apply_state" structure will come at the beginning of the helper functions that need it and will be passed around the call chain. To start let's move the "prefix" and "prefix_length" global variables into "struct apply_state". Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-05-12builtin/apply: move 'read_stdin' global into cmd_apply()Libravatar Christian Couder1-1/+1
The 'read_stdin' variable doesn't need to be static and global to the file. It can be local to cmd_apply(), so let's move it there. This will make it easier to libify the apply functionality. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-05-12builtin/apply: move 'options' variable into cmd_apply()Libravatar Christian Couder1-1/+1
The 'options' variable doesn't need to be static and global to the file. It can be local to cmd_apply(), so let's move it there. This will make it easier to libify the apply functionality. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-05-12builtin/apply: extract line_by_line_fuzzy_match() from match_fragment()Libravatar Christian Couder1-55/+71
The match_fragment() function is very big and contains a big special case algorithm that does line by line fuzzy matching. So let's extract this algorithm in a separate line_by_line_fuzzy_match() function. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-05-12builtin/apply: avoid local variable shadowing 'len' parameterLibravatar Christian Couder1-10/+10
This is just a cleanup to avoid errors when compiling with -Wshadow and to make it safer to later move global variables into a "state" struct. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-05-12builtin/apply: avoid parameter shadowing 'linenr' globalLibravatar Christian Couder1-24/+24
Let's just rename the global 'state_linenr' as it will become 'state->linenr' in a following patch. This also avoid errors when compiling with -Wshadow and makes it safer to later move global variables into a "state" struct. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-05-12builtin/apply: avoid parameter shadowing 'p_value' globalLibravatar Christian Couder1-17/+17
Let's just rename the global 'state_p_value' as it will become 'state->p_value' in a following patch. This also avoid errors when compiling with -Wshadow and makes it safer to later move global variables into a "state" struct. Helped-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-05-12builtin/apply: make gitdiff_verify_name() return voidLibravatar Christian Couder1-13/+13
As the value returned by gitdiff_verify_name() is put into the same variable that is passed as a parameter to this function, it is simpler to pass the address of the variable and have gitdiff_verify_name() change the variable itself. This also makes it possible to later have this function return -1 instead of die()ing in case of error. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-05-10Eleventh batch for 2.9Libravatar Junio C Hamano1-0/+21
Signed-off-by: Junio C Hamano <gitster@pobox.com>