Skip to content

Commit 6cd8b46

Browse files
authored
Merge pull request #1455 from joshtriplett/portable-atomic-only-when-needed
Pull in portable-atomic only when needed
2 parents 9ff9642 + 27653cf commit 6cd8b46

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

gix-status/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ gix-diff = { version = "^0.44.0", path = "../gix-diff", default-features = false
3434
thiserror = "1.0.26"
3535
filetime = "0.2.15"
3636
bstr = { version = "1.3.0", default-features = false }
37-
portable-atomic = "1"
3837

3938
document-features = { version = "0.2.0", optional = true }
4039

40+
[target.'cfg(not(target_has_atomic = "64"))'.dependencies]
41+
portable-atomic = "1"
42+
4143
[package.metadata.docs.rs]
4244
features = ["document-features", "worktree-rewrites"]

gix-status/src/index_as_worktree/function.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ use std::{
55
sync::atomic::{AtomicUsize, Ordering},
66
};
77

8-
#[cfg(target_has_atomic = "64")]
9-
use std::sync::atomic::AtomicU64;
10-
11-
#[cfg(not(target_has_atomic = "64"))]
12-
use portable_atomic::AtomicU64;
13-
148
use bstr::BStr;
159
use filetime::FileTime;
1610
use gix_features::parallel::{in_parallel_if, Reduce};
@@ -25,7 +19,7 @@ use crate::{
2519
types::{Error, Options},
2620
Change, Conflict, EntryStatus, Outcome, VisitEntry,
2721
},
28-
is_dir_to_mode, SymlinkCheck,
22+
is_dir_to_mode, AtomicU64, SymlinkCheck,
2923
};
3024

3125
/// Calculates the changes that need to be applied to an `index` to match the state of the `worktree` and makes them

gix-status/src/index_as_worktree/traits.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,12 @@ pub trait ReadData<'a> {
5252
///
5353
#[allow(clippy::empty_docs)]
5454
pub mod read_data {
55-
#[cfg(target_has_atomic = "64")]
56-
use std::sync::atomic::AtomicU64;
5755
use std::sync::atomic::Ordering;
5856

59-
#[cfg(not(target_has_atomic = "64"))]
60-
use portable_atomic::AtomicU64;
61-
6257
use gix_filter::pipeline::convert::ToGitOutcome;
6358

59+
use crate::AtomicU64;
60+
6461
/// A stream with worktree file data.
6562
pub struct Stream<'a> {
6663
pub(crate) inner: ToGitOutcome<'a, std::fs::File>,

gix-status/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
#![cfg_attr(all(doc, feature = "document-features"), feature(doc_cfg, doc_auto_cfg))]
1616
#![deny(missing_docs, rust_2018_idioms, unsafe_code)]
1717

18+
#[cfg(target_has_atomic = "64")]
19+
use std::sync::atomic::AtomicU64;
20+
21+
#[cfg(not(target_has_atomic = "64"))]
22+
use portable_atomic::AtomicU64;
23+
1824
pub mod index_as_worktree;
1925
pub use index_as_worktree::function::index_as_worktree;
2026

0 commit comments

Comments
 (0)