[PR #4571] [Other] update.sh / UPDATE.bat: a failed pull without origin/main is not the old history #5096

Open
opened 2026-11-07 16:32:39 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4571
Author: @Nyarlathoteppppp
Created: 10/29/2026
Status: 🔄 Open

Base: main ← Head: fix/4390-update-no-main


📝 Commits (1)

  • 1af3466 update: a failed pull on a clone without origin/main is not the old history (#4390)

📊 Changes

3 files changed (+62 additions, -1 deletions)

View changed files

📝 UPDATE.bat (+1 -0)
➕ tests/terminal/test_update_sh_no_main.py (+60 -0)
📝 update.sh (+1 -1)

📄 Description

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.

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/4571 **Author:** [@Nyarlathoteppppp](https://github.com/Nyarlathoteppppp) **Created:** 10/29/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/4390-update-no-main` --- ### 📝 Commits (1) - [`1af3466`](https://github.com/Niko1221/Strata/commit/1af3466ae67e12fd3ef7dfdf3830705c2abdb065) update: a failed pull on a clone without origin/main is not the old history (#4390) ### 📊 Changes **3 files changed** (+62 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `UPDATE.bat` (+1 -0) ➕ `tests/terminal/test_update_sh_no_main.py` (+60 -0) 📝 `update.sh` (+1 -1) </details> ### 📄 Description ## 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#5096
No description provided.