From 8bce9342d101eed4bb16fe03d36e7f89bac991ab Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 12 Nov 2025 14:45:20 +0800 Subject: [PATCH] fix(vim-patch.sh): don't treat 1-file runtime-only patch as N/A (#36525) If the patch in question does not change src/version.c, `git log -1` instead shows the previous patch that changes src/version.c, which causes 1-file runtime-only patches to be considered N/A. Check that the remaining file is src/version.c to fix this problem. Also use `git diff-tree` instead of `git log -1` for version.c. --- scripts/vim-patch.sh | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index 368596d6c2..171910367c 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -892,21 +892,20 @@ is_na_patch() { local NA_REGEXP="$NVIM_SOURCE_DIR/scripts/vim_na_regexp.txt" local NA_FILELIST="$NVIM_SOURCE_DIR/scripts/vim_na_files.txt" - local FILE_LNUM - # shellcheck disable=SC2086 - FILE_LNUM="$(diff <(git -C "${VIM_SOURCE_DIR}" diff-tree --no-commit-id --name-only -r "$patch" | grep -v -f "$NA_REGEXP") "$NA_FILELIST" | - grep -c '^<')" || FILE_LNUM=0 - test "$FILE_LNUM" -gt 1 && return 1 - if test "$FILE_LNUM" -eq 1; then + local FILES_REMAINING + FILES_REMAINING="$(diff <(git -C "${VIM_SOURCE_DIR}" diff-tree --no-commit-id --name-only -r "$patch" | grep -v -f "$NA_REGEXP") "$NA_FILELIST" | + grep '^<')" || true + test -z "$FILES_REMAINING" && return 0 + if test "$FILES_REMAINING" == "$(printf "< src/version.c\n")"; then local VERSION_LNUM - VERSION_LNUM=$(git -C "${VIM_SOURCE_DIR}" log -1 --numstat --format= "$patch" -- src/version.c | grep -c '^2\s\+0') + VERSION_LNUM=$(git -C "${VIM_SOURCE_DIR}" diff-tree --no-commit-id --numstat -r "$patch" -- src/version.c | grep -c '^2\s\+0') test "$VERSION_LNUM" -ne 1 && return 1 local VERSION_VNUM - VERSION_VNUM="$(git -C "${VIM_SOURCE_DIR}" log -1 -U1 --format="" "$patch" -- src/version.c | + VERSION_VNUM="$(git -C "${VIM_SOURCE_DIR}" diff-tree --no-commit-id -U1 -r "$patch" -- src/version.c | grep -Pzc '[ +]\/\*\*\/\n\+\s+[0-9]+,\n[ +]\/\*\*\/\n')" || true - test "$VERSION_VNUM" -ne 1 && return 1 + test "$VERSION_VNUM" -eq 1 && return 0 fi - return 0 + return 1 } list_na_patches() {