@@ -45,27 +45,30 @@ impl crate::Repository {
45
45
/// Note that there may be `None` if there is no work tree, even though the `PathBuf` will be empty
46
46
/// if the CWD is at the root of the work tree.
47
47
// TODO: tests, details - there is a lot about environment variables to change things around.
48
- pub fn prefix ( & self ) -> Option < std:: io:: Result < PathBuf > > {
49
- self . work_tree . as_ref ( ) . map ( |root| {
50
- std:: env:: current_dir ( ) . and_then ( |cwd| {
51
- gix_path:: realpath_opts ( root, & cwd, MAX_SYMLINKS )
52
- . map_err ( |err| std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , err) )
53
- . and_then ( |root| {
54
- cwd. strip_prefix ( & root)
55
- . map_err ( |_| {
56
- std:: io:: Error :: new (
57
- std:: io:: ErrorKind :: Other ,
58
- format ! (
59
- "CWD '{}' isn't within the work tree '{}'" ,
60
- cwd. display( ) ,
61
- root. display( )
62
- ) ,
63
- )
64
- } )
65
- . map ( ToOwned :: to_owned)
66
- } )
48
+ pub fn prefix ( & self ) -> std:: io:: Result < Option < PathBuf > > {
49
+ self . work_tree
50
+ . as_ref ( )
51
+ . map ( |root| {
52
+ std:: env:: current_dir ( ) . and_then ( |cwd| {
53
+ gix_path:: realpath_opts ( root, & cwd, MAX_SYMLINKS )
54
+ . map_err ( |err| std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , err) )
55
+ . and_then ( |root| {
56
+ cwd. strip_prefix ( & root)
57
+ . map_err ( |_| {
58
+ std:: io:: Error :: new (
59
+ std:: io:: ErrorKind :: Other ,
60
+ format ! (
61
+ "CWD '{}' isn't within the work tree '{}'" ,
62
+ cwd. display( ) ,
63
+ root. display( )
64
+ ) ,
65
+ )
66
+ } )
67
+ . map ( ToOwned :: to_owned)
68
+ } )
69
+ } )
67
70
} )
68
- } )
71
+ . transpose ( )
69
72
}
70
73
71
74
/// Return the kind of repository, either bare or one with a work tree.
0 commit comments