From dc9290109481e5e0d0c224fecb217ceb5a4c978d Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 7 Nov 2017 00:29:19 +0100 Subject: vim-patch.sh: new option `-P` --- scripts/vim-patch.sh | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'scripts/vim-patch.sh') diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index 4f6bb40488..fd1d2a200b 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -22,9 +22,10 @@ usage() { echo "Options:" echo " -h Show this message and exit." echo " -l Show list of Vim patches missing from Neovim." - echo " -p {vim-revision} Download and apply the Vim patch vim-revision." - echo " vim-revision can be a version number of the " - echo " format '7.4.xxx' or a Git commit hash." + echo " -p {vim-revision} Download and generate the specified Vim patch." + echo " vim-revision can be a version number '8.0.xxx'" + echo " or a valid Git ref (hash, tag, etc.)." + echo " -P {vim-revision} Download, generate and apply the Vim patch." echo " -g {vim-revision} Download the Vim patch vim-revision." echo " vim-revision can be a version number of the " echo " format '7.4.xxx' or a Git commit hash." @@ -32,7 +33,7 @@ usage() { echo " -r {pr-number} Review a vim-patch pull request to Neovim." echo echo "Set VIM_SOURCE_DIR to change where Vim's sources are stored." - echo "The default is '${VIM_SOURCE_DIR_DEFAULT}'." + echo "Default is '${VIM_SOURCE_DIR_DEFAULT}'." } # Checks if a program is in the user's PATH, and is executable. @@ -186,6 +187,7 @@ get_vim_patch() { stage_patch() { get_vim_patch "$1" + local try_apply="${2:-}" local git_remote git_remote="$(find_git_remote)" @@ -215,14 +217,23 @@ stage_patch() { echo "āœ” ${output}" || (echo "✘ ${output}"; false) - printf "\nInstructions: - Proceed to port the patch. This may help: - patch -p1 < ${patch_file} + if test -n "$try_apply" ; then + if ! check_executable patch; then + printf "\n✘ 'patch' command not found\n" + else + printf "\nApplying patch...\n" + patch -p1 < "${patch_file}" + fi + printf "\nInstructions:\n Proceed to port the patch.\n" + else + printf "\nInstructions:\n Proceed to port the patch.\n Try the 'patch' command (or use '${BASENAME} -P ...' next time):\n patch -p1 < ${patch_file}\n" + fi - Stage your changes ('git add ...') and use 'git commit --amend' to commit. + printf " + Stage your changes ('git add ...'), then use 'git commit --amend' to commit. - To port additional patches related to ${vim_version} and add them to the - current branch, call '${BASENAME} -p' again. + To port more patches (if any) related to ${vim_version}, + run '${BASENAME}' again. * Do this only for _related_ patches (otherwise it increases the size of the pull request, making it harder to review) @@ -446,7 +457,7 @@ review_pr() { clean_files } -while getopts "hlp:g:r:s" opt; do +while getopts "hlp:P:g:r:s" opt; do case ${opt} in h) usage @@ -460,6 +471,10 @@ while getopts "hlp:g:r:s" opt; do stage_patch "${OPTARG}" exit 0 ;; + P) + stage_patch "${OPTARG}" TRY_APPLY + exit 0 + ;; g) get_vim_patch "${OPTARG}" exit 0 -- cgit From 3a7feb69897ad081cbe4a782b08176084df6e386 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 7 Nov 2017 20:25:34 +0100 Subject: vim-patch.sh: remove vimrc_example.vim vimrc_example.vim is not relevant to Nvim. Anything worth having in there should be made an actual default. .gitignore: - remove *.orig ... super annoying --- scripts/vim-patch.sh | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'scripts/vim-patch.sh') diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index fd1d2a200b..07b3904570 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -151,6 +151,10 @@ preprocess_patch() { local na_po='sjiscorr.c\|ja.sjis.po\|ko.po\|pl.cp1250.po\|pl.po\|ru.cp1251.po\|uk.cp1251.po\|zh_CN.cp936.po\|zh_CN.po\|zh_TW.po' 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/po/\<\%('${na_po}'\)\>@norm! d/\v(^diff)|%$ ' +w +q "$file" + # Remove vimrc_example.vim + local na_vimrcexample='vimrc_example\.vim' + 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/runtime/\<\%('${na_vimrcexample}'\)\>@norm! d/\v(^diff)|%$ ' +w +q "$file" + # Rename src/ paths to src/nvim/ LC_ALL=C sed -e 's/\( [ab]\/src\)/\1\/nvim/g' \ "$file" > "$file".tmp && mv "$file".tmp "$file" -- cgit From ea51f08276ce7c9386b88b320fd63ae71324351a Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 7 Nov 2017 20:41:35 +0100 Subject: vim-patch.sh: avoid creating *.orig files --- scripts/vim-patch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/vim-patch.sh') diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index 07b3904570..2875e7d95a 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -226,7 +226,7 @@ stage_patch() { printf "\n✘ 'patch' command not found\n" else printf "\nApplying patch...\n" - patch -p1 < "${patch_file}" + patch -p1 --posix < "${patch_file}" fi printf "\nInstructions:\n Proceed to port the patch.\n" else -- cgit