void get_commit_format(const char *arg, struct rev_info *rev) { struct cmt_fmt_map *commit_format; rev->use_terminator = 0; if (!arg || !*arg) { rev->commit_format = CMIT_FMT_DEFAULT; return; } if (starts_with(arg, "format:") || starts_with(arg, "tformat:")) { save_user_format(rev, strchr(arg, ':') + 1, arg[0] == 't'); return; } if (strchr(arg, '%')) { save_user_format(rev, arg, 1); return; } commit_format = find_commit_format(arg); if (!commit_format) die("invalid --pretty format: %s", arg); rev->commit_format = commit_format->format; rev->use_terminator = commit_format->is_tformat; if (commit_format->format == CMIT_FMT_USERFORMAT) { save_user_format(rev, commit_format->user_format, commit_format->is_tformat); } }
void get_commit_format(const char *arg, struct rev_info *rev) { struct cmt_fmt_map *commit_format; rev->use_terminator = 0; if (!arg) { rev->commit_format = CMIT_FMT_DEFAULT; return; } if (skip_prefix(arg, "format:", &arg)) { save_user_format(rev, arg, 0); return; } if (!*arg || skip_prefix(arg, "tformat:", &arg) || strchr(arg, '%')) { save_user_format(rev, arg, 1); return; } commit_format = find_commit_format(arg); if (!commit_format) die("invalid --pretty format: %s", arg); rev->commit_format = commit_format->format; rev->use_terminator = commit_format->is_tformat; rev->expand_tabs_in_log_default = commit_format->expand_tabs_in_log; if (commit_format->format == CMIT_FMT_USERFORMAT) { save_user_format(rev, commit_format->user_format, commit_format->is_tformat); } }
void get_commit_format(const char *arg, struct rev_info *rev) { int i; static struct cmt_fmt_map { const char *n; size_t cmp_len; enum cmit_fmt v; } cmt_fmts[] = { { "raw", 1, CMIT_FMT_RAW }, { "medium", 1, CMIT_FMT_MEDIUM }, { "short", 1, CMIT_FMT_SHORT }, { "email", 1, CMIT_FMT_EMAIL }, { "full", 5, CMIT_FMT_FULL }, { "fuller", 5, CMIT_FMT_FULLER }, { "oneline", 1, CMIT_FMT_ONELINE }, }; rev->use_terminator = 0; if (!arg || !*arg) { rev->commit_format = CMIT_FMT_DEFAULT; return; } if (!prefixcmp(arg, "format:") || !prefixcmp(arg, "tformat:")) { save_user_format(rev, strchr(arg, ':') + 1, arg[0] == 't'); return; } for (i = 0; i < ARRAY_SIZE(cmt_fmts); i++) { if (!strncmp(arg, cmt_fmts[i].n, cmt_fmts[i].cmp_len) && !strncmp(arg, cmt_fmts[i].n, strlen(arg))) { if (cmt_fmts[i].v == CMIT_FMT_ONELINE) rev->use_terminator = 1; rev->commit_format = cmt_fmts[i].v; return; } } if (strchr(arg, '%')) { save_user_format(rev, arg, 1); return; } die("invalid --pretty format: %s", arg); }