From f4f715fcf174daac82a4659203139f8863ae6f2b Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Thu, 23 Apr 2026 18:12:44 +0300 Subject: [PATCH] tools: fix v up error on windows (fixes #15298) --- GNUmakefile | 2 +- Makefile | 2 +- cmd/tools/vup.v | 16 +++++++++++----- makev.bat | 4 ++-- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index ed6b5eb94..f60dc3455 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -18,7 +18,7 @@ TMPLEGACY := $(LEGACYLIBS)/source TCCOS := unknown TCCARCH := unknown HAS_GIT := $(shell command -v $(GIT) >/dev/null 2>&1 && echo 1 || echo 0) -GITCLEANPULL := $(GIT) clean -xf && $(GIT) pull --quiet +GITCLEANPULL := $(GIT) clean -xf && $(GIT) pull --rebase --quiet GITFASTCLONE := $(GIT) clone --filter=blob:none --quiet #### Platform detections and overrides: diff --git a/Makefile b/Makefile index 6bec64064..0a626be23 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ all: download_vc v download_vc: if [ -f vc/v.c ] ; then \ if command -v git >/dev/null 2>&1 ; then \ - git -C vc/ pull; \ + git -C vc/ pull --rebase; \ else \ echo "git not found; using existing vc/v.c"; \ fi; \ diff --git a/cmd/tools/vup.v b/cmd/tools/vup.v index a9d4807e9..7a86ede7b 100644 --- a/cmd/tools/vup.v +++ b/cmd/tools/vup.v @@ -7,6 +7,8 @@ import v.util.recompilation const vexe = os.real_path(os.getenv_opt('VEXE') or { @VEXE }) const vroot = os.dir(vexe) +const v_upstream_url = 'https://github.com/vlang/v' +const v_upstream_branch = 'master' struct App { is_verbose bool @@ -77,20 +79,24 @@ fn (app App) update_from_master() { if !os.exists('.git') { // initialize the folder, as if it had been cloned: app.git_command('git init') - app.git_command('git remote add origin https://github.com/vlang/v') + app.git_command('git remote add origin ${v_upstream_url}') app.git_command('git fetch') - app.git_command('git remote set-head origin master') - app.git_command('git reset --hard origin/master') + app.git_command('git remote set-head origin ${v_upstream_branch}') + app.git_command('git reset --hard origin/${v_upstream_branch}') // Note 1: patterns starting with /, will match only against the root; // `--exclude v` will match also vlib/v/ in addition to ./v; `--exclude /v` will only match ./v // Note 2: patterns ending with / are treated as folders. app.git_command('git clean -xfd --exclude /thirdparty/tcc/ --exclude /v --exclude /v.exe --exclude /v_old --exclude /v_old.exe --exclude /${app.current_vexe_name()} --exclude /${app.current_vbackup_name()} --exclude /.bin/ --exclude /cmd/tools/vup --exclude /cmd/tools/vup.exe') } else { - // pull latest - app.git_command('git pull https://github.com/vlang/v master') + // Rebase avoids merge failures when the local checkout has unrelated history. + app.git_command(v_upstream_pull_command()) } } +fn v_upstream_pull_command() string { + return 'git pull --rebase ${v_upstream_url} ${v_upstream_branch}' +} + fn (app App) recompile_v() bool { // Note: app.vexe is more reliable than just v (which may be a symlink) vexe_path := app.current_vexe_path() diff --git a/makev.bat b/makev.bat index b50a2b1ba..421a4b132 100644 --- a/makev.bat +++ b/makev.bat @@ -123,7 +123,7 @@ if !flag_local! NEQ 1 ( echo Updating vc... echo ^> Sync with remote !vc_url! cd %vc_dir% - git pull --quiet + git pull --rebase --quiet cd .. popd ) @@ -245,7 +245,7 @@ if exist "%tcc_dir%" ( echo Updating TCC echo ^> Syncing TCC from !tcc_url! if exist "lib\advapi32.def" git checkout -- lib\advapi32.def >nul 2>nul - git pull --quiet + git pull --rebase --quiet popd ) ) else ( -- 2.39.5