Consistent message encoding while reusing log from an existing commit.
The following commands can reuse log message from an existing commit while creating a new commit: git-cherry-pick git-rebase (both with and without --merge) git-commit (-c and -C) When the original commit was made in a different encoding from the current i18n.commitencoding, "cat-file commit" would give a string that is inconsistent with what the resulting commit will claim to be in. Replace them with "git show -s --encoding". "git-rebase" without --merge is "git format-patch" piped to "git am" in essence, and has been taken care of before this commit. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Jan 13, 2007 at 13:33 UTC
5ac2715f2eaacc7c76ac03680a0d7a16a30946f2
2 files changed
+15
-6
git-commit.sh
+5
-2
@@ -435,7 +435,9 @@ then
435
fi
436
elif test "$use_commit" != ""
437
then
438
- git-cat-file commit "$use_commit" | sed -e '1,/^$/d'
438
+ encoding=$(git repo-config i18n.commitencoding || echo UTF-8)
439
+ git show -s --pretty=raw --encoding="$encoding" "$use_commit" |
440
+ sed -e '1,/^$/d' -e 's/^ //'
441
elif test -f "$GIT_DIR/MERGE_MSG"
442
then
443
cat "$GIT_DIR/MERGE_MSG"
@@ -497,7 +499,8 @@ then
499
q
500
}
501
'
500
- set_author_env=`git-cat-file commit "$use_commit" |
502
+ encoding=$(git repo-config i18n.commitencoding || echo UTF-8)
503
+ set_author_env=`git show -s --pretty=raw --encoding="$encoding" "$use_commit" |
504
LANG=C LC_ALL=C sed -ne "$pick_author_script"`
505
eval "$set_author_env"
506
export GIT_AUTHOR_NAME
git-revert.sh
+10
-4
@@ -78,6 +78,8 @@ prev=$(git-rev-parse --verify "$commit^1" 2>/dev/null) ||
78
git-rev-parse --verify "$commit^2" >/dev/null 2>&1 &&
79
die "Cannot run $me a multi-parent commit."
80
81
+encoding=$(git repo-config i18n.commitencoding || echo UTF-8)
82
+
83
# "commit" is an existing commit. We would want to apply
84
# the difference it introduces since its first parent "prev"
85
# on top of the current HEAD if we are cherry-pick. Or the
@@ -85,10 +87,11 @@ git-rev-parse --verify "$commit^2" >/dev/null 2>&1 &&
87
88
case "$me" in
89
revert)
88
- git-rev-list --pretty=oneline --max-count=1 $commit |
90
+ git show -s --pretty=oneline --encoding="$encoding" $commit |
91
sed -e '
92
s/^[^ ]* /Revert "/
91
- s/$/"/'
93
+ s/$/"/
94
+ '
95
echo
96
echo "This reverts commit $commit."
97
test "$rev" = "$commit" ||
@@ -117,14 +120,17 @@ cherry-pick)
120
121
q
122
}'
120
- set_author_env=`git-cat-file commit "$commit" |
123
+
124
+ logmsg=`git show -s --pretty=raw --encoding="$encoding" "$commit"`
125
+ set_author_env=`echo "$logmsg" |
126
LANG=C LC_ALL=C sed -ne "$pick_author_script"`
127
eval "$set_author_env"
128
export GIT_AUTHOR_NAME
129
export GIT_AUTHOR_EMAIL
130
export GIT_AUTHOR_DATE
131
127
- git-cat-file commit $commit | sed -e '1,/^$/d'
132
+ echo "$logmsg" |
133
+ sed -e '1,/^$/d' -e 's/^ //'
134
case "$replay" in
135
'')
136
echo "(cherry picked from commit $commit)"