This is a patch series about libifying "git apply" functionality, to be able to use this functionality in "git am" without spawning new processes. This should make "git am" and "git rebase" significantly faster. This has been discussed in the following thread: http://thread.gmane.org/gmane.comp.version-control.git/287236/ This RFC patch series for now just gets rid of the global variables and refactors the code around a bit. As suggested by Junio the global variables in builtin/apply.c are just thrown into a single "apply_state" structure that is passed around the callchain. A new parameter called "state" that is a pointer to the "apply_state" structure comes at the beginning of the helper functions that need it. Before I make further changes to handle erroneous input and make the libified functions not die() and properly clean things up, I'd be happy to get some feedback. One point I'd especially welcome feedback about is the fact that there are many boolean options that are using OPT_BOOL(...), so they use an int. And there are a few others that are using OPT_BIT(...), so they use just a bit. I wonder if it is worth it to try to be consistent, and maybe also to try to save some memory. Related to this, some of the variables for these options have not been moved into the "apply_state" structure, because they are not global to the file, but maybe for consistency they should be. Christian Couder (48): builtin/apply: avoid parameter shadowing 'p_value' global builtin/apply: avoid parameter shadowing 'linenr' global builtin/apply: avoid local variable shadowing 'len' parameter builtin/apply: extract line_by_line_fuzzy_match() from match_fragment() builtin/apply: move 'options' variable into cmd_apply() builtin/apply: introduce 'struct apply_state' to start libifying builtin/apply: move 'newfd' global into 'struct apply_state' builtin/apply: move 'unidiff_zero' global into 'struct apply_state' builtin/apply: move 'check' global into 'struct apply_state' builtin/apply: move 'check_index' global into 'struct apply_state' builtin/apply: move 'apply_in_reverse' global into 'struct apply_state' builtin/apply: move 'apply_with_reject' global into 'struct apply_state' builtin/apply: move 'apply_verbosely' global into 'struct apply_state' builtin/apply: move 'update_index' global into 'struct apply_state' builtin/apply: move 'allow_overlap' global into 'struct apply_state' builtin/apply: move 'cached' global into 'struct apply_state' builtin/apply: move 'diffstat' global into 'struct apply_state' builtin/apply: move 'numstat' global into 'struct apply_state' builtin/apply: move 'summary' global into 'struct apply_state' builtin/apply: move 'threeway' global into 'struct apply_state' builtin/apply: move 'no-add' global into 'struct apply_state' builtin/apply: move 'unsafe_paths' global into 'struct apply_state' builtin/apply: move 'line_termination' global into 'struct apply_state' builtin/apply: move 'fake_ancestor' global into 'struct apply_state' builtin/apply: move 'p_context' global into 'struct apply_state' builtin/apply: move 'apply' global into 'struct apply_state' builtin/apply: move 'read_stdin' global into cmd_apply() builtin/apply: move 'lock_file' global into 'struct apply_state' builtin/apply: move 'patch_input_file' global into 'struct apply_state' builtin/apply: move 'limit_by_name' global into 'struct apply_state' builtin/apply: move 'has_include' global into 'struct apply_state' builtin/apply: move 'p_value' global into 'struct apply_state' builtin/apply: move 'p_value_known' global into 'struct apply_state' builtin/apply: move 'root' global into 'struct apply_state' builtin/apply: move 'whitespace_error' global into 'struct apply_state' builtin/apply: move 'whitespace_option' into 'struct apply_state' builtin/apply: remove whitespace_option arg from set_default_whitespace_mode() builtin/apply: move 'squelch_whitespace_errors' into 'struct apply_state' builtin/apply: move 'applied_after_fixing_ws' into 'struct apply_state' builtin/apply: move 'ws_error_action' into 'struct apply_state' builtin/apply: move 'ws_ignore_action' into 'struct apply_state' builtin/apply: move 'max_change' and 'max_len' into 'struct apply_state' builtin/apply: move 'linenr' global into 'struct apply_state' builtin/apply: move 'fn_table' global into 'struct apply_state' builtin/apply: move 'symlink_changes' global into 'struct apply_state' builtin/apply: move 'state' init into init_apply_state() builtin/apply: move 'state' check into check_apply_state() builtin/apply: move applying patches into apply_all_patches() builtin/apply.c | 1424 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 817 insertions(+), 607 deletions(-) -- 2.8.0.rc1.49.gca61272 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html