summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-05-31 19:19:11 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-05-31 19:19:11 (GMT)
commitf67d2e82d6d2fd385d3d20e8d348eaf69dc95041 (patch)
treee1c16bbf610d405e77443f51f121d857d44eba0b /builtin
parent1c9d71944a7a35cdfeb09200b20e261737cdc0b9 (diff)
parent9553d2b26395d9a19bf60875784661090f607f4a (diff)
downloadgit-f67d2e82d6d2fd385d3d20e8d348eaf69dc95041.zip
git-f67d2e82d6d2fd385d3d20e8d348eaf69dc95041.tar.gz
git-f67d2e82d6d2fd385d3d20e8d348eaf69dc95041.tar.bz2
Merge branch 'jk/format-patch-am'
* jk/format-patch-am: format-patch: preserve subject newlines with -k clean up calling conventions for pretty.c functions pretty: add pp_commit_easy function for simple callers mailinfo: always clean up rfc822 header folding t: test subject handling in format-patch / am pipeline Conflicts: builtin/branch.c builtin/log.c commit.h
Diffstat (limited to 'builtin')
-rw-r--r--builtin/branch.c4
-rw-r--r--builtin/checkout.c7
-rw-r--r--builtin/log.c25
-rw-r--r--builtin/mailinfo.c2
-rw-r--r--builtin/merge.c3
-rw-r--r--builtin/rev-list.c3
-rw-r--r--builtin/shortlog.c6
-rw-r--r--builtin/show-branch.c3
8 files changed, 25 insertions, 28 deletions
diff --git a/builtin/branch.c b/builtin/branch.c
index 9cca1b9..d6ab93b 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -399,9 +399,7 @@ static void add_verbose_info(struct strbuf *out, struct ref_item *item,
struct commit *commit = item->commit;
if (commit && !parse_commit(commit)) {
- struct pretty_print_context ctx = {0};
- pretty_print_commit(CMIT_FMT_ONELINE, commit,
- &subject, &ctx);
+ pp_commit_easy(CMIT_FMT_ONELINE, commit, &subject);
sub = subject.buf;
}
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 4761769..28cdc51 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -306,9 +306,8 @@ static void show_local_changes(struct object *head, struct diff_options *opts)
static void describe_detached_head(const char *msg, struct commit *commit)
{
struct strbuf sb = STRBUF_INIT;
- struct pretty_print_context ctx = {0};
parse_commit(commit);
- pretty_print_commit(CMIT_FMT_ONELINE, commit, &sb, &ctx);
+ pp_commit_easy(CMIT_FMT_ONELINE, commit, &sb);
fprintf(stderr, "%s %s... %s\n", msg,
find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV), sb.buf);
strbuf_release(&sb);
@@ -623,14 +622,12 @@ static int clear_commit_marks_from_one_ref(const char *refname,
static void describe_one_orphan(struct strbuf *sb, struct commit *commit)
{
- struct pretty_print_context ctx = { 0 };
-
parse_commit(commit);
strbuf_addstr(sb, " ");
strbuf_addstr(sb,
find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV));
strbuf_addch(sb, ' ');
- pretty_print_commit(CMIT_FMT_ONELINE, commit, sb, &ctx);
+ pp_commit_easy(CMIT_FMT_ONELINE, commit, sb);
strbuf_addch(sb, '\n');
}
diff --git a/builtin/log.c b/builtin/log.c
index 224b167..5c2af59 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -376,9 +376,11 @@ int cmd_whatchanged(int argc, const char **argv, const char *prefix)
static void show_tagger(char *buf, int len, struct rev_info *rev)
{
struct strbuf out = STRBUF_INIT;
+ struct pretty_print_context pp = {0};
- pp_user_info("Tagger", rev->commit_format, &out, buf, rev->date_mode,
- get_log_output_encoding());
+ pp.fmt = rev->commit_format;
+ pp.date_mode = rev->date_mode;
+ pp_user_info(&pp, "Tagger", &out, buf, get_log_output_encoding());
printf("%s", out.buf);
strbuf_release(&out);
}
@@ -762,10 +764,8 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
int quiet)
{
const char *committer;
- const char *subject_start = NULL;
const char *body = "*** SUBJECT HERE ***\n\n*** BLURB HERE ***\n";
const char *msg;
- const char *extra_headers = rev->extra_headers;
struct shortlog log;
struct strbuf sb = STRBUF_INIT;
int i;
@@ -773,6 +773,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
struct diff_options opts;
int need_8bit_cte = 0;
struct commit *commit = NULL;
+ struct pretty_print_context pp = {0};
if (rev->commit_format != CMIT_FMT_EMAIL)
die(_("Cover letter needs email format"));
@@ -804,7 +805,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
free(commit);
}
- log_write_email_headers(rev, head, &subject_start, &extra_headers,
+ log_write_email_headers(rev, head, &pp.subject, &pp.after_subject,
&need_8bit_cte);
for (i = 0; !need_8bit_cte && i < nr; i++)
@@ -812,11 +813,11 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
need_8bit_cte = 1;
msg = body;
- pp_user_info(NULL, CMIT_FMT_EMAIL, &sb, committer, DATE_RFC2822,
- encoding);
- pp_title_line(CMIT_FMT_EMAIL, &msg, &sb, subject_start, extra_headers,
- encoding, need_8bit_cte);
- pp_remainder(CMIT_FMT_EMAIL, &msg, &sb, 0);
+ pp.fmt = CMIT_FMT_EMAIL;
+ pp.date_mode = DATE_RFC2822;
+ pp_user_info(&pp, NULL, &sb, committer, encoding);
+ pp_title_line(&pp, &msg, &sb, encoding, need_8bit_cte);
+ pp_remainder(&pp, &msg, &sb, 0);
printf("%s\n", sb.buf);
strbuf_release(&sb);
@@ -1180,6 +1181,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
die (_("-n and -k are mutually exclusive."));
if (keep_subject && subject_prefix)
die (_("--subject-prefix and -k are mutually exclusive."));
+ rev.preserve_subject = keep_subject;
argc = setup_revisions(argc, argv, &rev, &s_r_opt);
if (argc > 1)
@@ -1410,8 +1412,7 @@ static void print_commit(char sign, struct commit *commit, int verbose,
find_unique_abbrev(commit->object.sha1, abbrev));
} else {
struct strbuf buf = STRBUF_INIT;
- struct pretty_print_context ctx = {0};
- pretty_print_commit(CMIT_FMT_ONELINE, commit, &buf, &ctx);
+ pp_commit_easy(CMIT_FMT_ONELINE, commit, &buf);
printf("%c %s %s\n", sign,
find_unique_abbrev(commit->object.sha1, abbrev),
buf.buf);
diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c
index 71e6262..bfb32b7 100644
--- a/builtin/mailinfo.c
+++ b/builtin/mailinfo.c
@@ -400,7 +400,7 @@ static int read_one_header_line(struct strbuf *line, FILE *in)
break;
if (strbuf_getline(&continuation, in, '\n'))
break;
- continuation.buf[0] = '\n';
+ continuation.buf[0] = ' ';
strbuf_rtrim(&continuation);
strbuf_addbuf(line, &continuation);
}
diff --git a/builtin/merge.c b/builtin/merge.c
index 5a2a1eb..325891e 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -339,13 +339,14 @@ static void squash_message(void)
ctx.abbrev = rev.abbrev;
ctx.date_mode = rev.date_mode;
+ ctx.fmt = rev.commit_format;
strbuf_addstr(&out, "Squashed commit of the following:\n");
while ((commit = get_revision(&rev)) != NULL) {
strbuf_addch(&out, '\n');
strbuf_addf(&out, "commit %s\n",
sha1_to_hex(commit->object.sha1));
- pretty_print_commit(rev.commit_format, commit, &out, &ctx);
+ pretty_print_commit(&ctx, commit, &out);
}
if (write(fd, out.buf, out.len) < 0)
die_errno(_("Writing SQUASH_MSG"));
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 4be6699..56727e8 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -104,7 +104,8 @@ static void show_commit(struct commit *commit, void *data)
struct pretty_print_context ctx = {0};
ctx.abbrev = revs->abbrev;
ctx.date_mode = revs->date_mode;
- pretty_print_commit(revs->commit_format, commit, &buf, &ctx);
+ ctx.fmt = revs->commit_format;
+ pretty_print_commit(&ctx, commit, &buf);
if (revs->graph) {
if (buf.len) {
if (revs->commit_format != CMIT_FMT_ONELINE)
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index b6f4b0e..37f3193 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -138,9 +138,8 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
const char *author = NULL, *buffer;
struct strbuf buf = STRBUF_INIT;
struct strbuf ufbuf = STRBUF_INIT;
- struct pretty_print_context ctx = {0};
- pretty_print_commit(CMIT_FMT_RAW, commit, &buf, &ctx);
+ pp_commit_easy(CMIT_FMT_RAW, commit, &buf);
buffer = buf.buf;
while (*buffer && *buffer != '\n') {
const char *eol = strchr(buffer, '\n');
@@ -159,11 +158,12 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
sha1_to_hex(commit->object.sha1));
if (log->user_format) {
struct pretty_print_context ctx = {0};
+ ctx.fmt = CMIT_FMT_USERFORMAT;
ctx.abbrev = log->abbrev;
ctx.subject = "";
ctx.after_subject = "";
ctx.date_mode = DATE_NORMAL;
- pretty_print_commit(CMIT_FMT_USERFORMAT, commit, &ufbuf, &ctx);
+ pretty_print_commit(&ctx, commit, &ufbuf);
buffer = ufbuf.buf;
} else if (*buffer) {
buffer++;
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 1abcd9e..facc63a 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -283,8 +283,7 @@ static void show_one_commit(struct commit *commit, int no_name)
struct commit_name *name = commit->util;
if (commit->object.parsed) {
- struct pretty_print_context ctx = {0};
- pretty_print_commit(CMIT_FMT_ONELINE, commit, &pretty, &ctx);
+ pp_commit_easy(CMIT_FMT_ONELINE, commit, &pretty);
pretty_str = pretty.buf;
}
if (!prefixcmp(pretty_str, "[PATCH] "))