trailer: add interpret-trailers command
This patch adds the "git interpret-trailers" command. This command uses the previously added process_trailers() function in trailer.c. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
Oct 13, 2014 at 20:16 UTC
6634f05454662b62e1f34766d3684b99fb53ad66
5 files changed
+48
.gitignore
+1
@@ -74,6 +74,7 @@
74
/git-index-pack
75
/git-init
76
/git-init-db
77
+/git-interpret-trailers
78
/git-instaweb
79
/git-log
80
/git-ls-files
Makefile
+1
@@ -828,6 +828,7 @@ BUILTIN_OBJS += builtin/hash-object.o
828
BUILTIN_OBJS += builtin/help.o
829
BUILTIN_OBJS += builtin/index-pack.o
830
BUILTIN_OBJS += builtin/init-db.o
831
+BUILTIN_OBJS += builtin/interpret-trailers.o
832
BUILTIN_OBJS += builtin/log.o
833
BUILTIN_OBJS += builtin/ls-files.o
834
BUILTIN_OBJS += builtin/ls-remote.o
builtin.h
+1
@@ -73,6 +73,7 @@ extern int cmd_hash_object(int argc, const char **argv, const char *prefix);
73
extern int cmd_help(int argc, const char **argv, const char *prefix);
74
extern int cmd_index_pack(int argc, const char **argv, const char *prefix);
75
extern int cmd_init_db(int argc, const char **argv, const char *prefix);
76
+extern int cmd_interpret_trailers(int argc, const char **argv, const char *prefix);
77
extern int cmd_log(int argc, const char **argv, const char *prefix);
78
extern int cmd_log_reflog(int argc, const char **argv, const char *prefix);
79
extern int cmd_ls_files(int argc, const char **argv, const char *prefix);
builtin/interpret-trailers.c
new
+44
@@ -0,0 +1,44 @@
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[] = {
15
+ N_("git interpret-trailers [--trim-empty] [(--trailer <token>[(=|:)<value>])...] [<file>...]"),
16
+ NULL
17
+};
18
+
19
+int 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
+}
git.c
+1
@@ -418,6 +418,7 @@ static struct cmd_struct commands[] = {
418
{ "index-pack", cmd_index_pack, RUN_SETUP_GENTLY },
419
{ "init", cmd_init_db, NO_SETUP },
420
{ "init-db", cmd_init_db, NO_SETUP },
421
+ { "interpret-trailers", cmd_interpret_trailers, RUN_SETUP },
422
{ "log", cmd_log, RUN_SETUP },
423
{ "ls-files", cmd_ls_files, RUN_SETUP },
424
{ "ls-remote", cmd_ls_remote, RUN_SETUP_GENTLY },