diff options
author | Nanako Shiraishi <nanako3@lavabit.com> | 2009-02-24 18:59:15 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-02-24 23:53:38 -0800 |
commit | 36407548a2825462a91b456755412a65fd611fc0 (patch) | |
tree | e9932b7d92ae2d995636eb5cfebe528243cde6a2 /pretty.c | |
parent | 3a4c1a5e212357c3df030b6713c75466694c2e77 (diff) | |
download | git-36407548a2825462a91b456755412a65fd611fc0.tar.gz |
Give short-hands to --pretty=tformat:%formatstring
Allow --pretty="%h %s" (and --format="%h %s") as shorthand for an often
used option --pretty=tformat:"%h %s".
Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pretty.c')
-rw-r--r-- | pretty.c | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -10,6 +10,15 @@ static char *user_format; +static void save_user_format(struct rev_info *rev, const char *cp, int is_tformat) +{ + free(user_format); + user_format = xstrdup(cp); + if (is_tformat) + rev->use_terminator = 1; + rev->commit_format = CMIT_FMT_USERFORMAT; +} + void get_commit_format(const char *arg, struct rev_info *rev) { int i; @@ -33,12 +42,7 @@ void get_commit_format(const char *arg, struct rev_info *rev) return; } if (!prefixcmp(arg, "format:") || !prefixcmp(arg, "tformat:")) { - const char *cp = strchr(arg, ':') + 1; - free(user_format); - user_format = xstrdup(cp); - if (arg[0] == 't') - rev->use_terminator = 1; - rev->commit_format = CMIT_FMT_USERFORMAT; + save_user_format(rev, strchr(arg, ':') + 1, arg[0] == 't'); return; } for (i = 0; i < ARRAY_SIZE(cmt_fmts); i++) { @@ -50,6 +54,10 @@ void get_commit_format(const char *arg, struct rev_info *rev) return; } } + if (strchr(arg, '%')) { + save_user_format(rev, arg, 1); + return; + } die("invalid --pretty format: %s", arg); } |