#4571 [Other] update.sh / UPDATE.bat: a failed pull without origin/main is not the old history
closed · @Nyarlathoteppppp · 0 comentários · No GitHub
Descrição
## Problem and result
`update.sh` takes its "old history" recovery when `! git merge-base HEAD origin/main` succeeds. That is also true when `origin/main` does not exist (merge-base exits 128), so on a fork whose remote has no `main`, every ordinary `git pull --ff-only` failure is reported as old history and then fails on `git checkout -B <branch> origin/main`. `UPDATE.bat` has the same gate.
After the change the old-history path needs `origin/main` to resolve to a commit; otherwise a failed pull gets the existing "git pull did not succeed" message. A real old-history clone is handled as before.
## Related discussion
Fixes #4390. Focused fix, no scope change.
## Approach
- `update.sh`: add `git rev-parse --verify -q 'origin/main^{commit}'` to the condition, before the merge-base test.
- `UPDATE.bat`: clear `REWR` when that check fails, next to the shallow-clone check.
- New `tests/terminal/test_update_sh_no_main.py`: a hermetic sandbox (bare origin whose only branch is `memory-core`, a diverged clone with `update.sh` and a stub `setup.sh`) runs `sh update.sh` and checks exit 1, "git pull did not succeed", no "old history", no `pre-cleanup-backup*` branch, and that setup did not run. Skipped on Windows or without git/sh.
## Validation
**Passed:**
- `python -m pytest tests/terminal/test_update_sh_no_main.py`: fails on `46c152a` (old-history path taken) and passes with the fix.
- `python -m pytest tests/terminal/test_packaging_pins.py tests/terminal/test_no_acquisition.py`: 19 passed, 2 failed, the same 2 (`StartNeverAcquiresTests`) as on `46c152a`.
- Environment: macOS 26 (Darwin 25.5) arm64, Apple M1 Pro, Python 3.14.7, git 2.50.1, base `46c152a`.
**Failed:**
none beyond the pre-existing failures above.
**Not run:**
`UPDATE.bat` on Windows (the change is one line next to the existing shallow check), Linux, full test suite.
## Limits
The ordinary failure message is unchanged; it does not yet suggest merge/rebase for a diverged branch.
No site
Links install, modelos, releases.