File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,11 @@ bitflags! {
6060}
6161
6262impl 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+
6368 /// Return the stage as extracted from the bits of this instance.
6469 pub fn stage ( & self ) -> Stage {
6570 match self . stage_raw ( ) {
@@ -96,6 +101,12 @@ impl Flags {
96101 }
97102}
98103
104+ impl From < Stage > for Flags {
105+ fn from ( value : Stage ) -> Self {
106+ Flags :: from_stage ( value)
107+ }
108+ }
109+
99110pub ( crate ) mod at_rest {
100111 use bitflags:: bitflags;
101112
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+ }
114mod mode;
215mod stat;
316mod time;
You can’t perform that action at this time.
0 commit comments