builtin / interpret-trailers.con commit Post 2.3 cycle (batch #1) (18d0fec)
   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
  14static const char * const git_interpret_trailers_usage[] = {
  15        N_("git interpret-trailers [--trim-empty] [(--trailer <token>[(=|:)<value>])...] [<file>...]"),
  16        NULL
  17};
  18
  19int cmd_interpret_trailers(int argc, const char **argv, const char *prefix)
  20{
  21        int trim_empty = 0;
  22        struct string_list trailers = STRING_LIST_INIT_DUP;
  23
  24        struct option options[] = {
  25                OPT_BOOL(0, "trim-empty", &trim_empty, N_("trim empty trailers")),
  26                OPT_STRING_LIST(0, "trailer", &trailers, N_("trailer"),
  27                                N_("trailer(s) to add")),
  28                OPT_END()
  29        };
  30
  31        argc = parse_options(argc, argv, prefix, options,
  32                             git_interpret_trailers_usage, 0);
  33
  34        if (argc) {
  35                int i;
  36                for (i = 0; i < argc; i++)
  37                        process_trailers(argv[i], trim_empty, &trailers);
  38        } else
  39                process_trailers(NULL, trim_empty, &trailers);
  40
  41        string_list_clear(&trailers, 0);
  42
  43        return 0;
  44}