File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -34,9 +34,24 @@ pub fn process_cmdline() -> Result<CliArgs> {
34
34
35
35
let workdir =
36
36
arg_matches. get_one :: < String > ( "workdir" ) . map ( PathBuf :: from) ;
37
- let gitdir = arg_matches
38
- . get_one :: < String > ( "directory" )
39
- . map_or_else ( || PathBuf :: from ( "." ) , PathBuf :: from) ;
37
+ let gitdir = ' blk: {
38
+ let mut cwd = env:: current_dir ( ) ?;
39
+ let cwd_file_name = cwd
40
+ . file_name ( )
41
+ . ok_or ( anyhow ! ( "Coulden't get the CWD name" ) ) ?
42
+ . as_encoded_bytes ( ) ;
43
+ if cwd_file_name == b".git" {
44
+ cwd = cwd
45
+ . parent ( )
46
+ . ok_or ( anyhow ! (
47
+ "Coulden't find the parent directory of .git"
48
+ ) ) ?
49
+ . to_path_buf ( ) ;
50
+ }
51
+ break ' blk arg_matches
52
+ . get_one :: < String > ( "directory" )
53
+ . map_or_else ( || cwd, PathBuf :: from) ;
54
+ } ;
40
55
41
56
let repo_path = if let Some ( w) = workdir {
42
57
RepoPath :: Workdir { gitdir, workdir : w }
You can’t perform that action at this time.
0 commit comments