aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDaniel Hahler <git@thequod.de>2019-10-16 15:44:38 +0200
committerGitHub <noreply@github.com>2019-10-16 15:44:38 +0200
commitc5c06665ed302e774dc1a01bed949815b4b7c8c3 (patch)
treed710bfbf47e2cacb00a86da076c4d77f1be351a5 /scripts
parent932edf4f338c4d31f94fdaaa125d3ff8c2e6fe08 (diff)
downloadrneovim-c5c06665ed302e774dc1a01bed949815b4b7c8c3.tar.gz
rneovim-c5c06665ed302e774dc1a01bed949815b4b7c8c3.tar.bz2
rneovim-c5c06665ed302e774dc1a01bed949815b4b7c8c3.zip
scripts/vim-patch.sh: lazily update Vim source (#11207)
This gets done only initially, for `-l`, and when a commit cannot be found. Also provide more compact instructions with `-l` / `show_vimpatches`.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/vim-patch.sh36
1 files changed, 19 insertions, 17 deletions
diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh
index 4efe509008..2a04805606 100755
--- a/scripts/vim-patch.sh
+++ b/scripts/vim-patch.sh
@@ -89,7 +89,7 @@ get_vim_sources() {
echo "Cloning Vim into: ${VIM_SOURCE_DIR}"
git clone https://github.com/vim/vim.git "${VIM_SOURCE_DIR}"
cd "${VIM_SOURCE_DIR}"
- else
+ elif [[ "${1-}" == update ]]; then
cd "${VIM_SOURCE_DIR}"
if ! [ -d ".git" ] \
&& ! [ "$(git rev-parse --show-toplevel)" = "${VIM_SOURCE_DIR}" ]; then
@@ -103,6 +103,8 @@ get_vim_sources() {
else
msg_err "Could not update Vim sources; ignoring error."
fi
+ else
+ cd "${VIM_SOURCE_DIR}"
fi
}
@@ -124,7 +126,7 @@ find_git_remote() {
}
# Assign variables for a given Vim tag, patch version, or commit.
-# Might exit in case it cannot be found.
+# Might exit in case it cannot be found, after updating Vim sources.
assign_commit_details() {
local vim_commit_ref
if [[ ${1} =~ v?[0-9]\.[0-9]\.[0-9]{3,4} ]]; then
@@ -146,9 +148,14 @@ assign_commit_details() {
local munge_commit_line=false
fi
- vim_commit=$(git -C "${VIM_SOURCE_DIR}" log -1 --format="%H" "${vim_commit_ref}" --) || {
- >&2 msg_err "Couldn't find Vim revision '${vim_commit_ref}'."
- exit 3
+ local get_vim_commit_cmd="git -C ${VIM_SOURCE_DIR} log -1 --format=%H ${vim_commit_ref} --"
+ vim_commit=$($get_vim_commit_cmd 2>&1) || {
+ # Update Vim sources.
+ get_vim_sources update
+ vim_commit=$($get_vim_commit_cmd 2>&1) || {
+ >&2 msg_err "Couldn't find Vim revision '${vim_commit_ref}': git error: ${vim_commit}."
+ exit 3
+ }
}
vim_commit_url="https://github.com/vim/vim/commit/${vim_commit}"
@@ -478,8 +485,8 @@ list_missing_vimpatches() {
# Prints a human-formatted list of Vim commits, with instructional messages.
# Passes "$@" onto list_missing_vimpatches (args for git-log).
show_vimpatches() {
- get_vim_sources
- printf "\nVim patches missing from Neovim:\n"
+ get_vim_sources update
+ printf "Vim patches missing from Neovim:\n"
local -A runtime_commits
for commit in $(git -C "${VIM_SOURCE_DIR}" log --format="%H %D" -- runtime | sed 's/,\? tag: / /g'); do
@@ -494,17 +501,12 @@ show_vimpatches() {
fi
done
- printf "Instructions:
-
- To port one of the above patches to Neovim, execute
- this script with the patch revision as argument and
- follow the instructions.
-
- Examples: '%s -p 7.4.487'
- '%s -p 1e8ebf870720e7b671f98f22d653009826304c4f'
+ printf "\nInstructions:
+ To port one of the above patches to Neovim, execute this script with the patch revision as argument and follow the instructions, e.g.
+ '%s -p v8.0.1234', or '%s -P v8.0.1234'
NOTE: Please port the _oldest_ patch if you possibly can.
- Out-of-order patches increase the possibility of bugs.
+ You can use '%s -l path/to/file' to see what patches are missing for a file.
" "${BASENAME}" "${BASENAME}"
}
@@ -646,7 +648,7 @@ while getopts "hlLMVp:P:g:r:s" opt; do
exit 0
;;
V)
- get_vim_sources
+ get_vim_sources update
exit 0
;;
*)