--- builtin-cat-file.c | 6 +++++- builtin-commit-tree.c | 9 ++++++--- git-rebase.sh | 1 + log-tree.c | 4 +++- refs.c | 11 ++++++++--- t/t-utf-msg.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 66 insertions(+), 8 deletions(-) create mode 100755 t/t-utf-msg.sh diff --git a/builtin-cat-file.c b/builtin-cat-file.c index 6c16bfa..ff275bf 100644 --- a/builtin-cat-file.c +++ b/builtin-cat-file.c @@ -145,6 +145,10 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix) if (!buf) die("git-cat-file %s: bad file", argv[2]); - write_or_die(1, buf, size); + size_t localsize = locallen(buf,size); + char *localbuf = xcalloc(localsize+1,1); + localcpy(localbuf, buf, size+1); + write_or_die(1, localbuf, localsize); + free(localbuf); return 0; } diff --git a/builtin-commit-tree.c b/builtin-commit-tree.c index e2e690a..8d87ec7 100644 --- a/builtin-commit-tree.c +++ b/builtin-commit-tree.c @@ -23,16 +23,19 @@ static void init_buffer(char **bufp, unsigned int *sizep) static void add_buffer(char **bufp, unsigned int *sizep, const char *fmt, ...) { char one_line[2048]; + char one_line_utf[2048]; va_list args; - int len; + int len,len_utf; unsigned long alloc, size, newsize; char *buf; va_start(args, fmt); len = vsnprintf(one_line, sizeof(one_line), fmt, args); va_end(args); + utfcpy(one_line_utf, one_line, len + 1); + len_utf = strlen(one_line_utf); size = *sizep; - newsize = size + len; + newsize = size + len_utf; alloc = (size + 32767) & ~32767; buf = *bufp; if (newsize > alloc) { @@ -41,7 +44,7 @@ static void add_buffer(char **bufp, unsigned int *sizep, const char *fmt, ...) *bufp = buf; } *sizep = newsize; - memcpy(buf + size, one_line, len); + memcpy(buf + size, one_line_utf, len_utf); } static void check_valid(unsigned char *sha1, const char *expect) diff --git a/git-rebase.sh b/git-rebase.sh index 546fa44..939ac40 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -296,6 +296,7 @@ fi if test -z "$do_merge" then + LC_CTYPE=sv_SE.UTF-8 \ git-format-patch -k --stdout --full-index --ignore-if-in-upstream "$upstream"..ORIG_HEAD | git am --binary -3 -k --resolvemsg="$RESOLVEMSG" \ --reflog-action=rebase diff --git a/log-tree.c b/log-tree.c index fbe1399..7c2564d 100644 --- a/log-tree.c +++ b/log-tree.c @@ -104,6 +104,7 @@ static int append_signoff(char *buf, int buf_sz, int at, const char *signoff) void show_log(struct rev_info *opt, const char *sep) { static char this_header[16384]; + static char this_header_local[16384]; struct log_info *log = opt->loginfo; struct commit *commit = log->commit, *parent = log->parent; int abbrev = opt->diffopt.abbrev; @@ -217,7 +218,8 @@ void show_log(struct rev_info *opt, const char *sep) if (opt->add_signoff) len = append_signoff(this_header, sizeof(this_header), len, opt->add_signoff); - printf("%s%s%s", this_header, extra, sep); + localcpy(this_header_local, this_header, len+1); + printf("%s%s%s", this_header_local, extra, sep); } int log_tree_diff_flush(struct rev_info *opt) diff --git a/refs.c b/refs.c index 98327d7..cfe2704 100644 --- a/refs.c +++ b/refs.c @@ -363,8 +363,9 @@ static int log_ref_write(struct ref_lock *lock, const unsigned char *sha1, const char *msg) { int logfd, written, oflags = O_APPEND | O_WRONLY; - unsigned maxlen, len; + unsigned maxlen, len, len_utf; char *logrec; + char *logrec_utf; const char *committer; if (log_all_ref_updates) { @@ -400,10 +401,14 @@ static int log_ref_write(struct ref_lock *lock, sha1_to_hex(sha1), committer); } - written = len <= maxlen ? write(logfd, logrec, len) : -1; + logrec_utf = xmalloc(len*6); + utfcpy(logrec_utf, logrec, len + 1); + len_utf = strlen(logrec_utf); + written = len_utf <= maxlen ? write(logfd, logrec_utf, len_utf) : -1; free(logrec); + free(logrec_utf); close(logfd); - if (written != len) + if (written != len_utf) return error("Unable to append to %s", lock->log_file); return 0; } diff --git a/t/t-utf-msg.sh b/t/t-utf-msg.sh new file mode 100755 index 0000000..727d497 --- /dev/null +++ b/t/t-utf-msg.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +test_description='Test charset management. + +This assumes normal tests works fine +and concentrates commit messages and other +descriptive data.' + +. ./test-lib.sh + +export GIT_AUTHOR_NAME='Pär Nördsson' +export GIT_COMMITTER_NAME='Pär Nördsson' +export GIT_AUTHOR_DATE='Thu Sep 14 22:54:30 2006 +0000' +export GIT_COMMITTER_DATE='Thu Sep 14 22:54:30 2006 +0000' + +test_expect_success \ + 'add simple text file' \ + 'echo hej >aland.txt && + git-add aland.txt && + git-commit -a -m "Ändrad" && + echo test $(git-ls-files) = "aland.txt\"" && + LC_CTYPE=sv_SE.UTF-8 echo test $(git-ls-files) = "aland.txt\"" + ' + +cat >>expected <<EOF +commit 6905219c78beda5d5efd2a5fe4fbe0a8757bb355 +Author: Pär Nördsson <author@xxxxxxxxxxx> +Date: Thu Sep 14 22:54:30 2006 +0000 + + Ändrad +EOF + +test_expect_success \ + 'log' \ + ' + git log >actual && + diff -u actual expected + ' + +# todo: git-cat-file commit xxxxxxxxxxxxx + +test_done + -- 1.6.3.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html