Skip to content

Fix detached checkout of non-default dependency branches - #3162

Open
Shubham-Padkonde wants to merge 1 commit into
dlang:masterfrom
Shubham-Padkonde:fix/git-remote-branch-checkout
Open

Shubham-Padkonde wants to merge 1 commit into
dlang:masterfrom
Shubham-Padkonde:fix/git-remote-branch-checkout

Conversation

@Shubham-Padkonde

Copy link
Copy Markdown
Contributor

Non-default branches in Git repository dependencies fail with fatal: --detach cannot be used with -b/-B/--orphan: after cloning, the branch exists only as a remote-tracking reference, and Git's automatic local branch creation conflicts with detached checkout.

Resolve an existing commit reference first, falling back to refs/remotes/origin/<reference> when it is absent. This preserves default-branch, commit-hash, and tag behavior, including a tag sharing its name with a remote branch.

The regression creates a local Git repository and runs a real DUB consumer against four references, checking the dependency's compiled value. The non-default branch fails before the fix; all four cases pass afterward. The fixture uses isolated temporary repositories and package caches, without a network dependency.

Validation on Linux, LDC 1.43.0:

  • ldc2 -run build.d with DMD=ldmd2: passed.
  • test/issue3047-git-branch.sh: all four consumer builds/runs passed.
  • dub test --compiler=ldc2 --skip-registry=all -c library: 59 modules passed.
  • Shell syntax and git diff --check: passed.

Fixes #3047 for the dependency checkout failure. The separately reported Windows cleanup/access-denied path has not been tested or changed. Full OS/compiler integration matrix not run.

Developed and tested with OpenAI Codex assistance; no independent human review is claimed.

@github-actions

Copy link
Copy Markdown

Thanks for your Pull Request and making D better!

This comment will automatically be updated to summarize some statistics in a few minutes.

@Shubham-Padkonde

Copy link
Copy Markdown
Contributor Author

Buildkite 4215 stopped before compilation because merge_head.sh could not fetch refs/pull/3162/merge (exit 128). That reference now resolves to 9834ba1e43e93efa9d1856c56f96b83c1aa5731f. Could someone with Buildkite access rerun it? This is the same initial checkout failure seen on #3161; no source changes were made for it. Local validation and agent assistance are disclosed above.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fatal: '--detach' cannot be used with '-b/-B/--orphan' when referencing branch w/ git repository dependency.

1 participant