Raw
1 #include "builtin.h"
2 #include "config.h"
3 #include "diff-hunks.h"
4 #include "gettext.h"
5 #include "parse-options.h"
6 #include "repository.h"
7
8 static const char * const diff_hunks_usage[] = {
9 N_("git diff-hunks verify"),
10 N_("git diff-hunks clear"),
11 NULL
12 };
13
14 static int cmd_diff_hunks_verify(int argc, const char **argv,
15 const char *prefix UNUSED,
16 struct repository *r)
17 {
18 struct option options[] = { OPT_END() };
19
20 argc = parse_options(argc, argv, NULL, options, diff_hunks_usage, 0);
21 if (argc)
22 usage_with_options(diff_hunks_usage, options);
23 return diff_hunks_verify(r) ? 1 : 0;
24 }
25
26 static int cmd_diff_hunks_clear(int argc, const char **argv,
27 const char *prefix UNUSED,
28 struct repository *r)
29 {
30 struct option options[] = { OPT_END() };
31
32 argc = parse_options(argc, argv, NULL, options, diff_hunks_usage, 0);
33 if (argc)
34 usage_with_options(diff_hunks_usage, options);
35 return diff_hunks_clear(r) ? 1 : 0;
36 }
37
38 int cmd_diff_hunks(int argc, const char **argv, const char *prefix,
39 struct repository *repo)
40 {
41 parse_opt_subcommand_fn *fn = NULL;
42 struct option options[] = {
43 OPT_SUBCOMMAND("verify", &fn, cmd_diff_hunks_verify),
44 OPT_SUBCOMMAND("clear", &fn, cmd_diff_hunks_clear),
45 OPT_END()
46 };
47
48 repo_config(repo, git_default_config, NULL);
49
50 argc = parse_options(argc, argv, prefix, options, diff_hunks_usage, 0);
51
52 return fn(argc, argv, prefix, repo);
53 }