|
1 | 1 | use bstr::BStr; |
2 | 2 | use filetime::{set_file_mtime, FileTime}; |
3 | | -use gix_features::threading::OwnShared; |
4 | 3 | use gix_index as index; |
5 | 4 | use gix_index::Entry; |
6 | 5 | use gix_utils::FilesystemCapabilities; |
7 | 6 | use gix_worktree::index::status::content::{FastEq, ReadDataOnce}; |
8 | 7 | use gix_worktree::index::status::worktree::{self, Options}; |
9 | 8 | use gix_worktree::index::status::{Change, CompareBlobs, Recorder}; |
10 | 9 | use std::sync::atomic::{AtomicUsize, Ordering}; |
| 10 | +use std::sync::Arc; |
11 | 11 |
|
12 | 12 | use crate::fixture_path; |
13 | 13 |
|
@@ -57,45 +57,36 @@ fn removed() { |
57 | 57 | ); |
58 | 58 | } |
59 | 59 |
|
| 60 | +#[test] |
| 61 | +fn intent_to_add() { |
| 62 | + fixture( |
| 63 | + "status_intent_to_add", |
| 64 | + &[(BStr::new(b"content"), Some(Change::IntentToAdd), false)], |
| 65 | + ); |
| 66 | +} |
| 67 | + |
| 68 | +#[test] |
| 69 | +fn conflict() { |
| 70 | + fixture( |
| 71 | + "status_conflict", |
| 72 | + &[( |
| 73 | + BStr::new(b"content"), |
| 74 | + Some(Change::Modification { |
| 75 | + executable_bit_changed: false, |
| 76 | + content_change: Some(()), |
| 77 | + }), |
| 78 | + true, |
| 79 | + )], |
| 80 | + ); |
| 81 | +} |
| 82 | + |
60 | 83 | #[test] |
61 | 84 | fn unchanged() { |
62 | 85 | fixture("status_unchanged", &[]); |
63 | 86 | } |
64 | 87 |
|
65 | 88 | #[test] |
66 | 89 | fn modified() { |
67 | | - // run the same status check twice to ensure that racy detection |
68 | | - // doesn't change the result of the status check |
69 | | - fixture( |
70 | | - "status_changed", |
71 | | - &[ |
72 | | - ( |
73 | | - BStr::new(b"dir/content"), |
74 | | - Some(Change::Modification { |
75 | | - executable_bit_changed: true, |
76 | | - content_change: None, |
77 | | - }), |
78 | | - false, |
79 | | - ), |
80 | | - ( |
81 | | - BStr::new(b"dir/content2"), |
82 | | - Some(Change::Modification { |
83 | | - executable_bit_changed: false, |
84 | | - content_change: Some(()), |
85 | | - }), |
86 | | - false, |
87 | | - ), |
88 | | - (BStr::new(b"empty"), Some(Change::Type), false), |
89 | | - ( |
90 | | - BStr::new(b"executable"), |
91 | | - Some(Change::Modification { |
92 | | - executable_bit_changed: true, |
93 | | - content_change: Some(()), |
94 | | - }), |
95 | | - false, |
96 | | - ), |
97 | | - ], |
98 | | - ); |
99 | 90 | fixture( |
100 | 91 | "status_changed", |
101 | 92 | &[ |
@@ -141,7 +132,7 @@ fn racy_git() { |
141 | 132 | let mut index = gix_index::File::at(git_dir.join("index"), gix_hash::Kind::Sha1, Default::default()).unwrap(); |
142 | 133 |
|
143 | 134 | #[derive(Clone)] |
144 | | - struct CountCalls(OwnShared<AtomicUsize>, FastEq); |
| 135 | + struct CountCalls(Arc<AtomicUsize>, FastEq); |
145 | 136 | impl CompareBlobs for CountCalls { |
146 | 137 | type Output = (); |
147 | 138 |
|
@@ -169,7 +160,7 @@ fn racy_git() { |
169 | 160 | .expect("changing filetime works"); |
170 | 161 | let mut recorder = Recorder::default(); |
171 | 162 |
|
172 | | - let count = OwnShared::new(AtomicUsize::new(0)); |
| 163 | + let count = Arc::new(AtomicUsize::new(0)); |
173 | 164 | let counter = CountCalls(count.clone(), FastEq); |
174 | 165 | worktree::changes_to_obtain( |
175 | 166 | &mut index, |
|
0 commit comments