Subject: [PATCH v3 0/8] Correct internal working and output encoding

From: Doan Tran Cong Danh <[email-masked]>
Date: Wed, 6 Nov 2019 16:19:58 +0700

The series is shifting from fixing test that failed on musl based Linux to
correct the internal working encoding and output encoding of git-am
git-cherry-pick git-rebase and git-revert.

Doan Tran Cong Danh (8):
  t0028: eliminate non-standard usage of printf
  configure.ac: define ICONV_OMITS_BOM if necessary
  t3900: demonstrate git-rebase problem with multi encoding
  sequencer: reencode to utf-8 before arrange rebase's todo list
  sequencer: reencode revert/cherry-pick's todo list
  sequencer: reencode squashing commit's message
  sequencer: reencode old merge-commit message
  sequencer: reencode commit message for am/rebase --show-current-patch

 configure.ac                     | 49 ++++++++++++++++++++++++++++++++
 sequencer.c                      | 21 +++++++++-----
 t/t0028-working-tree-encoding.sh |  4 +--
 t/t3900-i18n-commit.sh           | 42 +++++++++++++++++++++++++++
 4 files changed, 107 insertions(+), 9 deletions(-)

Range-diff against v2:
1:  8b30028425 ! 1:  b3d6c4e720 t0028: eliminate non-standard usage of printf
    @@ Commit message
            one, two, or three-digit octal number, shall be written as a byte
            with the numeric value specified by the octal number.
     
    -    printf '\xfe\xff' in an extension of some shell.
    +    printf '\xfe\xff' is an extension of some shell.
         Dash, a popular yet simple shell, do not implement this extension.
     
         This wasn't caught by most people running the tests, even though
2:  7c2c6f0603 ! 2:  f07566c60c configure.ac: define ICONV_OMITS_BOM if necessary
    @@ Commit message
     
         However, typing the flag all the time is cumbersome and error-prone.
     
    -    Add a checking into configure script to detect this flag automatically.
    +    Add a check into configure script to detect this flag automatically.
     
         Signed-off-by: Doan Tran Cong Danh <[email-masked]>
     
-:  ---------- > 3:  662e5bd545 t3900: demonstrate git-rebase problem with multi encoding
3:  b7927b2723 ! 4:  6a51fdd29c sequencer: reencode to utf-8 before arrange rebase's todo list
    @@ Commit message
         first, then format it and convert the message to the actual output
         encoding on git commit --squash.
     
    -    Thus, t3900 is failing on Linux with musl libc.
    -
    -    This problem wasn't specific to musl libc. On Linux with glibc, this
    -    problem can be observed by:
    -
    -    for encoding in utf-8 iso-8859-1; do
    -            # commit using the encoding
    -            echo $encoding >file && git add file
    -            echo "éñcödèd with $encoding" | iconv -f utf-8 -t $encoding |
    -              git -c i18n.commitEncoding=$encoding commit -F -
    -            # and then fixup without it
    -            echo "$encoding fixed" >file && git add file
    -            git commit --fixup HEAD
    -    done
    -    git rebase -i --autosquash --root
    +    Thus, t3900::test_commit_autosquash_flags is failing on musl libc.
     
         Reencode to utf-8 before arranging rebase's todo list.
    +    By doing this, we also remove a breakage introduced in the previous
    +    commit.
     
         Signed-off-by: Doan Tran Cong Danh <[email-masked]>
     
    @@ sequencer.c: int todo_list_rearrange_squash(struct todo_list *todo_list)
      		find_commit_subject(commit_buffer, &subject);
      		format_subject(&buf, subject, " ");
      		subject = subjects[i] = strbuf_detach(&buf, &subject_len);
    +
    + ## t/t3900-i18n-commit.sh ##
    +@@ t/t3900-i18n-commit.sh: test_commit_autosquash_multi_encoding () {
    + 	old=$2
    + 	new=$3
    + 	msg=$4
    +-	test_expect_failure "commit --$flag into $old from $new" '
    ++	test_expect_success "commit --$flag into $old from $new" '
    + 		git checkout -b '$flag-$old-$new' C0 &&
    + 		git config i18n.commitencoding '$old' &&
    + 		echo '$old' >>F &&
-:  ---------- > 5:  d382e35e4e sequencer: reencode revert/cherry-pick's todo list
-:  ---------- > 6:  340902eb67 sequencer: reencode squashing commit's message
-:  ---------- > 7:  7f0df0f685 sequencer: reencode old merge-commit message
-:  ---------- > 8:  69ec40bb1d sequencer: reencode commit message for am/rebase --show-current-patch
-- 
2.24.0.4.g6a51fdd29c