Repository navigation
Init: fall back when git init does not support -b - #1650
Closed
bruAristimunha wants to merge 1 commit into
Closed
bruAristimunha wants to merge 1 commit into
bruAristimunha wants to merge 1 commit into
Conversation
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.
9 tasks done
neuromechanist
changed the base branch from
dev
to
feature/issue-1671-epic-bru-upload-fixes
October 7, 2026 22:06
5 of 6 tasks
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 The epic merges into |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
#1645:
initDatasetrunsgit 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
initGitRepoOnMaintriesgit init -b main; on git's "unknown switchb'" it falls back togit initplusgit symbolic-ref HEAD refs/heads/main, which is what-b` does on an unborn branch.Closes #1645
Testing
test/git-init-branch-fallback.unit.test.ts(new, 5 tests): aPATHshim that answersinit -bexactly like git 2.25 and logs its calls; the test asserts the fallback ran and the branch ismain, 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 checkon the changed files.CI
api-testandintegration-devfail on this PR because it comes from a fork: both call the dev API with theTEST_*_API_KEYsecrets, which GitHub does not pass to fork pull requests, so the authenticated cases fail and the unauthenticated ones pass.lint,unit-pureande2e-sandboxrun normally.