refs/files: fix NULL pointer deref when releasing ref store
[git/gitster.git] / builtin / apply.c
blob861a01910ca20bcb9bd18279ebd10f9d94032fe1
1 #include "builtin.h"
2 #include "gettext.h"
3 #include "repository.h"
4 #include "apply.h"
6 static const char * const apply_usage[] = {
7 N_("git apply [<options>] [<patch>...]"),
8 NULL
9 };
11 int cmd_apply(int argc, const char **argv, const char *prefix)
13 int force_apply = 0;
14 int options = 0;
15 int ret;
16 struct apply_state state;
18 if (init_apply_state(&state, the_repository, prefix))
19 exit(128);
21 argc = apply_parse_options(argc, argv,
22 &state, &force_apply, &options,
23 apply_usage);
25 if (check_apply_state(&state, force_apply))
26 exit(128);
28 ret = apply_all_patches(&state, argc, argv, options);
30 clear_apply_state(&state);
32 return ret;