Git fork
at reftables-rust 51 lines 1.1 kB view raw
1#define USE_THE_REPOSITORY_VARIABLE 2#include "builtin.h" 3#include "gettext.h" 4#include "hash.h" 5#include "apply.h" 6 7static const char * const apply_usage[] = { 8 N_("git apply [<options>] [<patch>...]"), 9 NULL 10}; 11 12int cmd_apply(int argc, 13 const char **argv, 14 const char *prefix, 15 struct repository *repo) 16{ 17 int force_apply = 0; 18 int options = 0; 19 int ret; 20 struct apply_state state; 21 22 if (init_apply_state(&state, the_repository, prefix)) 23 exit(128); 24 25 /* 26 * We could to redo the "apply.c" machinery to make this 27 * arbitrary fallback unnecessary, but it is dubious that it 28 * is worth the effort. 29 * cf. https://lore.kernel.org/git/xmqqcypfcmn4.fsf@gitster.g/ 30 */ 31 if (!the_hash_algo) 32 repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT); 33 34 argc = apply_parse_options(argc, argv, 35 &state, &force_apply, &options, 36 apply_usage); 37 38 if (repo) { 39 prepare_repo_settings(repo); 40 repo->settings.command_requires_full_index = 0; 41 } 42 43 if (check_apply_state(&state, force_apply)) 44 exit(128); 45 46 ret = apply_all_patches(&state, argc, argv, options); 47 48 clear_apply_state(&state); 49 50 return ret; 51}