Refactor pretty_print_commit arguments into a struct
pretty_print_commit() has a bunch of rarely-used arguments, and introducing more of them requires yet another update of all the call sites. Refactor most of them into a struct to make future extensions easier. The ones that stay "plain" arguments were chosen on the grounds that all callers put real arguments there, whereas some callers have 0/NULL for all arguments that were factored into the struct. We declare the struct 'const' to ensure none of the callers are bitten by the changed (no longer call-by-value) semantics. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
9ecb2a7f49
commit
dd2e794a21
@ -684,8 +684,10 @@ static const char *find_author_by_nickname(const char *name)
|
||||
prepare_revision_walk(&revs);
|
||||
commit = get_revision(&revs);
|
||||
if (commit) {
|
||||
struct pretty_print_context ctx = {0};
|
||||
ctx.date_mode = DATE_NORMAL;
|
||||
strbuf_release(&buf);
|
||||
format_commit_message(commit, "%an <%ae>", &buf, DATE_NORMAL);
|
||||
format_commit_message(commit, "%an <%ae>", &buf, &ctx);
|
||||
return strbuf_detach(&buf, NULL);
|
||||
}
|
||||
die("No existing author found with '%s'", name);
|
||||
@ -942,8 +944,10 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
|
||||
initial_commit ? " (root-commit)" : "");
|
||||
|
||||
if (!log_tree_commit(&rev, commit)) {
|
||||
struct pretty_print_context ctx = {0};
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
format_commit_message(commit, format + 7, &buf, DATE_NORMAL);
|
||||
ctx.date_mode = DATE_NORMAL;
|
||||
format_commit_message(commit, format + 7, &buf, &ctx);
|
||||
printf("%s\n", buf.buf);
|
||||
strbuf_release(&buf);
|
||||
}
|
||||
|
Reference in New Issue
Block a user