aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/log.c1
-rw-r--r--commit.h1
-rw-r--r--log-tree.c1
-rw-r--r--pretty.c3
-rw-r--r--revision.h3
-rwxr-xr-xt/t4152-am-subjects.sh2
6 files changed, 8 insertions, 3 deletions
diff --git a/builtin/log.c b/builtin/log.c
index 8d842cbca..0e46e5ae9 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1131,6 +1131,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)
diff --git a/commit.h b/commit.h
index 2935740a8..e985dcc6e 100644
--- a/commit.h
+++ b/commit.h
@@ -74,6 +74,7 @@ struct pretty_print_context
int abbrev;
const char *subject;
const char *after_subject;
+ int preserve_subject;
enum date_mode date_mode;
int need_8bit_cte;
int show_notes;
diff --git a/log-tree.c b/log-tree.c
index 0d8cc7af2..0c4178935 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -504,6 +504,7 @@ void show_log(struct rev_info *opt)
ctx.date_mode = opt->date_mode;
ctx.abbrev = opt->diffopt.abbrev;
ctx.after_subject = extra_headers;
+ ctx.preserve_subject = opt->preserve_subject;
ctx.reflog_info = opt->reflog_info;
ctx.fmt = opt->commit_format;
pretty_print_commit(&ctx, commit, &msgbuf);
diff --git a/pretty.c b/pretty.c
index 1bb7e075e..193bafd83 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1131,7 +1131,8 @@ void pp_title_line(const struct pretty_print_context *pp,
struct strbuf title;
strbuf_init(&title, 80);
- *msg_p = format_subject(&title, *msg_p, " ");
+ *msg_p = format_subject(&title, *msg_p,
+ pp->preserve_subject ? "\n" : " ");
strbuf_grow(sb, title.len + 1024);
if (pp->subject) {
diff --git a/revision.h b/revision.h
index 05659c64a..f8ddd83e7 100644
--- a/revision.h
+++ b/revision.h
@@ -90,7 +90,8 @@ struct rev_info {
abbrev_commit:1,
use_terminator:1,
missing_newline:1,
- date_mode_explicit:1;
+ date_mode_explicit:1,
+ preserve_subject:1;
unsigned int disable_stdin:1;
enum date_mode date_mode;
diff --git a/t/t4152-am-subjects.sh b/t/t4152-am-subjects.sh
index 37e5c0361..4c68245ac 100755
--- a/t/t4152-am-subjects.sh
+++ b/t/t4152-am-subjects.sh
@@ -70,7 +70,7 @@ test_expect_success 'multiline subject unwrapped (format-patch -k | am)' '
check_subject multiline-k
'
echo "$MULTILINE_SUBJECT" >expect
-test_expect_failure 'multiline subject preserved (format-patch -k | am -k)' '
+test_expect_success 'multiline subject preserved (format-patch -k | am -k)' '
check_subject multiline-k -k
'