Commit 4eed957b authored by Ben Boeckel's avatar Ben Boeckel

prepare: fix more submodule name/path mixups

parent c21c9455
Pipeline #71158 passed with stage
# v3.1.2 (unreleased)
* More submodule name/path mismatch fixes.
# v3.1.1
* Submodules which have different names and paths are now properly handled.
......
......@@ -435,8 +435,7 @@ impl GitWorkArea {
file_name(self.dir.path()));
for (name, config) in &self.submodule_config {
let path = config.get("path").unwrap();
let gitdir = self.context.gitdir().join("modules").join(path);
let gitdir = self.context.gitdir().join("modules").join(name);
if !gitdir.exists() {
error!(target: "git.workarea",
......@@ -448,6 +447,8 @@ impl GitWorkArea {
continue;
}
let path = config.get("path")
.expect("the 'path` configuration for submodules is required.");
let gitfiledir = self.work_tree().join(path);
fs::create_dir_all(&gitfiledir).chain_err(|| {
format!("failed to create the {} submodule directory for the workarea",
......@@ -484,19 +485,18 @@ impl GitWorkArea {
file_name(self.dir.path()),
path.display());
let branch = self.submodule_config
let branch_info = self.submodule_config
.iter()
.find(|&(_, config)| {
config.get("path")
.map_or(false,
|submod_path| submod_path.as_str() == path.to_string_lossy())
})
.map(|(_, config)| {
config.get("branch")
.map_or("master", String::as_str)
.map(|(name, config)| {
(name, config.get("branch").map_or("master", String::as_str))
});
let branch = if let Some(branch_name) = branch {
let (name, branch) = if let Some((name, branch_name)) = branch_info {
if branch_name == "." {
// TODO: Pass the branch name we are working on down to here.
debug!(target: "git.workarea",
......@@ -506,7 +506,7 @@ impl GitWorkArea {
return Ok(Conflict::Path(path));
}
branch_name
(name, branch_name)
} else {
debug!(target: "git.workarea",
"no submodule configured for {}; cannot attempt smarter resolution",
......@@ -515,7 +515,7 @@ impl GitWorkArea {
return Ok(Conflict::Path(path));
};
let submodule_ctx = GitContext::new(self.gitdir().join("modules").join(&path));
let submodule_ctx = GitContext::new(self.gitdir().join("modules").join(name));
// NOTE: The submodule is assumed to be kept up-to-date externally.
let refs = submodule_ctx.git()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment