4
#include "diff.h"
5
#include "revision.h"
6
7
-static struct cmt_fmt_map {
8
- const char *n;
9
- size_t cmp_len;
10
- enum cmit_fmt v;
11
-} cmt_fmts[] = {
12
- { "raw", 1, CMIT_FMT_RAW },
13
- { "medium", 1, CMIT_FMT_MEDIUM },
14
- { "short", 1, CMIT_FMT_SHORT },
15
- { "email", 1, CMIT_FMT_EMAIL },
16
- { "full", 5, CMIT_FMT_FULL },
17
- { "fuller", 5, CMIT_FMT_FULLER },
18
- { "oneline", 1, CMIT_FMT_ONELINE },
19
- { "format:", 7, CMIT_FMT_USERFORMAT},
20
-};
21
-
7
static char *user_format;
8
24
-enum cmit_fmt get_commit_format(const char *arg)
9
+void get_commit_format(const char *arg, struct rev_info *rev)
10
{
11
int i;
27
-
28
- if (!arg || !*arg)
29
- return CMIT_FMT_DEFAULT;
12
+ static struct cmt_fmt_map {
13
+ const char *n;
14
+ size_t cmp_len;
15
+ enum cmit_fmt v;
16
+ } cmt_fmts[] = {
17
+ { "raw", 1, CMIT_FMT_RAW },
18
+ { "medium", 1, CMIT_FMT_MEDIUM },
19
+ { "short", 1, CMIT_FMT_SHORT },
20
+ { "email", 1, CMIT_FMT_EMAIL },
21
+ { "full", 5, CMIT_FMT_FULL },
22
+ { "fuller", 5, CMIT_FMT_FULLER },
23
+ { "oneline", 1, CMIT_FMT_ONELINE },
24
+ };
25
+
26
+ rev->use_terminator = 0;
27
+ if (!arg || !*arg) {
28
+ rev->commit_format = CMIT_FMT_DEFAULT;
29
+ return;
30
+ }
31
if (*arg == '=')
32
arg++;
32
- if (!prefixcmp(arg, "format:")) {
33
+ if (!prefixcmp(arg, "format:") || !prefixcmp(arg, "tformat:")) {
34
+ const char *cp = strchr(arg, ':') + 1;
35
free(user_format);
34
- user_format = xstrdup(arg + 7);
35
- return CMIT_FMT_USERFORMAT;
36
+ user_format = xstrdup(cp);
37
+ if (arg[0] == 't')
38
+ rev->use_terminator = 1;
39
+ rev->commit_format = CMIT_FMT_USERFORMAT;
40
+ return;
41
}
42
for (i = 0; i < ARRAY_SIZE(cmt_fmts); i++) {
43
if (!strncmp(arg, cmt_fmts[i].n, cmt_fmts[i].cmp_len) &&
39
- !strncmp(arg, cmt_fmts[i].n, strlen(arg)))
40
- return cmt_fmts[i].v;
44
+ !strncmp(arg, cmt_fmts[i].n, strlen(arg))) {
45
+ if (cmt_fmts[i].v == CMIT_FMT_ONELINE)
46
+ rev->use_terminator = 1;
47
+ rev->commit_format = cmt_fmts[i].v;
48
+ return;
49
+ }
50
}
51
52
die("invalid --pretty format: %s", arg);