{"thread":{"id":"13316","subject":"[PATCH 2/2] log: print log entry terminator even if the message is empty","startedAt":"2008-04-29T08:32:59Z","lastAt":"2008-04-29T08:33:00Z","messageCount":2,"participants":["Adam Simpkins"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"75512","messageId":"1209457980-19677-1-git-send-email-adam@adamsimpkins.net","threadId":"13316","inReplyTo":null,"subject":"[PATCH 1/2] Remove dead code: show_log() sep argument and diff_options.msg_sep","fromName":"Adam Simpkins","fromEmail":"adam@adamsimpkins.net","sentAt":"2008-04-29T08:32:59Z","receivedAt":"2008-04-29T08:32:59Z","isPatch":true,"sender":{"key":"adam@adamsimpkins.net","avatar":"https://gravatar.com/avatar/d3fd2c0b3e2d2136b56e95726ee03227bee4eb562f627dcd3ebca0623fa05054?d=mp&s=160"},"body":"These variables were made unnecessary by commit\n3969cf7db1a13a78f3b7a36d8c1084bbe0a53459.\n\nSigned-off-by: Adam Simpkins <adam@adamsimpkins.net>\n---\n\nThis is the first of two minor cleanup patches discussed in the thread\n\"entry terminator/separator behavior in show_log()\"\n\n builtin-log.c  |    1 -\n combine-diff.c |    6 +++---\n diff.c         |    1 -\n diff.h         |    1 -\n log-tree.c     |   27 +++++++++------------------\n log-tree.h     |    2 +-\n 6 files changed, 13 insertions(+), 25 deletions(-)\n\ndiff --git a/builtin-log.c b/builtin-log.c\nindex 1670d0b..256bbac 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -770,7 +770,6 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \trev.diff = 1;\n \trev.combine_merges = 0;\n \trev.ignore_merges = 1;\n-\trev.diffopt.msg_sep = \"\";\n \tDIFF_OPT_SET(&rev.diffopt, RECURSIVE);\n \n \trev.subject_prefix = fmt_patch_subject_prefix;\ndiff --git a/combine-diff.c b/combine-diff.c\nindex f1e7a4d..41aaf83 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -798,7 +798,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \t\tint deleted = 0;\n \n \t\tif (rev->loginfo && !rev->no_commit_id)\n-\t\t\tshow_log(rev, opt->msg_sep);\n+\t\t\tshow_log(rev);\n \t\tdump_quoted_path(dense ? \"diff --cc \" : \"diff --combined \",\n \t\t\t\t \"\", elem->path, c_meta, c_reset);\n \t\tprintf(\"%sindex \", c_meta);\n@@ -881,7 +881,7 @@ static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct re\n \t\tinter_name_termination = 0;\n \n \tif (rev->loginfo && !rev->no_commit_id)\n-\t\tshow_log(rev, opt->msg_sep);\n+\t\tshow_log(rev);\n \n \tif (opt->output_format & DIFF_FORMAT_RAW) {\n \t\toffset = strlen(COLONS) - num_parent;\n@@ -962,7 +962,7 @@ void diff_tree_combined(const unsigned char *sha1,\n \t\tpaths = intersect_paths(paths, i, num_parent);\n \n \t\tif (show_log_first && i == 0) {\n-\t\t\tshow_log(rev, opt->msg_sep);\n+\t\t\tshow_log(rev);\n \t\t\tif (rev->verbose_header && opt->output_format)\n \t\t\t\tputchar(opt->line_termination);\n \t\t}\ndiff --git a/diff.c b/diff.c\nindex 3632b55..e35384b 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2220,7 +2220,6 @@ void diff_setup(struct diff_options *options)\n \toptions->rename_limit = -1;\n \toptions->dirstat_percent = 3;\n \toptions->context = 3;\n-\toptions->msg_sep = \"\";\n \n \toptions->change = diff_change;\n \toptions->add_remove = diff_addremove;\ndiff --git a/diff.h b/diff.h\nindex f2c7739..1bd94a4 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -88,7 +88,6 @@ struct diff_options {\n \tint abbrev;\n \tconst char *prefix;\n \tint prefix_length;\n-\tconst char *msg_sep;\n \tconst char *stat_sep;\n \tlong xdl_opts;\n \ndiff --git a/log-tree.c b/log-tree.c\nindex 8f5436b..4c7d7ef 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -208,14 +208,13 @@ void log_write_email_headers(struct rev_info *opt, const char *name,\n \t*extra_headers_p = extra_headers;\n }\n \n-void show_log(struct rev_info *opt, const char *sep)\n+void show_log(struct rev_info *opt)\n {\n \tstruct strbuf msgbuf;\n \tstruct log_info *log = opt->loginfo;\n \tstruct commit *commit = log->commit, *parent = log->parent;\n \tint abbrev = opt->diffopt.abbrev;\n \tint abbrev_commit = opt->abbrev_commit ? opt->abbrev : 40;\n-\tconst char *extra;\n \tconst char *subject = NULL, *extra_headers = opt->extra_headers;\n \tint need_8bit_cte = 0;\n \n@@ -240,17 +239,10 @@ void show_log(struct rev_info *opt, const char *sep)\n \t}\n \n \t/*\n-\t * The \"oneline\" format has several special cases:\n-\t *  - The pretty-printed commit lacks a newline at the end\n-\t *    of the buffer, but we do want to make sure that we\n-\t *    have a newline there. If the separator isn't already\n-\t *    a newline, add an extra one.\n-\t *  - unlike other log messages, the one-line format does\n-\t *    not have an empty line between entries.\n+\t * If use_terminator is set, add a newline at the end of the entry.\n+\t * Otherwise, add a diffopt.line_termination character before all\n+\t * entries but the first.  (IOW, as a separator between entries)\n \t */\n-\textra = \"\";\n-\tif (*sep != '\\n' && opt->use_terminator)\n-\t\textra = \"\\n\";\n \tif (opt->shown_one && !opt->use_terminator)\n \t\tputchar(opt->diffopt.line_termination);\n \topt->shown_one = 1;\n@@ -292,10 +284,8 @@ void show_log(struct rev_info *opt, const char *sep)\n \t\t\tshow_reflog_message(opt->reflog_info,\n \t\t\t\t    opt->commit_format == CMIT_FMT_ONELINE,\n \t\t\t\t    opt->date_mode);\n-\t\t\tif (opt->commit_format == CMIT_FMT_ONELINE) {\n-\t\t\t\tprintf(\"%s\", sep);\n+\t\t\tif (opt->commit_format == CMIT_FMT_ONELINE)\n \t\t\t\treturn;\n-\t\t\t}\n \t\t}\n \t}\n \n@@ -319,7 +309,8 @@ void show_log(struct rev_info *opt, const char *sep)\n \n \tif (msgbuf.len) {\n \t\tfwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);\n-\t\tprintf(\"%s%s\", extra, sep);\n+\t\tif (opt->use_terminator)\n+\t\t\tputchar('\\n');\n \t}\n \tstrbuf_release(&msgbuf);\n }\n@@ -342,7 +333,7 @@ int log_tree_diff_flush(struct rev_info *opt)\n \t\t * an extra newline between the end of log and the\n \t\t * output for readability.\n \t\t */\n-\t\tshow_log(opt, opt->diffopt.msg_sep);\n+\t\tshow_log(opt);\n \t\tif ((opt->diffopt.output_format & ~DIFF_FORMAT_NO_OUTPUT) &&\n \t\t    opt->verbose_header &&\n \t\t    opt->commit_format != CMIT_FMT_ONELINE) {\n@@ -430,7 +421,7 @@ int log_tree_commit(struct rev_info *opt, struct commit *commit)\n \tshown = log_tree_diff(opt, commit, &log);\n \tif (!shown && opt->loginfo && opt->always_show_header) {\n \t\tlog.parent = NULL;\n-\t\tshow_log(opt, \"\");\n+\t\tshow_log(opt);\n \t\tshown = 1;\n \t}\n \topt->loginfo = NULL;\ndiff --git a/log-tree.h b/log-tree.h\nindex 8946ff3..59ba4c4 100644\n--- a/log-tree.h\n+++ b/log-tree.h\n@@ -11,7 +11,7 @@ void init_log_tree_opt(struct rev_info *);\n int log_tree_diff_flush(struct rev_info *);\n int log_tree_commit(struct rev_info *, struct commit *);\n int log_tree_opt_parse(struct rev_info *, const char **, int);\n-void show_log(struct rev_info *opt, const char *sep);\n+void show_log(struct rev_info *opt);\n void show_decorations(struct commit *commit);\n void log_write_email_headers(struct rev_info *opt, const char *name,\n \t\t\t     const char **subject_p,\n-- \n1.5.3.6\n"},{"id":"75511","messageId":"1209457980-19677-2-git-send-email-adam@adamsimpkins.net","threadId":"13316","inReplyTo":"1209457980-19677-1-git-send-email-adam@adamsimpkins.net","subject":"[PATCH 2/2] log: print log entry terminator even if the message is empty","fromName":"Adam Simpkins","fromEmail":"adam@adamsimpkins.net","sentAt":"2008-04-29T08:33:00Z","receivedAt":"2008-04-29T08:33:00Z","isPatch":true,"sender":{"key":"adam@adamsimpkins.net","avatar":"https://gravatar.com/avatar/d3fd2c0b3e2d2136b56e95726ee03227bee4eb562f627dcd3ebca0623fa05054?d=mp&s=160"},"body":"This eliminates a special case in the show_log() function, to help\nsimplify the terminator semantics.  Now show_log() always prints a\nnewline after the log entry when use_terminator is set, even if the log\nmessage is empty.\n\nThis change should only affect the --pretty=tformat output, since that\nwas the only way to trigger this special case.\n\nSigned-off-by: Adam Simpkins <adam@adamsimpkins.net>\n---\n log-tree.c |    8 +++-----\n 1 files changed, 3 insertions(+), 5 deletions(-)\n\ndiff --git a/log-tree.c b/log-tree.c\nindex 4c7d7ef..74b79b5 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -307,11 +307,9 @@ void show_log(struct rev_info *opt)\n \tif (opt->show_log_size)\n \t\tprintf(\"log size %i\\n\", (int)msgbuf.len);\n \n-\tif (msgbuf.len) {\n-\t\tfwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);\n-\t\tif (opt->use_terminator)\n-\t\t\tputchar('\\n');\n-\t}\n+\tfwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);\n+\tif (opt->use_terminator)\n+\t\tputchar('\\n');\n \tstrbuf_release(&msgbuf);\n }\n \n-- \n1.5.3.6\n"}]}