Skip to content

test: pin the branch in the t900 tests that push to main - #199

Merged
mizchi merged 1 commit into
mainfrom
claude/modest-dirac-kceqee
Sep 21, 2026
Merged

mizchi merged 1 commit into
mainfrom
claude/modest-dirac-kceqee

Conversation

@mizchi

@mizchi mizchi commented Sep 21, 2026

Copy link
Copy Markdown
Member

Fixes #193, #194, #195.

Three tests create their repositories with a bare git init and then name main, so they fail wherever init.defaultBranch is unset and git still defaults to master (git 2.43 here).

before after failing assertion
t9001-subdir-push 19 of 23 23 of 23 git push origin main (×3, plus one knock-on)
t9004-workspace-routing 7 of 8 8 of 8 grep "main" branch.out
t9005-workspace-commit-push 6 of 7 7 of 7 git push origin main

The fix

For t9001 and t9005 the branch to pin is the bare upstream's, not the clone's — the working clone adopts the remote's unborn HEAD, so one change fixes the push without touching the clone:

 mkdir upstream.git &&
-(cd upstream.git && git init --bare) &&
+(cd upstream.git &&
+ git init --bare &&
+ git symbolic-ref HEAD refs/heads/main) &&
 git clone upstream.git work &&

t9004 creates its repository directly, so it is pinned in place.

Setting HEAD while it is unborn rather than passing git init -b, which needs git 2.28 — the same form used for the fixture in #192.

Verification

All three pass in full with init.defaultBranch unset, and with it set to main — so the fix removes the dependency rather than moving it:

                              unset       =main
t9001-subdir-push             23 / 0      23 / 0
t9004-workspace-routing        8 / 0       8 / 0
t9005-workspace-commit-push    7 / 0       7 / 0

The whole test-subdir task afterwards:

t900:  Total 11   Passed 10   Failed 1
t902:  Total  2   Passed  2   Failed 0

The one remaining failure is t9007-workspace-nested-translation.sh, left alone deliberately — see #196. It expects bit repo status from a deep nested path to fail with Not a git repository and it does not, while the sibling assertion at the workspace root passes. Deciding whether the test's expectation or the behaviour is right is a call for a maintainer, not a mechanical fix.

A correction worth flagging

While preparing this I found that four of the six issues I filed after #192 were wrong, and I have corrected them: #197 and #198 are closed as not-a-bug, and #194, #195, #196 had retractions added.

I had reported that implicit command translation was broken — bit status inside a workspace returning plain git status instead of the workspace form. It is not. The container I triaged in exports git config through the environment (GIT_CONFIG_COUNT, GIT_CONFIG_KEY_0..2, GIT_CONFIG_VALUE_0..2, holding credential.interactive and two url.*.insteadOf entries for its proxy). should_delegate_to_real_git (modules/bit/cmd/bit/main.mbt:1044) treats any such injection as a reason to hand the command to the real git binary, and it runs before workspace_translate_implicit_command — which is the documented intent of that check. With those variables unset, every one of those assertions passes.

Every measurement in this PR was taken with GIT_CONFIG_* unset.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VDVUJHu38YtVAr6sKZtRDB


Generated by Claude Code

Three tests create their repositories with a bare `git init` and then name
`main`, so they fail wherever init.defaultBranch is unset and git still
defaults to `master` (git 2.43 here):

  t9001-subdir-push        19 of 23 passed   `git push origin main`
  t9004-workspace-routing   7 of 8  passed   `grep "main" branch.out`
  t9005-workspace-commit-push 6 of 7 passed  `git push origin main`

For t9001 and t9005 the branch to pin is the bare upstream's: the working
clone adopts the remote's unborn HEAD, so setting it there fixes the push
without touching the clone. t9004 creates its repository directly.

Setting HEAD while it is unborn rather than passing `git init -b`, which
needs git 2.28 — the same form used for the fixture in #192.

All three now pass in full, both with init.defaultBranch unset and with it
set to main, so the fix does not just move the dependency.

Fixes #193
Fixes #194
Fixes #195

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VDVUJHu38YtVAr6sKZtRDB
@mizchi
mizchi merged commit 2cdd8da into main Sep 21, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

t9001-subdir-push: all four failures come from git push origin main on a master repo

2 participants