aboutsummaryrefslogtreecommitdiff
path: root/scripts/vim-patch.sh
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-10-30 08:05:50 +0800
committerGitHub <noreply@github.com>2022-10-30 08:05:50 +0800
commit8d38e1ad34552293de9e562b73c727ec119fd847 (patch)
tree02f8135ca9ff57f38f5c3150132f5d0e628b8162 /scripts/vim-patch.sh
parent2817411b7de3c85348e613ce97acff1f1cc5b781 (diff)
downloadrneovim-8d38e1ad34552293de9e562b73c727ec119fd847.tar.gz
rneovim-8d38e1ad34552293de9e562b73c727ec119fd847.tar.bz2
rneovim-8d38e1ad34552293de9e562b73c727ec119fd847.zip
build(vim-patch.sh): checkout files with path for uncrustify (#20863)
Diffstat (limited to 'scripts/vim-patch.sh')
-rwxr-xr-xscripts/vim-patch.sh44
1 files changed, 13 insertions, 31 deletions
diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh
index c2fac658a9..0854c2f627 100755
--- a/scripts/vim-patch.sh
+++ b/scripts/vim-patch.sh
@@ -280,49 +280,32 @@ preprocess_patch() {
}
uncrustify_patch() {
- local commit="$1"
- local changed_files=()
- while IFS='' read -r file; do changed_files+=("$file"); done < <(git diff-tree --name-only --no-commit-id -r "${commit}")
+ git diff --quiet || {
+ >&2 echo 'Vim source working tree dirty, aborting.'
+ exit 1
+ }
local patch_path=$NVIM_SOURCE_DIR/build/vim_patch
rm -rf "$patch_path"
- mkdir -p "$patch_path"/{before,after,patch}
+ mkdir -p "$patch_path"/{a,b}
- git checkout --quiet "$commit"~
- for file in "${changed_files[@]}"; do
- if [[ -e $file ]]; then
- cp "$file" "$patch_path"/before
- fi
+ local commit="$1"
+ for file in $(git diff-tree --name-only --no-commit-id -r --diff-filter=a "$commit"); do
+ git --work-tree="$patch_path"/a checkout --quiet "$commit"~ -- "$file"
done
-
- git checkout --quiet "$commit"
- for file in "${changed_files[@]}"; do
- if [[ -e $file ]]; then
- cp "$file" "$patch_path"/after
- fi
+ for file in $(git diff-tree --name-only --no-commit-id -r --diff-filter=d "$commit"); do
+ git --work-tree="$patch_path"/b checkout --quiet "$commit" -- "$file"
done
+ git reset --quiet --hard HEAD
# If the difference are drastic enough uncrustify may need to be used more
# than once. This is obviously a bug that needs to be fixed on uncrustify's
# end, but in the meantime this workaround is sufficient.
for _ in {1..2}; do
- uncrustify -c "$NVIM_SOURCE_DIR"/src/uncrustify.cfg -q --replace --no-backup "$patch_path"/{before,after}/*.[ch]
- done
-
- for file in "${changed_files[@]}"; do
- local basename
- basename=$(basename "$file")
- local before=$patch_path/before/$basename
- local after=$patch_path/after/$basename
- local patchfile="$patch_path"/patch/"$basename".patch
- [[ ! -e $before ]] && before=/dev/null
- [[ ! -e $after ]] && after=/dev/null
- git --no-pager diff --no-index --patch --unified=5 --color=never "$before" "$after" > "$patchfile"
- [[ "$before" != /dev/null ]] && sed -E "s|$before|/$file|g" -i "$patchfile"
- [[ "$after" != /dev/null ]] && sed -E "s|$after|/$file|g" -i "$patchfile"
+ uncrustify -c "$NVIM_SOURCE_DIR"/src/uncrustify.cfg -q --replace --no-backup "$patch_path"/{a,b}/src/*.[ch]
done
- cat "$patch_path"/patch/*.patch
+ (cd "$patch_path" && (git --no-pager diff --no-index --no-prefix --patch --unified=5 --color=never a/ b/ || true))
}
get_vimpatch() {
@@ -335,7 +318,6 @@ get_vimpatch() {
local patch_content
if check_executable uncrustify; then
patch_content="$(uncrustify_patch "${vim_commit}")"
- git switch --quiet master
else
patch_content="$(git --no-pager show --unified=5 --color=never -1 --pretty=medium "${vim_commit}")"
fi