vim-patch.sh: new option -P

This commit is contained in:
Justin M. Keyes 2017-11-07 00:29:19 +01:00
parent 7bcbf5d456
commit dc92901094

View File

@ -22,9 +22,10 @@ usage() {
echo "Options:" echo "Options:"
echo " -h Show this message and exit." echo " -h Show this message and exit."
echo " -l Show list of Vim patches missing from Neovim." echo " -l Show list of Vim patches missing from Neovim."
echo " -p {vim-revision} Download and apply the Vim patch vim-revision." echo " -p {vim-revision} Download and generate the specified Vim patch."
echo " vim-revision can be a version number of the " echo " vim-revision can be a version number '8.0.xxx'"
echo " format '7.4.xxx' or a Git commit hash." 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 " -g {vim-revision} Download the Vim patch vim-revision."
echo " vim-revision can be a version number of the " echo " vim-revision can be a version number of the "
echo " format '7.4.xxx' or a Git commit hash." 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 " -r {pr-number} Review a vim-patch pull request to Neovim."
echo echo
echo "Set VIM_SOURCE_DIR to change where Vim's sources are stored." 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. # Checks if a program is in the user's PATH, and is executable.
@ -186,6 +187,7 @@ get_vim_patch() {
stage_patch() { stage_patch() {
get_vim_patch "$1" get_vim_patch "$1"
local try_apply="${2:-}"
local git_remote local git_remote
git_remote="$(find_git_remote)" git_remote="$(find_git_remote)"
@ -215,14 +217,23 @@ stage_patch() {
echo "${output}" || echo "${output}" ||
(echo "${output}"; false) (echo "${output}"; false)
printf "\nInstructions: if test -n "$try_apply" ; then
Proceed to port the patch. This may help: if ! check_executable patch; then
patch -p1 < ${patch_file} 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 To port more patches (if any) related to ${vim_version},
current branch, call '${BASENAME} -p' again. run '${BASENAME}' again.
* Do this only for _related_ patches (otherwise it increases the * Do this only for _related_ patches (otherwise it increases the
size of the pull request, making it harder to review) size of the pull request, making it harder to review)
@ -446,7 +457,7 @@ review_pr() {
clean_files clean_files
} }
while getopts "hlp:g:r:s" opt; do while getopts "hlp:P:g:r:s" opt; do
case ${opt} in case ${opt} in
h) h)
usage usage
@ -460,6 +471,10 @@ while getopts "hlp:g:r:s" opt; do
stage_patch "${OPTARG}" stage_patch "${OPTARG}"
exit 0 exit 0
;; ;;
P)
stage_patch "${OPTARG}" TRY_APPLY
exit 0
;;
g) g)
get_vim_patch "${OPTARG}" get_vim_patch "${OPTARG}"
exit 0 exit 0