Git 2.46-rc0
[git/gitster.git] / builtin / apply.c
blobd623c52f78fc6d1a7b8064b48b7f13eb5fd1b73a
1 #include "builtin.h"
2 #include "gettext.h"
3 #include "repository.h"
4 #include "hash.h"
5 #include "apply.h"
7 static const char * const apply_usage[] = {
8 N_("git apply [<options>] [<patch>...]"),
9 NULL
12 int cmd_apply(int argc, const char **argv, const char *prefix)
14 int force_apply = 0;
15 int options = 0;
16 int ret;
17 struct apply_state state;
19 if (init_apply_state(&state, the_repository, prefix))
20 exit(128);
23 * We could to redo the "apply.c" machinery to make this
24 * arbitrary fallback unnecessary, but it is dubious that it
25 * is worth the effort.
26 * cf. https://lore.kernel.org/git/xmqqcypfcmn4.fsf@gitster.g/
28 if (!the_hash_algo)
29 repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
31 argc = apply_parse_options(argc, argv,
32 &state, &force_apply, &options,
33 apply_usage);
35 if (check_apply_state(&state, force_apply))
36 exit(128);
38 ret = apply_all_patches(&state, argc, argv, options);
40 clear_apply_state(&state);
42 return ret;