diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-10-20 12:25:30 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-10-20 12:25:32 -0700 |
commit | 9d04401ffe18138138e8f765c2bb31420f3efe25 (patch) | |
tree | d26e9823fb98bac3245a1b174d87cb58ae12ba80 /builtin | |
parent | 7df3b072a90f77f7fd82c493659e1b1160db5658 (diff) | |
parent | dfd66ddf5aa9aacc06ed38a9ee2cc15a4f2d4896 (diff) | |
download | git-9d04401ffe18138138e8f765c2bb31420f3efe25.tar.gz git-9d04401ffe18138138e8f765c2bb31420f3efe25.tar.xz |
Merge branch 'cc/interpret-trailers'
A new filter to programatically edit the tail end of the commit log
messages.
* cc/interpret-trailers:
Documentation: add documentation for 'git interpret-trailers'
trailer: add tests for commands in config file
trailer: execute command from 'trailer.<name>.command'
trailer: add tests for "git interpret-trailers"
trailer: add interpret-trailers command
trailer: put all the processing together and print
trailer: parse trailers from file or stdin
trailer: process command line trailer arguments
trailer: read and process config information
trailer: process trailers from input message and arguments
trailer: add data structures and basic functions
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/interpret-trailers.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/builtin/interpret-trailers.c b/builtin/interpret-trailers.c new file mode 100644 index 000000000..46838d24a --- /dev/null +++ b/builtin/interpret-trailers.c @@ -0,0 +1,44 @@ +/* + * Builtin "git interpret-trailers" + * + * Copyright (c) 2013, 2014 Christian Couder <chriscool@tuxfamily.org> + * + */ + +#include "cache.h" +#include "builtin.h" +#include "parse-options.h" +#include "string-list.h" +#include "trailer.h" + +static const char * const git_interpret_trailers_usage[] = { + N_("git interpret-trailers [--trim-empty] [(--trailer <token>[(=|:)<value>])...] [<file>...]"), + NULL +}; + +int cmd_interpret_trailers(int argc, const char **argv, const char *prefix) +{ + int trim_empty = 0; + struct string_list trailers = STRING_LIST_INIT_DUP; + + struct option options[] = { + OPT_BOOL(0, "trim-empty", &trim_empty, N_("trim empty trailers")), + OPT_STRING_LIST(0, "trailer", &trailers, N_("trailer"), + N_("trailer(s) to add")), + OPT_END() + }; + + argc = parse_options(argc, argv, prefix, options, + git_interpret_trailers_usage, 0); + + if (argc) { + int i; + for (i = 0; i < argc; i++) + process_trailers(argv[i], trim_empty, &trailers); + } else + process_trailers(NULL, trim_empty, &trailers); + + string_list_clear(&trailers, 0); + + return 0; +} |