File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -1049,6 +1049,19 @@ pub enum FileMode {
10491049 Commit ,
10501050}
10511051
1052+ impl From < FileMode > for u32 {
1053+ fn from ( mode : FileMode ) -> u32 {
1054+ match mode {
1055+ FileMode :: Unreadable => raw:: GIT_FILEMODE_UNREADABLE as u32 ,
1056+ FileMode :: Tree => raw:: GIT_FILEMODE_TREE as u32 ,
1057+ FileMode :: Blob => raw:: GIT_FILEMODE_BLOB as u32 ,
1058+ FileMode :: BlobExecutable => raw:: GIT_FILEMODE_BLOB_EXECUTABLE as u32 ,
1059+ FileMode :: Link => raw:: GIT_FILEMODE_LINK as u32 ,
1060+ FileMode :: Commit => raw:: GIT_FILEMODE_COMMIT as u32 ,
1061+ }
1062+ }
1063+ }
1064+
10521065bitflags ! {
10531066 /// Return codes for submodule status.
10541067 ///
@@ -1441,12 +1454,18 @@ impl Default for ReferenceFormat {
14411454
14421455#[ cfg( test) ]
14431456mod tests {
1444- use super :: ObjectType ;
1457+ use super :: { FileMode , ObjectType } ;
14451458
14461459 #[ test]
14471460 fn convert ( ) {
14481461 assert_eq ! ( ObjectType :: Blob . str ( ) , "blob" ) ;
14491462 assert_eq ! ( ObjectType :: from_str( "blob" ) , Some ( ObjectType :: Blob ) ) ;
14501463 assert ! ( ObjectType :: Blob . is_loose( ) ) ;
14511464 }
1465+
1466+ #[ test]
1467+ fn convert_filemode ( ) {
1468+ assert_eq ! ( u32 :: from( FileMode :: Blob ) , 0o100644 ) ;
1469+ assert_eq ! ( u32 :: from( FileMode :: BlobExecutable ) , 0o100755 ) ;
1470+ }
14521471}
You can’t perform that action at this time.
0 commit comments