mirror of
https://github.com/git/git
synced 2024-09-13 05:14:36 +00:00
commit: allow --pretty= args to be abbreviated
Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
63dffdf03d
commit
6cdfd17974
38
commit.c
38
commit.c
|
@ -22,23 +22,33 @@ struct sort_node
|
||||||
|
|
||||||
const char *commit_type = "commit";
|
const char *commit_type = "commit";
|
||||||
|
|
||||||
|
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 },
|
||||||
|
{ "full", 5, CMIT_FMT_FULL },
|
||||||
|
{ "fuller", 5, CMIT_FMT_FULLER },
|
||||||
|
{ "oneline", 1, CMIT_FMT_ONELINE },
|
||||||
|
};
|
||||||
|
|
||||||
enum cmit_fmt get_commit_format(const char *arg)
|
enum cmit_fmt get_commit_format(const char *arg)
|
||||||
{
|
{
|
||||||
if (!*arg)
|
int i;
|
||||||
|
|
||||||
|
if (!arg || !*arg)
|
||||||
return CMIT_FMT_DEFAULT;
|
return CMIT_FMT_DEFAULT;
|
||||||
if (!strcmp(arg, "=raw"))
|
if (*arg == '=')
|
||||||
return CMIT_FMT_RAW;
|
arg++;
|
||||||
if (!strcmp(arg, "=medium"))
|
for (i = 0; i < ARRAY_SIZE(cmt_fmts); i++) {
|
||||||
return CMIT_FMT_MEDIUM;
|
if (!strncmp(arg, cmt_fmts[i].n, cmt_fmts[i].cmp_len))
|
||||||
if (!strcmp(arg, "=short"))
|
return cmt_fmts[i].v;
|
||||||
return CMIT_FMT_SHORT;
|
}
|
||||||
if (!strcmp(arg, "=full"))
|
|
||||||
return CMIT_FMT_FULL;
|
die("invalid --pretty format: %s", arg);
|
||||||
if (!strcmp(arg, "=fuller"))
|
|
||||||
return CMIT_FMT_FULLER;
|
|
||||||
if (!strcmp(arg, "=oneline"))
|
|
||||||
return CMIT_FMT_ONELINE;
|
|
||||||
die("invalid --pretty format");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct commit *check_commit(struct object *obj,
|
static struct commit *check_commit(struct object *obj,
|
||||||
|
|
Loading…
Reference in a new issue