Skip to content

Init: fall back when git init does not support -b - #1650

Closed
bruAristimunha wants to merge 1 commit into
nemarOrg:feature/issue-1671-epic-bru-upload-fixesfrom
bruAristimunha:fix/issue-1645-git-init-b-fallback
Closed

bruAristimunha wants to merge 1 commit into
nemarOrg:feature/issue-1671-epic-bru-upload-fixesfrom
bruAristimunha:fix/issue-1645-git-init-b-fallback

Conversation

@bruAristimunha

@bruAristimunha bruAristimunha commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Problem

#1645: initDataset runs git init -b main, which git older than 2.28 (2.25 is the system git on Ubuntu 20.04 and several HPC images) rejects with "unknown switch `b'", so uploads stop at "Initializing git-annex dataset".

Change

  • initGitRepoOnMain tries git init -b main; on git's "unknown switch b'" it falls back to git initplusgit symbolic-ref HEAD refs/heads/main, which is what -b` does on an unborn branch.
  • Any other init failure is reported as before.

Closes #1645

Testing

  • test/git-init-branch-fallback.unit.test.ts (new, 5 tests): a PATH shim that answers init -b exactly like git 2.25 and logs its calls; the test asserts the fallback ran and the branch is main, and that a different init failure is reported, not retried.

  • 11 files that import the changed module: 146 pass, 1 skip, 0 fail (on current dev).

  • bun run typecheck, biome check on the changed files.

  • CI api-test and integration-dev fail on this PR because it comes from a fork: both call the dev API with the TEST_*_API_KEY secrets, which GitHub does not pass to fork pull requests, so the authenticated cases fail and the unauthenticated ones pass. lint, unit-pure and e2e-sandbox run normally.

initDataset ran 'git init -b main', which git 2.25 (Ubuntu 20.04's system
git, common on HPC images) rejects with "unknown switch `b'"; uploads failed
at 'Initializing git-annex dataset' unless a newer git was shimmed onto PATH.
initGitRepoOnMain now retries with a plain 'git init' and points the unborn
HEAD at refs/heads/main, which is what -b does. Other init failures are
reported as before.
@neuromechanist
neuromechanist changed the base branch from dev to feature/issue-1671-epic-bru-upload-fixes October 7, 2026 22:06
@neuromechanist

Copy link
Copy Markdown
Contributor

Thank you for this fix, and for the PATH shim that reproduced git 2.25. It is merged into the integration branch for epic #1671 as PR #1676, with your commit kept (fa76a57 on that branch, authored by you). The review added commits on top, so this PR is closed in favor of that one.

What the review added: the fallback keys on git's usage-error exit status (129) instead of the English message, since git localizes it; HEAD is re-pointed only when it is genuinely unborn, so an existing repository keeps its history and a corrupt ref is refused instead of being renamed over; both calls pass -- before the path; and the tests drive initDataset itself.

The epic merges into dev as a unit once 0.10.15 has shipped. The full review record is on #1676.

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.

2 participants