From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ramkumar Ramachandra Subject: [PATCH v6 1/3] fmt_merge_msg: Change fmt_merge_msg API to accept shortlog_len Date: Wed, 25 Aug 2010 16:18:48 +0530 Message-ID: <1282733330-32334-2-git-send-email-artagnon@gmail.com> References: <1282733330-32334-1-git-send-email-artagnon@gmail.com> Cc: Git Mailing List , Jonathan Nieder To: Junio C Hamano X-From: git-owner@vger.kernel.org Wed Aug 25 12:51:24 2010 Return-path: Envelope-to: gcvg-git-2@lo.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OoDZd-0001Cc-Q3 for gcvg-git-2@lo.gmane.org; Wed, 25 Aug 2010 12:51:18 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752070Ab0HYKvF (ORCPT ); Wed, 25 Aug 2010 06:51:05 -0400 Received: from mail-px0-f174.google.com ([209.85.212.174]:54483 "EHLO mail-px0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751859Ab0HYKvD (ORCPT ); Wed, 25 Aug 2010 06:51:03 -0400 Received: by pxi10 with SMTP id 10so133261pxi.19 for ; Wed, 25 Aug 2010 03:51:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=ZmhNx8b3o4Pru/pSUJ5e/4VaecNTkubvo3vlpSrms4A=; b=EusDAkUpVoHIhmY7T4awWIepQPhlhETZi0XQy3VIYyQBRz2NBI2/+xcTlWuV6tFleC qfSBmOYgSvLwG7z9nl6VNvu9jVJ6dy5duPqzMbNH405v3YJhbR0ypBdycoN6w/hgMtAn VYuNvgOD0GN+ykmSPllc3VtvNJdGoc/fv/8P4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=Pfxg2kFNu/Oi/1JDxxaM9heaZypLIpnby6ugdbwTZpeLSxX+Z6OHjmXM6VsvaO76HW bT8m7vkvKE/RLhRF3jzn4xlUe71apsNCOLo6L7gwY+zAi1Oz+c/hSQgnZIvQ7IHl4gMK 2RdZrHTWc2luoxTQGvtkCi3nKDF8xtP+AFYqM= Received: by 10.114.77.11 with SMTP id z11mr9238303waa.112.1282733462292; Wed, 25 Aug 2010 03:51:02 -0700 (PDT) Received: from localhost.localdomain ([203.110.240.41]) by mx.google.com with ESMTPS id d38sm2037882wam.20.2010.08.25.03.50.57 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 25 Aug 2010 03:51:01 -0700 (PDT) X-Mailer: git-send-email 1.7.2.2.409.gdbb11.dirty In-Reply-To: <1282733330-32334-1-git-send-email-artagnon@gmail.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Give "shortlog_len" parameter to the fmt_merge_msg(), remove its "merge_summary" parameter, and remove fmt_merge_msg_shortlog() function. In the updated API, shortlog_len == 0 means no shortlog is given. The parameter "merge_title" controls if the title of the merge commit is autogenerated (it reads something like "Merge branch ..."), and typically it is set to true when the caller does not give its own message. Signed-off-by: Ramkumar Ramachandra Helped-and-Reviewed-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- builtin.h | 7 ++++--- builtin/fmt-merge-msg.c | 30 ++++++++++++++---------------- builtin/merge.c | 14 ++++++-------- 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/builtin.h b/builtin.h index 9c3d50b..009992e 100644 --- a/builtin.h +++ b/builtin.h @@ -7,6 +7,8 @@ #include "commit.h" #include "notes.h" +#define DEFAULT_MERGE_LOG_LEN 20 + extern const char git_version_string[]; extern const char git_usage_string[]; extern const char git_more_info_string[]; @@ -14,9 +16,8 @@ extern const char git_more_info_string[]; extern void list_common_cmds_help(void); extern const char *help_unknown_cmd(const char *cmd); extern void prune_packed_objects(int); -extern int fmt_merge_msg(int merge_summary, struct strbuf *in, - struct strbuf *out); -extern int fmt_merge_msg_shortlog(struct strbuf *in, struct strbuf *out); +extern int fmt_merge_msg(struct strbuf *in, struct strbuf *out, + int merge_title, int shortlog_len); extern int commit_notes(struct notes_tree *t, const char *msg); struct notes_rewrite_cfg { diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c index e7e12ee..7f06b95 100644 --- a/builtin/fmt-merge-msg.c +++ b/builtin/fmt-merge-msg.c @@ -255,9 +255,9 @@ static void do_fmt_merge_msg_title(struct strbuf *out, strbuf_addf(out, " into %s\n", current_branch); } -static int do_fmt_merge_msg(int merge_title, int merge_summary, - struct strbuf *in, struct strbuf *out) { - int limit = 20, i = 0, pos = 0; +static int do_fmt_merge_msg(int merge_title, struct strbuf *in, + struct strbuf *out, int shortlog_len) { + int i = 0, pos = 0; unsigned char head_sha1[20]; const char *current_branch; @@ -288,7 +288,7 @@ static int do_fmt_merge_msg(int merge_title, int merge_summary, if (merge_title) do_fmt_merge_msg_title(out, current_branch); - if (merge_summary) { + if (shortlog_len) { struct commit *head; struct rev_info rev; @@ -303,17 +303,14 @@ static int do_fmt_merge_msg(int merge_title, int merge_summary, for (i = 0; i < origins.nr; i++) shortlog(origins.items[i].string, origins.items[i].util, - head, &rev, limit, out); + head, &rev, shortlog_len, out); } return 0; } -int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) { - return do_fmt_merge_msg(1, merge_summary, in, out); -} - -int fmt_merge_msg_shortlog(struct strbuf *in, struct strbuf *out) { - return do_fmt_merge_msg(0, 1, in, out); +int fmt_merge_msg(struct strbuf *in, struct strbuf *out, + int merge_title, int shortlog_len) { + return do_fmt_merge_msg(merge_title, in, out, shortlog_len); } int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix) @@ -355,12 +352,13 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix) if (strbuf_read(&input, fileno(in), 0) < 0) die_errno("could not read input file"); - if (message) { + + if (message) strbuf_addstr(&output, message); - ret = fmt_merge_msg_shortlog(&input, &output); - } else { - ret = fmt_merge_msg(merge_summary, &input, &output); - } + ret = fmt_merge_msg(&input, &output, + message ? 0 : 1, + merge_summary ? DEFAULT_MERGE_LOG_LEN : 0); + if (ret) return ret; write_in_full(STDOUT_FILENO, output.buf, output.len); diff --git a/builtin/merge.c b/builtin/merge.c index 017e6d0..1f4d68d 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -1017,14 +1017,12 @@ int cmd_merge(int argc, const char **argv, const char *prefix) for (i = 0; i < argc; i++) merge_name(argv[i], &merge_names); - if (have_message && option_log) - fmt_merge_msg_shortlog(&merge_names, &merge_msg); - else if (!have_message) - fmt_merge_msg(option_log, &merge_names, &merge_msg); - - - if (!(have_message && !option_log) && merge_msg.len) - strbuf_setlen(&merge_msg, merge_msg.len-1); + if (!have_message || option_log) { + fmt_merge_msg(&merge_names, &merge_msg, !have_message, + option_log ? DEFAULT_MERGE_LOG_LEN : 0); + if (merge_msg.len) + strbuf_setlen(&merge_msg, merge_msg.len - 1); + } } if (head_invalid || !argc) -- 1.7.2.2.409.gdbb11.dirty