]>
Commit | Line | Data |
---|---|---|
6634f054 CC |
1 | /* |
2 | * Builtin "git interpret-trailers" | |
3 | * | |
4 | * Copyright (c) 2013, 2014 Christian Couder <chriscool@tuxfamily.org> | |
5 | * | |
6 | */ | |
7 | ||
8 | #include "cache.h" | |
9 | #include "builtin.h" | |
10 | #include "parse-options.h" | |
11 | #include "string-list.h" | |
12 | #include "trailer.h" | |
13 | ||
14 | static const char * const git_interpret_trailers_usage[] = { | |
e1f89863 | 15 | N_("git interpret-trailers [--in-place] [--trim-empty] [(--trailer <token>[(=|:)<value>])...] [<file>...]"), |
6634f054 CC |
16 | NULL |
17 | }; | |
18 | ||
19 | int cmd_interpret_trailers(int argc, const char **argv, const char *prefix) | |
20 | { | |
8abc8980 | 21 | struct process_trailer_options opts = PROCESS_TRAILER_OPTIONS_INIT; |
7c4b1695 | 22 | struct string_list trailers = STRING_LIST_INIT_NODUP; |
6634f054 CC |
23 | |
24 | struct option options[] = { | |
8abc8980 JK |
25 | OPT_BOOL(0, "in-place", &opts.in_place, N_("edit files in place")), |
26 | OPT_BOOL(0, "trim-empty", &opts.trim_empty, N_("trim empty trailers")), | |
56c493ed | 27 | OPT_BOOL(0, "only-trailers", &opts.only_trailers, N_("output only the trailers")), |
6634f054 CC |
28 | OPT_STRING_LIST(0, "trailer", &trailers, N_("trailer"), |
29 | N_("trailer(s) to add")), | |
30 | OPT_END() | |
31 | }; | |
32 | ||
33 | argc = parse_options(argc, argv, prefix, options, | |
34 | git_interpret_trailers_usage, 0); | |
35 | ||
36 | if (argc) { | |
37 | int i; | |
38 | for (i = 0; i < argc; i++) | |
8abc8980 | 39 | process_trailers(argv[i], &opts, &trailers); |
e1f89863 | 40 | } else { |
8abc8980 | 41 | if (opts.in_place) |
e1f89863 | 42 | die(_("no input file given for in-place editing")); |
8abc8980 | 43 | process_trailers(NULL, &opts, &trailers); |
e1f89863 | 44 | } |
6634f054 CC |
45 | |
46 | string_list_clear(&trailers, 0); | |
47 | ||
48 | return 0; | |
49 | } |