File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,13 @@ pub struct Commit {
20
20
impl Commit {
21
21
pub fn rev_parse ( what : & str ) -> Result < Self , Error > {
22
22
let output = Command :: new ( "git" )
23
- . args ( [ "show" , "-s" , "--format=%H%x00%h%x00%ci" , what] )
23
+ . args ( [
24
+ "--git-dir=.git" ,
25
+ "show" ,
26
+ "-s" ,
27
+ "--format=%H%x00%h%x00%ci" ,
28
+ what,
29
+ ] )
24
30
. stderr ( Stdio :: inherit ( ) )
25
31
. stdin ( Stdio :: null ( ) )
26
32
. output ( )
@@ -31,15 +37,18 @@ impl Commit {
31
37
output. status
32
38
) ) ) ;
33
39
}
34
- let info = String :: from_utf8 ( output. stdout ) . expect ( "Commit info is not valid UTF-8??" ) ;
40
+ let mut info = String :: from_utf8 ( output. stdout ) . expect ( "Commit info is not valid UTF-8??" ) ;
41
+ let trimmed_len = info. trim_end ( ) . len ( ) ;
42
+ info. truncate ( trimmed_len) ;
35
43
36
44
let first_split = info
37
45
. find ( '\0' )
38
46
. expect ( "Failed to split hash and short hash" ) ;
39
47
let second_split = info[ first_split + 1 ..]
40
48
. find ( '\0' )
41
49
. expect ( "Failed to split short hash and timestamp" )
42
- + first_split;
50
+ + first_split
51
+ + 1 ;
43
52
44
53
Ok ( Self {
45
54
info,
You can’t perform that action at this time.
0 commit comments