File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ impl GitGraph {
4343 pub fn new (
4444 mut repository : Repository ,
4545 settings : & Settings ,
46+ start_point : Option < String > ,
4647 max_count : Option < usize > ,
4748 ) -> Result < Self , String > {
4849 #![ doc = include_str ! ( "../docs/branch_assignment.md" ) ]
@@ -61,8 +62,17 @@ impl GitGraph {
6162 walk. set_sorting ( git2:: Sort :: TOPOLOGICAL | git2:: Sort :: TIME )
6263 . map_err ( |err| err. message ( ) . to_string ( ) ) ?;
6364
64- walk. push_glob ( "*" )
65- . map_err ( |err| err. message ( ) . to_string ( ) ) ?;
65+ // Use starting point if specified
66+ if let Some ( start) = start_point {
67+ let object = repository
68+ . revparse_single ( & start)
69+ . map_err ( |err| format ! ( "Failed to resolve start point '{}': {}" , start, err) ) ?;
70+ walk. push ( object. id ( ) )
71+ . map_err ( |err| err. message ( ) . to_string ( ) ) ?;
72+ } else {
73+ walk. push_glob ( "*" )
74+ . map_err ( |err| err. message ( ) . to_string ( ) ) ?;
75+ }
6676
6777 if repository. is_shallow ( ) {
6878 return Err ( "ERROR: git-graph does not support shallow clones due to a missing feature in the underlying libgit2 library." . to_string ( ) ) ;
Original file line number Diff line number Diff line change @@ -422,7 +422,7 @@ fn run(
422422 pager : bool ,
423423) -> Result < ( ) , String > {
424424 let now = Instant :: now ( ) ;
425- let graph = GitGraph :: new ( repository, settings, max_commits) ?;
425+ let graph = GitGraph :: new ( repository, settings, None , max_commits) ?;
426426
427427 let duration_graph = now. elapsed ( ) . as_micros ( ) ;
428428
You can’t perform that action at this time.
0 commit comments