summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cee9f2b)
raw | patch | inline | side by side (parent: cee9f2b)
author | Tay Ray Chuan <rctay89@gmail.com> | |
Sat, 12 Jun 2010 14:15:39 +0000 (22:15 +0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 13 Jun 2010 16:38:43 +0000 (09:38 -0700) |
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, where format_commit_message() is used.
Instead, we do away with the format_commit_message() codeblock
altogether, replacing it with a re-run of log_tree_commit().
We re-run log_tree_commit() with rev.always_show_header set, to force
the invocation of show_log(). The effect of this flag can be seen from
this excerpt from log-tree.c:560, the only area that
rev.always_show_header is checked:
shown = log_tree_diff(opt, commit, &log);
if (!shown && opt->loginfo && opt->always_show_header) {
log.parent = NULL;
show_log(opt);
shown = 1;
}
We also set rev.use_terminator, so that a newline is appended at the end
of the log message. Note that callers in builtin/log.c that also set
rev.always_show_header don't have to set rev.use_terminator, but still
get a newline, because they are wrapped in a pager.
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
SHA-1s were printed in the summary.
One possible fix would be to set ctx.abbrev to DEFAULT_ABBREV in the
`if` block, where format_commit_message() is used.
Instead, we do away with the format_commit_message() codeblock
altogether, replacing it with a re-run of log_tree_commit().
We re-run log_tree_commit() with rev.always_show_header set, to force
the invocation of show_log(). The effect of this flag can be seen from
this excerpt from log-tree.c:560, the only area that
rev.always_show_header is checked:
shown = log_tree_diff(opt, commit, &log);
if (!shown && opt->loginfo && opt->always_show_header) {
log.parent = NULL;
show_log(opt);
shown = 1;
}
We also set rev.use_terminator, so that a newline is appended at the end
of the log message. Note that callers in builtin/log.c that also set
rev.always_show_header don't have to set rev.use_terminator, but still
get a newline, because they are wrapped in a pager.
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-commit.c | patch | blob | history | |
t/t7502-commit.sh | patch | blob | history |
diff --git a/builtin-commit.c b/builtin-commit.c
index f4c73442cfba9483a826dcfbf68f5466d43e8351..7b7a51a168c28a4679138e295d4f8f12f651fbd6 100644 (file)
--- a/builtin-commit.c
+++ b/builtin-commit.c
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);
+ rev.always_show_header = 1;
+ rev.use_terminator = 1;
+ log_tree_commit(&rev, commit);
}
+
strbuf_release(&format);
}
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index b10541d4d31030f743293df14e37eac0b677248e..08c0247ac30594cb1a672310e679fd3d8c3a95ff 100755 (executable)
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
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 &&