Commit 8a26dd5c authored by Ben Boeckel's avatar Ben Boeckel

prepare: submodule directories are as their name, not path

parent 289bece4
# v3.1.1 (unreleased)
* Submodules which have different names and paths are now properly handled.
# v3.1.0
* Added support for "update merges". This is equivalent to using the `ours`
......
......@@ -379,10 +379,7 @@ impl PreparingGitWorkArea {
let gitmoduledir = self.context.gitdir().join("modules");
Ok(submodule_config.into_iter()
.filter(|&(_, ref config)| {
config.get("path")
.map_or(false, |path| gitmoduledir.join(path).exists())
})
.filter(|&(ref name, _)| gitmoduledir.join(name).exists())
.collect())
}
......
......@@ -139,6 +139,7 @@ static ARBITRARY_COMMIT: &'static str = "9266430a205bc43fcb669a9b4825f2c69d36c3d
// These commits contain a submodule for testing merging and related tasks with them.
static BASE_COMMIT: &'static str = "6787f648d93d32e70aea9e94c85914422940a6c0";
static SUBMODULE_ADD_CUSTOM_NAME: &'static str = "d340326994009b57e70e0fc90730ba668d90dab4";
static SUBMODULE_UPDATE_COMMIT: &'static str = "1d1ac896e2908685d6c20f78821add835cb110e8";
static SUBMODULE_REWIND_COMMIT: &'static str = "6995e3989758531fdbd988ece628e7307ab59266";
static SUBMODULE_BRANCH1_COMMIT: &'static str = "6e8ae702722e39626ac686929234eea0dc3d48de";
......@@ -423,6 +424,36 @@ fn test_work_area_setup_submodule() {
]);
}
#[test]
fn test_work_area_setup_submodule_custom_name() {
let tempdir = test_workspace_dir("test_work_area_setup_submodule_custom_name");
let commit = CommitId::new(SUBMODULE_ADD_CUSTOM_NAME);
let ctx = git_context_submodule(tempdir.path(), &commit);
let workarea = ctx.prepare(&commit).unwrap();
check_workarea(&workarea, &commit);
assert!(!workarea.submodule_config().is_empty());
let submodule_config = workarea.submodule_config()
.iter()
.map(|(name, config)| {
(name.as_str(),
config.iter()
.map(|(key, value)| (key.as_str(), value.as_str()))
.sorted_by(|ref a, ref b| Ord::cmp(&a.0, &b.0)))
})
.sorted_by(|ref a, ref b| Ord::cmp(&a.0, &b.0));
assert_eq!(submodule_config,
&[
("custom-name",
vec![
("path", "submodule"),
("url", "https://gitlab.kitware.com/utils/test-repo.git"),
]),
]);
}
#[test]
fn test_setup_merge() {
let tempdir = test_workspace_dir("test_setup_merge");
......
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