File tree Expand file tree Collapse file tree
gitoxide-core/src/repository Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ use std::{borrow::Cow, io};
22
33use anyhow:: bail;
44
5- use gix:: { prelude :: ObjectIdExt , Tree } ;
5+ use gix:: Tree ;
66
77use crate :: OutputFormat ;
88
@@ -176,13 +176,10 @@ pub fn entries(
176176}
177177
178178fn treeish_to_tree < ' repo > ( treeish : Option < & str > , repo : & ' repo gix:: Repository ) -> anyhow:: Result < Tree < ' repo > > {
179- Ok ( match treeish {
180- Some ( hex) => gix:: hash:: ObjectId :: from_hex ( hex. as_bytes ( ) )
181- . map ( |id| id. attach ( repo) ) ?
182- . object ( ) ?
183- . try_into_tree ( ) ?,
184- None => repo. head ( ) ?. peel_to_commit_in_place ( ) ?. tree ( ) ?,
185- } )
179+ let spec = treeish
180+ . map ( |spec| format ! ( "{spec}^{{tree}}" ) )
181+ . unwrap_or_else ( || "@^{tree}" . into ( ) ) ;
182+ Ok ( repo. rev_parse_single ( spec. as_str ( ) ) ?. object ( ) ?. into_tree ( ) )
186183}
187184
188185fn format_entry (
Original file line number Diff line number Diff line change @@ -253,15 +253,15 @@ pub mod tree {
253253 #[ clap( long, short = 'e' ) ]
254254 extended : bool ,
255255
256- /// The tree to traverse, or the tree at `HEAD` if unspecified.
256+ /// The revspec of the tree to traverse, or the tree at `HEAD` if unspecified.
257257 treeish : Option < String > ,
258258 } ,
259259 /// Provide information about a tree.
260260 Info {
261261 /// Provide files size as well. This is expensive as the object is decoded entirely.
262262 #[ clap( long, short = 'e' ) ]
263263 extended : bool ,
264- /// The tree to traverse, or the tree at `HEAD` if unspecified.
264+ /// The revspec of the tree to traverse, or the tree at `HEAD` if unspecified.
265265 treeish : Option < String > ,
266266 } ,
267267 }
You can’t perform that action at this time.
0 commit comments