Skip to content

fix(open): clone the branch given in ref - #41

Merged
moyiz merged 1 commit into
moyiz:masterfrom
twio142:fix/clone-ref-branch
Sep 22, 2026
Merged

moyiz merged 1 commit into
moyiz:masterfrom
twio142:fix/clone-ref-branch

Conversation

@twio142

@twio142 twio142 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

M.open resolves a ref from both ref and the parsed URI, but the clone call only received parsed_repo.branch.

So open("owner/repo", { branch = "x" }) clones without -b. With --single-branch in the default clone_args, no ref for x is fetched, the post-clone git checkout x fails, and the repo is left on the default branch — silently, unless verbose = true. The URI form (/tree/x) is unaffected.

Fix: pass ref.branch or ref.tag or parsed_repo.branch. -b takes branches and tags; ref.commit still goes through the post-clone checkout, as before.

`M.open` resolved a ref from both `ref` and the parsed URI, but the clone
call only received `parsed_repo.branch`. Calling `open(repo, { branch = "x" })`
with a URI that carries no branch therefore cloned without `-b`, and since
the default `clone_args` include `--single-branch`, no remote-tracking ref
for "x" was ever fetched. The post-clone checkout then failed and the
repository was left on the default branch.

Pass `ref.branch or ref.tag` to the clone, falling back to the parsed URI
as before.
@moyiz

moyiz commented Sep 22, 2026

Copy link
Copy Markdown
Owner

Thanks.
LGTM

@moyiz
moyiz merged commit e4b0ade into moyiz:master Sep 22, 2026
2 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.

2 participants