Skip to content

Commit d92023d

Browse files
rcookehuss
authored andcommitted
Update to bitflags 2.1.0
1 parent 44d0ac3 commit d92023d

File tree

2 files changed

+88
-1
lines changed

2 files changed

+88
-1
lines changed

Diff for: Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ edition = "2018"
1717

1818
[dependencies]
1919
url = "2.0"
20-
bitflags = "1.1.0"
20+
bitflags = "2.1.0"
2121
libc = "0.2"
2222
log = "0.4.8"
2323
libgit2-sys = { path = "libgit2-sys", version = "0.16.0" }

Diff for: src/lib.rs

+87
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ pub enum FileFavor {
415415

416416
bitflags! {
417417
/// Orderings that may be specified for Revwalk iteration.
418+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
418419
pub struct Sort: u32 {
419420
/// Sort the repository contents in no particular ordering.
420421
///
@@ -449,6 +450,7 @@ impl Sort {
449450

450451
bitflags! {
451452
/// Types of credentials that can be requested by a credential callback.
453+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
452454
pub struct CredentialType: u32 {
453455
#[allow(missing_docs)]
454456
const USER_PASS_PLAINTEXT = raw::GIT_CREDTYPE_USERPASS_PLAINTEXT as u32;
@@ -485,6 +487,7 @@ impl Default for CredentialType {
485487

486488
bitflags! {
487489
/// Flags for the `flags` field of an IndexEntry.
490+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
488491
pub struct IndexEntryFlag: u16 {
489492
/// Set when the `extended_flags` field is valid.
490493
const EXTENDED = raw::GIT_INDEX_ENTRY_EXTENDED as u16;
@@ -500,6 +503,7 @@ impl IndexEntryFlag {
500503

501504
bitflags! {
502505
/// Flags for the `extended_flags` field of an IndexEntry.
506+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
503507
pub struct IndexEntryExtendedFlag: u16 {
504508
/// An "intent to add" entry from "git add -N"
505509
const INTENT_TO_ADD = raw::GIT_INDEX_ENTRY_INTENT_TO_ADD as u16;
@@ -519,6 +523,7 @@ impl IndexEntryExtendedFlag {
519523

520524
bitflags! {
521525
/// Flags for APIs that add files matching pathspec
526+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
522527
pub struct IndexAddOption: u32 {
523528
#[allow(missing_docs)]
524529
const DEFAULT = raw::GIT_INDEX_ADD_DEFAULT as u32;
@@ -550,6 +555,7 @@ impl Default for IndexAddOption {
550555

551556
bitflags! {
552557
/// Flags for `Repository::open_ext`
558+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
553559
pub struct RepositoryOpenFlags: u32 {
554560
/// Only open the specified path; don't walk upward searching.
555561
const NO_SEARCH = raw::GIT_REPOSITORY_OPEN_NO_SEARCH as u32;
@@ -574,6 +580,7 @@ impl RepositoryOpenFlags {
574580

575581
bitflags! {
576582
/// Flags for the return value of `Repository::revparse`
583+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
577584
pub struct RevparseMode: u32 {
578585
/// The spec targeted a single object
579586
const SINGLE = raw::GIT_REVPARSE_SINGLE as u32;
@@ -592,6 +599,7 @@ impl RevparseMode {
592599

593600
bitflags! {
594601
/// The results of `merge_analysis` indicating the merge opportunities.
602+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
595603
pub struct MergeAnalysis: u32 {
596604
/// No merge is possible.
597605
const ANALYSIS_NONE = raw::GIT_MERGE_ANALYSIS_NONE as u32;
@@ -622,6 +630,7 @@ impl MergeAnalysis {
622630

623631
bitflags! {
624632
/// The user's stated preference for merges.
633+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
625634
pub struct MergePreference: u32 {
626635
/// No configuration was found that suggests a preferred behavior for
627636
/// merge.
@@ -643,6 +652,7 @@ impl MergePreference {
643652

644653
bitflags! {
645654
/// Flags controlling the behavior of ODB lookup operations
655+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
646656
pub struct OdbLookupFlags: u32 {
647657
/// Don't call `git_odb_refresh` if the lookup fails. Useful when doing
648658
/// a batch of lookup operations for objects that may legitimately not
@@ -997,6 +1007,7 @@ bitflags! {
9971007
/// represents the status of file in the index relative to the HEAD, and the
9981008
/// `STATUS_WT_*` set of flags represent the status of the file in the
9991009
/// working directory relative to the index.
1010+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
10001011
pub struct Status: u32 {
10011012
#[allow(missing_docs)]
10021013
const CURRENT = raw::GIT_STATUS_CURRENT as u32;
@@ -1047,6 +1058,7 @@ impl Status {
10471058

10481059
bitflags! {
10491060
/// Mode options for RepositoryInitOptions
1061+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
10501062
pub struct RepositoryInitMode: u32 {
10511063
/// Use permissions configured by umask - the default
10521064
const SHARED_UMASK = raw::GIT_REPOSITORY_INIT_SHARED_UMASK as u32;
@@ -1179,6 +1191,7 @@ bitflags! {
11791191
/// Lastly, the following will only be returned for ignore "NONE".
11801192
///
11811193
/// * WD_UNTRACKED - workdir contains untracked files
1194+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
11821195
pub struct SubmoduleStatus: u32 {
11831196
#[allow(missing_docs)]
11841197
const IN_HEAD = raw::GIT_SUBMODULE_STATUS_IN_HEAD as u32;
@@ -1275,6 +1288,7 @@ pub enum SubmoduleUpdate {
12751288

12761289
bitflags! {
12771290
/// ...
1291+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
12781292
pub struct PathspecFlags: u32 {
12791293
/// Use the default pathspec matching configuration.
12801294
const DEFAULT = raw::GIT_PATHSPEC_DEFAULT as u32;
@@ -1320,6 +1334,7 @@ impl Default for PathspecFlags {
13201334

13211335
bitflags! {
13221336
/// Types of notifications emitted from checkouts.
1337+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
13231338
pub struct CheckoutNotificationType: u32 {
13241339
/// Notification about a conflict.
13251340
const CONFLICT = raw::GIT_CHECKOUT_NOTIFY_CONFLICT as u32;
@@ -1361,6 +1376,7 @@ pub enum DiffFormat {
13611376

13621377
bitflags! {
13631378
/// Formatting options for diff stats
1379+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
13641380
pub struct DiffStatsFormat: raw::git_diff_stats_format_t {
13651381
/// Don't generate any stats
13661382
const NONE = raw::GIT_DIFF_STATS_NONE;
@@ -1431,6 +1447,7 @@ pub enum StashApplyProgress {
14311447

14321448
bitflags! {
14331449
#[allow(missing_docs)]
1450+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
14341451
pub struct StashApplyFlags: u32 {
14351452
#[allow(missing_docs)]
14361453
const DEFAULT = raw::GIT_STASH_APPLY_DEFAULT as u32;
@@ -1453,6 +1470,7 @@ impl Default for StashApplyFlags {
14531470

14541471
bitflags! {
14551472
#[allow(missing_docs)]
1473+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
14561474
pub struct StashFlags: u32 {
14571475
#[allow(missing_docs)]
14581476
const DEFAULT = raw::GIT_STASH_DEFAULT as u32;
@@ -1485,6 +1503,7 @@ impl Default for StashFlags {
14851503

14861504
bitflags! {
14871505
#[allow(missing_docs)]
1506+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
14881507
pub struct AttrCheckFlags: u32 {
14891508
/// Check the working directory, then the index.
14901509
const FILE_THEN_INDEX = raw::GIT_ATTR_CHECK_FILE_THEN_INDEX as u32;
@@ -1505,6 +1524,7 @@ impl Default for AttrCheckFlags {
15051524

15061525
bitflags! {
15071526
#[allow(missing_docs)]
1527+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
15081528
pub struct DiffFlags: u32 {
15091529
/// File(s) treated as binary data.
15101530
const BINARY = raw::GIT_DIFF_FLAG_BINARY as u32;
@@ -1526,6 +1546,7 @@ impl DiffFlags {
15261546

15271547
bitflags! {
15281548
/// Options for [`Reference::normalize_name`].
1549+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
15291550
pub struct ReferenceFormat: u32 {
15301551
/// No particular normalization.
15311552
const NORMAL = raw::GIT_REFERENCE_FORMAT_NORMAL as u32;
@@ -1578,4 +1599,70 @@ mod tests {
15781599
assert_eq!(u32::from(FileMode::BlobGroupWritable), 0o100664);
15791600
assert_eq!(u32::from(FileMode::BlobExecutable), 0o100755);
15801601
}
1602+
1603+
#[test]
1604+
fn bitflags_partial_eq() {
1605+
use super::{
1606+
AttrCheckFlags, CheckoutNotificationType, CredentialType, DiffFlags, DiffStatsFormat,
1607+
IndexAddOption, IndexEntryExtendedFlag, IndexEntryFlag, MergeAnalysis, MergePreference,
1608+
OdbLookupFlags, PathspecFlags, ReferenceFormat, RepositoryInitMode,
1609+
RepositoryOpenFlags, RevparseMode, Sort, StashApplyFlags, StashFlags, Status,
1610+
SubmoduleStatus,
1611+
};
1612+
1613+
assert_eq!(
1614+
AttrCheckFlags::FILE_THEN_INDEX,
1615+
AttrCheckFlags::FILE_THEN_INDEX
1616+
);
1617+
assert_eq!(
1618+
CheckoutNotificationType::CONFLICT,
1619+
CheckoutNotificationType::CONFLICT
1620+
);
1621+
assert_eq!(
1622+
CredentialType::USER_PASS_PLAINTEXT,
1623+
CredentialType::USER_PASS_PLAINTEXT
1624+
);
1625+
assert_eq!(DiffFlags::BINARY, DiffFlags::BINARY);
1626+
assert_eq!(
1627+
DiffStatsFormat::INCLUDE_SUMMARY,
1628+
DiffStatsFormat::INCLUDE_SUMMARY
1629+
);
1630+
assert_eq!(
1631+
IndexAddOption::CHECK_PATHSPEC,
1632+
IndexAddOption::CHECK_PATHSPEC
1633+
);
1634+
assert_eq!(
1635+
IndexEntryExtendedFlag::INTENT_TO_ADD,
1636+
IndexEntryExtendedFlag::INTENT_TO_ADD
1637+
);
1638+
assert_eq!(IndexEntryFlag::EXTENDED, IndexEntryFlag::EXTENDED);
1639+
assert_eq!(
1640+
MergeAnalysis::ANALYSIS_FASTFORWARD,
1641+
MergeAnalysis::ANALYSIS_FASTFORWARD
1642+
);
1643+
assert_eq!(
1644+
MergePreference::FASTFORWARD_ONLY,
1645+
MergePreference::FASTFORWARD_ONLY
1646+
);
1647+
assert_eq!(OdbLookupFlags::NO_REFRESH, OdbLookupFlags::NO_REFRESH);
1648+
assert_eq!(PathspecFlags::FAILURES_ONLY, PathspecFlags::FAILURES_ONLY);
1649+
assert_eq!(
1650+
ReferenceFormat::ALLOW_ONELEVEL,
1651+
ReferenceFormat::ALLOW_ONELEVEL
1652+
);
1653+
assert_eq!(
1654+
RepositoryInitMode::SHARED_ALL,
1655+
RepositoryInitMode::SHARED_ALL
1656+
);
1657+
assert_eq!(RepositoryOpenFlags::CROSS_FS, RepositoryOpenFlags::CROSS_FS);
1658+
assert_eq!(RevparseMode::RANGE, RevparseMode::RANGE);
1659+
assert_eq!(Sort::REVERSE, Sort::REVERSE);
1660+
assert_eq!(
1661+
StashApplyFlags::REINSTATE_INDEX,
1662+
StashApplyFlags::REINSTATE_INDEX
1663+
);
1664+
assert_eq!(StashFlags::INCLUDE_IGNORED, StashFlags::INCLUDE_IGNORED);
1665+
assert_eq!(Status::WT_MODIFIED, Status::WT_MODIFIED);
1666+
assert_eq!(SubmoduleStatus::WD_ADDED, SubmoduleStatus::WD_ADDED);
1667+
}
15811668
}

0 commit comments

Comments
 (0)