Skip to content

Commit

Permalink
Merge branch 'as/log-output-encoding-in-user-format'
Browse files Browse the repository at this point in the history
"log --format=" did not honor i18n.logoutputencoding configuration
and this attempts to fix it.

* as/log-output-encoding-in-user-format:
  t4205 (log-pretty-formats): avoid using `sed`
  t6006 (rev-list-format): add tests for "%b" and "%s" for the case i18n.commitEncoding is not set
  t4205, t6006, t7102: make functions better readable
  t4205 (log-pretty-formats): revert back single quotes
  t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1
  t4205: replace .\+ with ..* in sed commands
  pretty: --format output should honor logOutputEncoding
  pretty: Add failing tests: --format output should honor logOutputEncoding
  t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
  t7102 (reset): don't hardcode SHA-1 in expected outputs
  t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
  • Loading branch information
Junio C Hamano committed Jul 12, 2013
2 parents dacd2bc + 37eb772 commit 8a64822
Show file tree
Hide file tree
Showing 9 changed files with 265 additions and 136 deletions.
5 changes: 4 additions & 1 deletion builtin/reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,12 @@ static int reset_index(const unsigned char *sha1, int reset_type, int quiet)
static void print_new_head_line(struct commit *commit)
{
const char *hex, *body;
char *msg;

hex = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);
printf(_("HEAD is now at %s"), hex);
body = strstr(commit->buffer, "\n\n");
msg = logmsg_reencode(commit, NULL, get_log_output_encoding());
body = strstr(msg, "\n\n");
if (body) {
const char *eol;
size_t len;
Expand All @@ -107,6 +109,7 @@ static void print_new_head_line(struct commit *commit)
}
else
printf("\n");
logmsg_free(msg, commit);
}

static void update_index_from_diff(struct diff_queue_struct *q,
Expand Down
1 change: 1 addition & 0 deletions builtin/rev-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ static void show_commit(struct commit *commit, void *data)
ctx.date_mode = revs->date_mode;
ctx.date_mode_explicit = revs->date_mode_explicit;
ctx.fmt = revs->commit_format;
ctx.output_encoding = get_log_output_encoding();
pretty_print_commit(&ctx, commit, &buf);
if (revs->graph) {
if (buf.len) {
Expand Down
1 change: 1 addition & 0 deletions builtin/shortlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
ctx.subject = "";
ctx.after_subject = "";
ctx.date_mode = DATE_NORMAL;
ctx.output_encoding = get_log_output_encoding();
pretty_print_commit(&ctx, commit, &ufbuf);
buffer = ufbuf.buf;
} else if (*buffer) {
Expand Down
1 change: 1 addition & 0 deletions log-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ void show_log(struct rev_info *opt)
ctx.fmt = opt->commit_format;
ctx.mailmap = opt->mailmap;
ctx.color = opt->diffopt.use_color;
ctx.output_encoding = get_log_output_encoding();
pretty_print_commit(&ctx, commit, &msgbuf);

if (opt->add_signoff)
Expand Down
1 change: 1 addition & 0 deletions submodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,
while ((commit = get_revision(rev))) {
struct pretty_print_context ctx = {0};
ctx.date_mode = rev->date_mode;
ctx.output_encoding = get_log_output_encoding();
strbuf_setlen(&sb, 0);
strbuf_addstr(&sb, line_prefix);
if (commit->object.flags & SYMMETRIC_LEFT) {
Expand Down
25 changes: 15 additions & 10 deletions t/t4041-diff-submodule-option.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh
#
# Copyright (c) 2009 Jens Lehmann, based on t7401 by Ping Yin
# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
#

test_description='Support for verbose submodule differences in git diff
Expand All @@ -10,6 +11,9 @@ This test tries to verify the sanity of the --submodule option of git diff.

. ./test-lib.sh

# String "added" in German (translated with Google Translate), encoded in UTF-8,
# used in sample commit log messages in add_file() function below.
added=$(printf "hinzugef\303\274gt")
add_file () {
(
cd "$1" &&
Expand All @@ -19,7 +23,8 @@ add_file () {
echo "$name" >"$name" &&
git add "$name" &&
test_tick &&
git commit -m "Add $name" || exit
msg_added_iso88591=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t iso8859-1) &&
git -c 'i18n.commitEncoding=iso8859-1' commit -m "$msg_added_iso88591"
done >/dev/null &&
git rev-parse --short --verify HEAD
)
Expand Down Expand Up @@ -93,7 +98,7 @@ test_expect_success 'modified submodule(forward)' '
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head1..$head2:
> Add foo3
> Add foo3 ($added foo3)
EOF
test_cmp expected actual
'
Expand All @@ -102,7 +107,7 @@ test_expect_success 'modified submodule(forward)' '
git diff --submodule=log >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head1..$head2:
> Add foo3
> Add foo3 ($added foo3)
EOF
test_cmp expected actual
'
Expand All @@ -111,7 +116,7 @@ test_expect_success 'modified submodule(forward) --submodule' '
git diff --submodule >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head1..$head2:
> Add foo3
> Add foo3 ($added foo3)
EOF
test_cmp expected actual
'
Expand Down Expand Up @@ -142,8 +147,8 @@ test_expect_success 'modified submodule(backward)' '
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head2..$head3 (rewind):
< Add foo3
< Add foo2
< Add foo3 ($added foo3)
< Add foo2 ($added foo2)
EOF
test_cmp expected actual
'
Expand All @@ -153,10 +158,10 @@ test_expect_success 'modified submodule(backward and forward)' '
git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF &&
Submodule sm1 $head2...$head4:
> Add foo5
> Add foo4
< Add foo3
< Add foo2
> Add foo5 ($added foo5)
> Add foo4 ($added foo4)
< Add foo3 ($added foo3)
< Add foo2 ($added foo2)
EOF
test_cmp expected actual
'
Expand Down
Loading

0 comments on commit 8a64822

Please sign in to comment.