@@ -156,6 +156,35 @@ impl CommandContext {
156156 Ok ( ( repo, VirtualBranchesTomlMetadataMut ( meta) , graph) )
157157 }
158158
159+ /// Open the repository with standard options and create a new Graph traversal from the given `ref_name`,
160+ /// along with a new metadata instance, and the graph itself.
161+ ///
162+ /// The write-permission is required to obtain a mutable metadata instance. Note that it must be held
163+ /// for until the end of the operation for the protection to be effective.
164+ ///
165+ /// Use [`Self::graph_and_meta()`] if control over the repository configuration is needed.
166+ pub fn graph_and_meta_mut_and_repo_from_reference (
167+ & self ,
168+ ref_name : & gix:: refs:: FullNameRef ,
169+ _write : & mut WorktreeWritePermission ,
170+ ) -> Result < (
171+ gix:: Repository ,
172+ VirtualBranchesTomlMetadataMut ,
173+ but_graph:: Graph ,
174+ ) > {
175+ let repo = self . gix_repo ( ) ?;
176+ let meta = self . meta_inner ( ) ?;
177+ let mut reference = repo. find_reference ( ref_name) ?;
178+ let commit_id = reference. peel_to_commit ( ) ?. id ( ) ;
179+ let graph = but_graph:: Graph :: from_commit_traversal (
180+ commit_id,
181+ reference. name ( ) . to_owned ( ) ,
182+ & meta,
183+ meta. graph_options ( ) ,
184+ ) ?;
185+ Ok ( ( repo, VirtualBranchesTomlMetadataMut ( meta) , graph) )
186+ }
187+
159188 /// Return a newly opened `gitoxide` repository, with all configuration available
160189 /// to correctly figure out author and committer names (i.e. with most global configuration loaded),
161190 /// *and* which will perform diffs quickly thanks to an adequate object cache.
0 commit comments