2005-05-23 19:52:17 +02:00
|
|
|
#include "cache.h"
|
2006-05-23 14:15:34 +02:00
|
|
|
#include "builtin.h"
|
2008-12-28 00:03:57 +01:00
|
|
|
#include "parse-options.h"
|
2016-04-22 20:55:46 +02:00
|
|
|
#include "lockfile.h"
|
2016-08-08 23:02:59 +02:00
|
|
|
#include "apply.h"
|
2016-05-11 15:16:19 +02:00
|
|
|
|
2008-12-28 00:03:57 +01:00
|
|
|
static const char * const apply_usage[] = {
|
2015-01-13 08:44:47 +01:00
|
|
|
N_("git apply [<options>] [<patch>...]"),
|
2008-12-28 00:03:57 +01:00
|
|
|
NULL
|
|
|
|
};
|
2005-05-23 19:52:17 +02:00
|
|
|
|
2006-06-06 21:51:49 +02:00
|
|
|
static struct lock_file lock_file;
|
2005-06-05 23:05:43 +02:00
|
|
|
|
2016-05-24 10:11:24 +02:00
|
|
|
int cmd_apply(int argc, const char **argv, const char *prefix)
|
|
|
|
{
|
2008-12-28 00:03:57 +01:00
|
|
|
int force_apply = 0;
|
2016-05-11 15:16:17 +02:00
|
|
|
int options = 0;
|
2016-05-24 10:11:24 +02:00
|
|
|
int ret;
|
2016-05-11 15:16:19 +02:00
|
|
|
struct apply_state state;
|
2005-05-23 19:52:17 +02:00
|
|
|
|
2016-08-08 23:03:08 +02:00
|
|
|
if (init_apply_state(&state, prefix, &lock_file))
|
|
|
|
exit(128);
|
2007-02-17 21:37:25 +01:00
|
|
|
|
2016-09-04 22:18:30 +02:00
|
|
|
argc = apply_parse_options(argc, argv,
|
|
|
|
&state, &force_apply, &options,
|
|
|
|
apply_usage);
|
2009-05-23 20:53:11 +02:00
|
|
|
|
2016-08-08 23:03:09 +02:00
|
|
|
if (check_apply_state(&state, force_apply))
|
|
|
|
exit(128);
|
2015-01-30 00:35:24 +01:00
|
|
|
|
2016-05-24 10:11:24 +02:00
|
|
|
ret = apply_all_patches(&state, argc, argv, options);
|
2005-05-23 19:52:17 +02:00
|
|
|
|
2016-05-24 10:10:46 +02:00
|
|
|
clear_apply_state(&state);
|
2005-11-26 08:14:15 +01:00
|
|
|
|
2016-05-24 10:11:24 +02:00
|
|
|
return ret;
|
2005-05-23 19:52:17 +02:00
|
|
|
}
|