File tree 2 files changed +24
-0
lines changed
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,11 @@ bitflags! {
60
60
}
61
61
62
62
impl Flags {
63
+ /// Create a new instance whose stage is set to `stage`.
64
+ pub fn from_stage ( stage : Stage ) -> Self {
65
+ Flags :: from_bits ( ( stage as u32 ) << 12 ) . expect ( "stage can only be valid flags" )
66
+ }
67
+
63
68
/// Return the stage as extracted from the bits of this instance.
64
69
pub fn stage ( & self ) -> Stage {
65
70
match self . stage_raw ( ) {
@@ -96,6 +101,12 @@ impl Flags {
96
101
}
97
102
}
98
103
104
+ impl From < Stage > for Flags {
105
+ fn from ( value : Stage ) -> Self {
106
+ Flags :: from_stage ( value)
107
+ }
108
+ }
109
+
99
110
pub ( crate ) mod at_rest {
100
111
use bitflags:: bitflags;
101
112
Original file line number Diff line number Diff line change
1
+ mod flags {
2
+ use gix_index:: entry:: { Flags , Stage } ;
3
+
4
+ #[ test]
5
+ fn from_stage ( ) {
6
+ for stage in [ Stage :: Unconflicted , Stage :: Base , Stage :: Ours , Stage :: Theirs ] {
7
+ let actual = Flags :: from_stage ( stage) ;
8
+ assert_eq ! ( actual. stage( ) , stage) ;
9
+ let actual: Flags = stage. into ( ) ;
10
+ assert_eq ! ( actual. stage( ) , stage) ;
11
+ }
12
+ }
13
+ }
1
14
mod mode;
2
15
mod stat;
3
16
mod time;
You can’t perform that action at this time.
0 commit comments