History

[commitgraph] Take `info` dir as arg, not `objects` dir.

This gives callers more freedom in how their directories are structured.

Conor Davis committed 6 years ago

Commit 36953e01 parent d1f0e9c5 files · +11 −10Browse files

Showing the changes to git-commitgraph/src (1 of 5 files). Show all

Unified · Split

git-commitgraph/src/graph/init.rs+7−6
@@ -48,18 +48,19 @@ quick_error! { · 47 unmodified lines
4848 }
4949
5050 impl Graph {
51− pub fn from_object_dir(object_dir: impl AsRef<Path>) -> Result<Self, Error> {
52− Self::from_single_file(object_dir.as_ref()).or_else(|_| Self::from_split_chain(object_dir.as_ref()))
51+ pub fn from_info_dir(info_dir: impl AsRef<Path>) -> Result<Self, Error> {
52+ Self::from_single_file(info_dir.as_ref())
53+ .or_else(|_| Self::from_split_chain(info_dir.as_ref().join("commit-graphs")))
5354 }
5455
55− pub fn from_single_file(object_dir: impl AsRef<Path>) -> Result<Self, Error> {
56− let single_graph_file = object_dir.as_ref().join("info").join("commit-graph");
56+ pub fn from_single_file(info_dir: impl AsRef<Path>) -> Result<Self, Error> {
57+ let single_graph_file = info_dir.as_ref().join("commit-graph");
5758 let file = GraphFile::at(&single_graph_file).map_err(|e| Error::GraphFile(e, single_graph_file.clone()))?;
5859 Self::new(vec![file])
5960 }
6061
61− pub fn from_split_chain(object_dir: impl AsRef<Path>) -> Result<Self, Error> {
62− let commit_graphs_dir = object_dir.as_ref().join("info").join("commit-graphs");
62+ pub fn from_split_chain(commit_graphs_dir: impl AsRef<Path>) -> Result<Self, Error> {
63+ let commit_graphs_dir = commit_graphs_dir.as_ref();
6364 let chain_file_path = commit_graphs_dir.join("commit-graph-chain");
6465 let chain_file = std::fs::File::open(&chain_file_path).map_err(|e| Error::Io(e, chain_file_path.clone()))?;
6566 let mut files: Vec<GraphFile> = Vec::new();