aboutsummaryrefslogtreecommitdiff
path: root/pretty.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-03-05 15:41:43 -0800
committerJunio C Hamano <gitster@pobox.com>2009-03-05 15:41:43 -0800
commit458eaf5bf895c2df8e0ef81a4c9606d179082e68 (patch)
tree650130c954c3e7fc5a123106b845b9813d1ed1c3 /pretty.c
parent3535dbb3d10cb2782dfbb77c07f2f7d9c44bd41f (diff)
parent72de29c24f50dccc5f045a7756bb0b47e34a7a8e (diff)
downloadgit-458eaf5bf895c2df8e0ef81a4c9606d179082e68.tar.gz
git-458eaf5bf895c2df8e0ef81a4c9606d179082e68.tar.xz
Merge branch 'ns/pretty-format'
* ns/pretty-format: bash completion: add --format= and --oneline options for "git log" Add tests for git log --pretty, --format and --oneline. Add --oneline that is a synonym to "--pretty=oneline --abbrev-commit" Give short-hands to --pretty=tformat:%formatstring Add --format that is a synonym to --pretty
Diffstat (limited to 'pretty.c')
-rw-r--r--pretty.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/pretty.c b/pretty.c
index d64212d4c..f49929479 100644
--- a/pretty.c
+++ b/pretty.c
@@ -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);
}