"Elijah Newren via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes: > From: Elijah Newren <newren@xxxxxxxxx> > > The function add_files_to_cache() is used by all three of builtin/{add, > checkout, commit}.c. That suggests this is common library code, and > should be moved somewhere else, like read-cache.c. However, the > function and its helpers made use of two global variables that made > straight code movement difficult: > * the_index > * include_sparse I was checking that add_filer_to_cache() did not inadvertently use these global variables even after the refactoring, and it looks good. It's a pity that we can't remove the USE_THE_INDEX_VARIABLE #define even after this patch (other parts in builtin/add.c use it), but I couldn't see any more usages of the_index in that function. There is no more usage of include_sparse, indeed, as can be seen from the next patch (when the function is moved to another file that has no access to include_sparse declared in builtin/add.c).