GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — clone: support tags and explicit branch references by hakarrr · Pull Request #7475 · libgit2/libgit2

Conversation

@hakarrr

@hakarrr hakarrr commented Nov 10, 2026

Copy link
Copy Markdown

Fixes #3218.

checkout_branch currently treats every selection as a remote branch name, so a tag or an explicit refs/heads/... reference cannot be selected when cloning.

This keeps branch-first lookup for short names and falls back to a tag only when the branch is absent. Explicit refs/heads/... selects only a branch; explicit refs/tags/... selects only a tag. Tag selections use the existing HEAD setter to peel annotated tags and detach HEAD at the target commit. Normal branch tracking and the remote's default HEAD are preserved.

The API documentation now describes these choices. Twelve local regression tests cover lightweight and nested annotated tags, branch/tag collisions, explicit references, bare clones, the non-optimized file transport, missing selections and non-commit tags. They also check tracking configuration, detached HEAD and cleanup on failure. Arbitrary revision expressions are not added.

Validation on Linux, based on 42a89d7cc9374a19e72fa57011e5fe3a99c7b3bf:

  • Debug and Release builds with ENABLE_WERROR=ON pass. HTTPS, SSH, NTLM and Negotiate were disabled because their development dependencies are unavailable here.
  • All 12 new tests pass in Debug, Release and ASan+UBSan with leak detection. With the original clone.c, seven positive regression cases fail and five control cases pass.
  • Thirty local clone tests, run individually in each of Debug and Release, pass. bad_urls was not included because its network attempts timed out.
  • The remaining offline Release selection (-xonline -xclone::nonetwork) reports 3,103 executions, 45 skips and no failures. The same Debug selection has one structinit padding failure, reproduced after restoring the original clone.c.

No shallow HTTP/SSH, Windows or macOS validation is claimed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
hakarrr and others added 3 commits November 11, 2026 03:38
@hakarrr @GeneralTony007
clone: support tags and explicit branch references
f205463
Keep branch-first lookup for short names and fall back to a tag only when
no branch exists. Use the existing HEAD setter to peel tags and detach,
and accept explicit refs/heads/ and refs/tags/ selections.

Co-authored-by: GeneralTony007 <[email protected]>
@hakarrr @GeneralTony007
clone: document tag checkout and reference precedence
37d5cc5
Describe explicit branch and tag references, branch-first short names,
and detached HEAD behavior when selecting a tag.

Co-authored-by: GeneralTony007 <[email protected]>
@hakarrr @GeneralTony007
clone: test tag checkout and explicit reference selection
1e47c7f
Cover lightweight and nested annotated tags, explicit refs, branch/tag
collisions, bare and transported clones, and invalid checkout cleanup.
Check detached HEAD, tracking configuration and preserved remote HEAD.

Co-authored-by: GeneralTony007 <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Clone's branch option should take a ref or DWIM it

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@hakarrr
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.