History

[commitgraph] refactor graph::init module

Sebastian Thiel committed 6 years ago

Commit d2eec1d1 parent 3c8640e1 file · +4 −4Browse files

Showing the changes to git-commitgraph (1 of 1 file). Show all

Unified · Split

git-commitgraph/src/graph/init.rs+4−4
@@ -39,6 +39,7 @@ quick_error! { · 38 unmodified lines
3939 }
4040 }
4141
42+/// Instantiate a `Graph` from various sources
4243 impl Graph {
4344 pub fn from_info_dir(info_dir: impl AsRef<Path>) -> Result<Self, Error> {
4445 Self::from_single_file(info_dir.as_ref())
@@ -55,11 +56,10 @@ impl Graph { · 10 unmodified lines
5556 let commit_graphs_dir = commit_graphs_dir.as_ref();
5657 let chain_file_path = commit_graphs_dir.join("commit-graph-chain");
5758 let chain_file = std::fs::File::open(&chain_file_path).map_err(|e| Error::Io(e, chain_file_path.clone()))?;
58− let mut files: Vec<File> = Vec::new();
59+ let mut files = Vec::new();
5960 for line in BufReader::new(chain_file).lines() {
60− let line = line.map_err(|e| Error::Io(e, chain_file_path.clone()))?;
61− let graph_filename = format!("graph-{}.graph", line);
62− let graph_file_path = commit_graphs_dir.join(graph_filename);
61+ let hash = line.map_err(|e| Error::Io(e, chain_file_path.clone()))?;
62+ let graph_file_path = commit_graphs_dir.join(format!("graph-{}.graph", hash));
6363 files.push(File::at(&graph_file_path).map_err(|e| Error::File(e, graph_file_path.clone()))?);
6464 }
6565 Self::new(files)