Skip to content

Commit 70e8f9d

Browse files
authored
Rollup merge of #113371 - jyn514:submodule-with-tags, r=albertlarsan68
Fix submodule handling when the current branch is named after a tag If: 1. The current branch has the same name as git tag, and 2. The current branch is set to track a remote other than `origin`, and 3. We try to update a submodule then we'll get the following error: ``` ; x c Updating submodule src/doc/reference remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 fatal: 'personal' does not appear to be a git repository fatal: Could not read from remote repository. ``` The problem is that 1. causes `git symbolic-ref --short HEAD` to try and disambiguate the branch from the tag using `heads/branch-name`, which breaks a previous workaround for a bug in `git submodule update` that uses the wrong remote. Adapt the workaround to strip `heads/` from the output.
2 parents 2bc0ae3 + 6c7017f commit 70e8f9d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/bootstrap/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,9 @@ impl Build {
599599

600600
let mut git = self.config.git();
601601
if let Some(branch) = current_branch {
602+
// If there is a tag named after the current branch, git will try to disambiguate by prepending `heads/` to the branch name.
603+
// This syntax isn't accepted by `branch.{branch}`. Strip it.
604+
let branch = branch.strip_prefix("heads/").unwrap_or(&branch);
602605
git.arg("-c").arg(format!("branch.{branch}.remote=origin"));
603606
}
604607
git.args(&["submodule", "update", "--init", "--recursive", "--depth=1"]);

0 commit comments

Comments
 (0)