diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-01-29 03:10:13 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-01-29 03:10:13 +0300 |
commit | 4f3aa9da7022c11c5db51b5b9063c0215863aba1 (patch) | |
tree | 10d42e9fc0874205bacf6c07ad8d7a070296b497 /builtin | |
parent | 4b16573ce99c46e8c5b4950c44b70f1584b8dca9 (diff) | |
parent | e1f898639e906158fec26bdf3111d6f623288fa1 (diff) |
Merge branch 'tk/interpret-trailers-in-place'
"interpret-trailers" has been taught to optionally update a file in
place, instead of always writing the result to the standard output.
* tk/interpret-trailers-in-place:
interpret-trailers: add option for in-place editing
trailer: allow to write to files other than stdout
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/interpret-trailers.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/builtin/interpret-trailers.c b/builtin/interpret-trailers.c index 46838d24a9..b99ae4be88 100644 --- a/builtin/interpret-trailers.c +++ b/builtin/interpret-trailers.c @@ -12,16 +12,18 @@ #include "trailer.h" static const char * const git_interpret_trailers_usage[] = { - N_("git interpret-trailers [--trim-empty] [(--trailer <token>[(=|:)<value>])...] [<file>...]"), + N_("git interpret-trailers [--in-place] [--trim-empty] [(--trailer <token>[(=|:)<value>])...] [<file>...]"), NULL }; int cmd_interpret_trailers(int argc, const char **argv, const char *prefix) { + int in_place = 0; int trim_empty = 0; struct string_list trailers = STRING_LIST_INIT_DUP; struct option options[] = { + OPT_BOOL(0, "in-place", &in_place, N_("edit files in place")), OPT_BOOL(0, "trim-empty", &trim_empty, N_("trim empty trailers")), OPT_STRING_LIST(0, "trailer", &trailers, N_("trailer"), N_("trailer(s) to add")), @@ -34,9 +36,12 @@ int cmd_interpret_trailers(int argc, const char **argv, const char *prefix) if (argc) { int i; for (i = 0; i < argc; i++) - process_trailers(argv[i], trim_empty, &trailers); - } else - process_trailers(NULL, trim_empty, &trailers); + process_trailers(argv[i], in_place, trim_empty, &trailers); + } else { + if (in_place) + die(_("no input file given for in-place editing")); + process_trailers(NULL, in_place, trim_empty, &trailers); + } string_list_clear(&trailers, 0); |