Skip to content

fix(server): don't report origin/main in repos with no remote - #459

Merged
yoshiko-pg merged 1 commit into
yoshiko-pg:mainfrom
finnmglas:finn/fix-local-only-repos
Aug 28, 2026
Merged

yoshiko-pg merged 1 commit into
yoshiko-pg:mainfrom
finnmglas:finn/fix-local-only-repos

Conversation

@finnmglas

Copy link
Copy Markdown
Contributor

Hi, first small bugfix commit here, love the tool!


Description: When origin/HEAD is unset, getOriginDefaultBranch falls back to probing refs/remotes/origin/{main,master} with git show-ref --verify --quiet. That probe never fails. simple-git decides success partly from stderr, and --quiet tells git to stay silent, so a missing ref resolves instead of rejecting.

Impact: Every local-only repository therefore reports originDefaultBranch: "origin/main" from GET /api/revisions, and the quick menu offers an origin/main...Uncommitted (merge-base) preset that cannot resolve.

Proposed fix: Dropping --quiet lets git write fatal: ... - not a valid ref to stderr, which simple-git surfaces as a rejection, so the fallback behaves as intended.


Context: I first found difit last week while building a code-quality tool that also uses npx and interactive htmls based on git data (npx desprawl) :)

When `origin/HEAD` is unset, `getOriginDefaultBranch` falls back to probing
`refs/remotes/origin/{main,master}` with `git show-ref --verify --quiet`. That
probe never fails. simple-git decides success partly from stderr, and `--quiet`
tells git to stay silent, so a missing ref resolves instead of rejecting.

Every local-only repository therefore reports `originDefaultBranch:
"origin/main"` from `GET /api/revisions`, and the quick menu offers an
`origin/main...Uncommitted (merge-base)` preset that cannot resolve.

Dropping `--quiet` lets git write `fatal: ... - not a valid ref` to stderr,
which simple-git surfaces as a rejection, so the fallback behaves as intended.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@yoshiko-pg

Copy link
Copy Markdown
Owner

@finnmglas Thank you!!

寿司ゆき:love

@yoshiko-pg
yoshiko-pg enabled auto-merge (squash) August 28, 2026 14:56
@yoshiko-pg
yoshiko-pg disabled auto-merge August 28, 2026 14:56
@yoshiko-pg
yoshiko-pg merged commit faea407 into yoshiko-pg:main Aug 28, 2026
3 checks passed
WarLikeLaux pushed a commit to WarLikeLaux/difit that referenced this pull request Sep 25, 2026
…o-pg#459)

When `origin/HEAD` is unset, `getOriginDefaultBranch` falls back to probing
`refs/remotes/origin/{main,master}` with `git show-ref --verify --quiet`. That
probe never fails. simple-git decides success partly from stderr, and `--quiet`
tells git to stay silent, so a missing ref resolves instead of rejecting.

Every local-only repository therefore reports `originDefaultBranch:
"origin/main"` from `GET /api/revisions`, and the quick menu offers an
`origin/main...Uncommitted (merge-base)` preset that cannot resolve.

Dropping `--quiet` lets git write `fatal: ... - not a valid ref` to stderr,
which simple-git surfaces as a rejection, so the fallback behaves as intended.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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