Skip to content

Commit

Permalink
Always remove .gitmodules (#2)
Browse files Browse the repository at this point in the history
This is a dirty solution which will only work for a repo with one
submodule and no history of ever having another, but hey, the goal of
our first release is to solve a specific problem I have, not to please
everyone. We have issues filed--we'll get there eventually.
  • Loading branch information
Minoru committed Jun 27, 2017
1 parent 820e7f7 commit 362825d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
First public release.

###Added
- Merges submodules that reside in the repository's root
- Merges a single submodule that resides in the repository's root
- Removes `.gitmodules`
- User can provide mappings from missing commit IDs to existing ones


Expand Down
5 changes: 5 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,10 +511,15 @@ fn replace_submodule_dir<'repo>(repo: &'repo Repository,
-> Tree<'repo> {
let mut treebuilder = repo.treebuilder(Some(&tree))
.expect("Couldn't create TreeBuilder");

treebuilder.remove(submodule_path)
.expect("Couldn't remove submodule path from TreeBuilder");
treebuilder.insert(submodule_path, *subtree_id, 0o040000)
.expect("Couldn't add submodule as a subdir to TreeBuilder");

treebuilder.remove(".gitmodules")
.expect("Couldn't remove .gitmodules from TreeBuilder");

let new_tree_id = treebuilder.write()
.expect("Couldn't write TreeBuilder into a Tree");
let new_tree = repo.find_tree(new_tree_id)
Expand Down

0 comments on commit 362825d

Please sign in to comment.