From: Tay Ray Chuan <rctay89@gmail.com>
To: "Git Mailing List" <git@vger.kernel.org>
Cc: "Junio C Hamano" <gitster@pobox.com>
Subject: [PATCH v4] commit::print_summary(): set rev_info.always_show_header to 1
Date: Mon, 7 Jun 2010 13:04:16 +0800 [thread overview]
Message-ID: <1275887056-4788-1-git-send-email-rctay89@gmail.com> (raw)
In-Reply-To: <1275639660-5344-1-git-send-email-rctay89@gmail.com>
This attempts to fix a regression in git-commit, where non-abbreviated
SHA-1s were printed in the summary.
One possible fix would be to set ctx.abbrev to DEFAULT_ABBREV in the
`if` block.
However, we remove this codeblock altogether, and set
rev.always_show_header. This way, we use back the same show_log()
mechanism (instead of format_commit_message()).
Quoting log-tree.c:560:
shown = log_tree_diff(opt, commit, &log);
if (!shown && opt->loginfo && opt->always_show_header) {
log.parent = NULL;
show_log(opt);
shown = 1;
}
This is the only area that always_show_header is checked, so the
setting of this flag should only affect this area.
Also, we now die() if log_tree_commit() returns false; add a comment in
the area, which may be helpful to future git hackers (eg. diagnosisng
trigger of the die()).
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
This is a reworked version of the third patch of the
'tc/commit-abbrev-fix' series; there are no changes to the first and
second patches.
Changes from v3:
- shift note on the die() and our assumption from the commit message into the
code (as a comment), as suggested by Junio.
builtin/commit.c | 22 +++++++++++++---------
t/t7502-commit.sh | 4 ++--
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/builtin/commit.c b/builtin/commit.c
index a4e4966..b0c266c 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1148,7 +1148,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
rev.verbose_header = 1;
rev.show_root_diff = 1;
get_commit_format(format.buf, &rev);
- rev.always_show_header = 0;
+ rev.always_show_header = 1;
rev.diffopt.detect_rename = 1;
rev.diffopt.rename_limit = 100;
rev.diffopt.break_opt = 0;
@@ -1162,14 +1162,18 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
head,
initial_commit ? " (root-commit)" : "");
- if (!log_tree_commit(&rev, commit)) {
- struct pretty_print_context ctx = {0};
- struct strbuf buf = STRBUF_INIT;
- ctx.date_mode = DATE_NORMAL;
- format_commit_message(commit, format.buf + 7, &buf, &ctx);
- printf("%s\n", buf.buf);
- strbuf_release(&buf);
- }
+ /**
+ * Based on the existing underlying codepaths (log_tree_commit(),
+ * log_tree_diff(), log_tree_diff_flush(), to name a few), the die()
+ * should not occur; changes to these codepaths may warrant a revision
+ * of our handling of this situation.
+ *
+ * Tests #1-#3 in t7502 for output formats should aid in detecting such
+ * breakages.
+ */
+ if (!log_tree_commit(&rev, commit))
+ die("unable to print summary");
+
strbuf_release(&format);
}
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index b10541d..08c0247 100755
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
@@ -36,12 +36,12 @@ test_expect_success 'output summary format' '
check_summary_oneline "" "a change"
'
-test_expect_failure 'output summary format for commit with an empty diff' '
+test_expect_success 'output summary format for commit with an empty diff' '
check_summary_oneline "" "empty" "--allow-empty"
'
-test_expect_failure 'output summary format for merges' '
+test_expect_success 'output summary format for merges' '
git checkout -b recursive-base &&
test_commit base file1 &&
--
1.7.1.189.g07419
next prev parent reply other threads:[~2010-06-07 5:04 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-24 9:47 [PATCH 0/3] commit: fix abbrev-sha regression Tay Ray Chuan
2010-05-24 9:47 ` [PATCH 1/3] t7502-commit: add tests for summary output Tay Ray Chuan
2010-05-24 9:47 ` [PATCH 2/3] t7502-commit: add summary output tests for empty and merge commits Tay Ray Chuan
2010-05-24 9:47 ` [PATCH 3/3] commit: show abbreviated sha for commits with empty diffs Tay Ray Chuan
2010-05-26 5:07 ` Junio C Hamano
2010-05-26 5:37 ` Tay Ray Chuan
2010-05-26 5:39 ` Tay Ray Chuan
2010-05-26 5:07 ` [PATCH 2/3] t7502-commit: add summary output tests for empty and merge commits Junio C Hamano
2010-05-26 5:19 ` Tay Ray Chuan
2010-05-27 15:34 ` [PATCH v2 0/3] commit: fix abbrev-sha regression Tay Ray Chuan
2010-05-27 15:34 ` [PATCH v2 1/3] t7502-commit: add tests for summary output Tay Ray Chuan
2010-05-27 15:34 ` [PATCH v2 2/3] t7502-commit: add summary output tests for empty and merge commits Tay Ray Chuan
2010-05-27 15:34 ` [PATCH v2 3/3] commit::print_summary(): set rev_info.always_show_header to 1 Tay Ray Chuan
2010-05-29 1:10 ` Junio C Hamano
2010-05-29 1:41 ` Tay Ray Chuan
2010-06-04 8:21 ` [PATCH v3 " Tay Ray Chuan
2010-06-04 8:34 ` Tay Ray Chuan
2010-06-05 6:44 ` Junio C Hamano
2010-06-07 5:04 ` Tay Ray Chuan [this message]
2010-06-12 14:15 ` [PATCH v6 3/3] commit::print_summary(): don't use format_commit_message() Tay Ray Chuan
2010-05-27 16:58 ` [PATCH v2 0/3] commit: fix abbrev-sha regression Will Palmer
-- strict thread matches above, loose matches on Subject: below --
2010-06-02 23:36 What's cooking in git.git (Jun 2010, #01; Wed, 2) Junio C Hamano
2010-06-03 3:13 ` Tay Ray Chuan
2010-06-03 8:40 ` Michael J Gruber
2010-06-03 18:25 ` mg/rev-parse-option-sifter-deprecation Jonathan Nieder
2010-06-03 13:36 ` [PATCH 1/2] separate quoting and relative path generation Clemens Buchacher
2010-06-03 13:39 ` [PATCH 2/2] ls-files: allow relative pathspec Clemens Buchacher
2010-06-03 22:16 ` [PATCH 1/2] separate quoting and relative path generation Junio C Hamano
2010-06-04 7:44 ` [PATCH] optimize path_relative() Clemens Buchacher
2010-06-04 7:50 ` Clemens Buchacher
2010-06-05 8:04 ` [PATCH] setup: document prefix Clemens Buchacher
2010-06-05 7:37 ` [PATCH v2] optimize path_relative() Clemens Buchacher
2010-06-05 18:07 ` Junio C Hamano
2010-06-03 14:36 ` What's cooking in git.git (Jun 2010, #01; Wed, 2) Thomas Rast
2010-06-03 19:53 ` Eyvind Bernhardsen
2010-06-04 21:18 ` Jonathan Nieder
2010-06-05 18:07 ` Junio C Hamano
2010-06-05 19:32 ` Jonathan Nieder
2010-06-05 23:57 ` Sverre Rabbelier
2010-06-06 4:00 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1275887056-4788-1-git-send-email-rctay89@gmail.com \
--to=rctay89@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).