vim-patch.sh: force LC_ALL=C for preprocessing

Any patch may contain mixed encodings, so we must process them as byte
arrays. E.g. with stock `sed` on OS X patch
8a94d873aa8c753a8522ea86a049bdf2abd0c507 causes this error:
    sed: RE error: illegal byte sequence
To avoid that, set LC_ALL=C.

Also remove redundant *.patch creation from review_pr().
This commit is contained in:
Justin M. Keyes 2015-12-17 21:02:20 -05:00
parent ecdf18edbb
commit 1e7a553ed7

View File

@ -38,11 +38,10 @@ check_executable() {
get_vim_sources() { get_vim_sources() {
check_executable git check_executable git
echo "Retrieving Vim sources." cd "${VIM_SOURCE_DIR}"
if [[ ! -d ${VIM_SOURCE_DIR} ]]; then if [[ ! -d ${VIM_SOURCE_DIR} ]]; then
echo "Cloning Vim sources into '${VIM_SOURCE_DIR}'." echo "Cloning Vim sources into '${VIM_SOURCE_DIR}'."
git clone --depth=1000 https://github.com/vim/vim.git "${VIM_SOURCE_DIR}" git clone --depth=1000 https://github.com/vim/vim.git "${VIM_SOURCE_DIR}"
cd "${VIM_SOURCE_DIR}"
else else
if [[ ! -d "${VIM_SOURCE_DIR}/.git" ]]; then if [[ ! -d "${VIM_SOURCE_DIR}/.git" ]]; then
echo "${VIM_SOURCE_DIR} does not appear to be a git repository." echo "${VIM_SOURCE_DIR} does not appear to be a git repository."
@ -50,7 +49,6 @@ get_vim_sources() {
exit 1 exit 1
fi fi
echo "Updating Vim sources in '${VIM_SOURCE_DIR}'." echo "Updating Vim sources in '${VIM_SOURCE_DIR}'."
cd "${VIM_SOURCE_DIR}"
git pull && git pull &&
echo "✔ Updated Vim sources." || echo "✔ Updated Vim sources." ||
echo "✘ Could not update Vim sources; ignoring error." echo "✘ Could not update Vim sources; ignoring error."
@ -58,11 +56,8 @@ get_vim_sources() {
} }
commit_message() { commit_message() {
echo "vim-patch:${vim_version} printf 'vim-patch:%s\n\n%s\n\n%s' "${vim_version}" \
"${vim_message}" "${vim_commit_url}"
${vim_message}
${vim_commit_url}"
} }
assign_commit_details() { assign_commit_details() {
@ -102,8 +97,10 @@ get_vim_patch() {
# Collect patch details and store into variables. # Collect patch details and store into variables.
vim_full="$(git show -1 --pretty=medium "${vim_commit}")" vim_full="$(git show -1 --pretty=medium "${vim_commit}")"
# Patch surgery: preprocess the patch.
# - transform src/ paths to src/nvim/
vim_diff="$(git show -1 "${vim_commit}" \ vim_diff="$(git show -1 "${vim_commit}" \
| sed -e 's/\( [ab]\/src\)/\1\/nvim/g')" # Change directory to src/nvim. | LC_ALL=C sed -e 's/\( [ab]\/src\)/\1\/nvim/g')"
neovim_message="$(commit_message)" neovim_message="$(commit_message)"
neovim_pr=" neovim_pr="
\`\`\` \`\`\`
@ -256,8 +253,6 @@ review_pr() {
echo "✔ Saved full pull request commit details to '${NEOVIM_SOURCE_DIR}/n${base_name}.patch'." echo "✔ Saved full pull request commit details to '${NEOVIM_SOURCE_DIR}/n${base_name}.patch'."
git show "${vim_commit}" > "${NEOVIM_SOURCE_DIR}/${base_name}.diff" git show "${vim_commit}" > "${NEOVIM_SOURCE_DIR}/${base_name}.diff"
echo "✔ Saved Vim diff to '${NEOVIM_SOURCE_DIR}/${base_name}.diff'." echo "✔ Saved Vim diff to '${NEOVIM_SOURCE_DIR}/${base_name}.diff'."
git show "${vim_commit}" > "${NEOVIM_SOURCE_DIR}/${base_name}.patch"
echo "✔ Saved full Vim commit details to '${NEOVIM_SOURCE_DIR}/${base_name}.patch'."
echo "You can use 'git clean' to remove these files when you're done." echo "You can use 'git clean' to remove these files when you're done."
echo echo