Skip to content

Commit 6532a79

Browse files
committed
Update to bitflags 2.1.0
1 parent 88c67f7 commit 6532a79

File tree

3 files changed

+57
-3
lines changed

3 files changed

+57
-3
lines changed

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.15.1" }

src/lib.rs

+54
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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(PartialEq)]
14561474
pub struct StashFlags: u32 {
14571475
#[allow(missing_docs)]
14581476
const DEFAULT = raw::GIT_STASH_DEFAULT as u32;
@@ -1483,6 +1501,7 @@ impl Default for StashFlags {
14831501

14841502
bitflags! {
14851503
#[allow(missing_docs)]
1504+
#[derive(PartialEq)]
14861505
pub struct AttrCheckFlags: u32 {
14871506
/// Check the working directory, then the index.
14881507
const FILE_THEN_INDEX = raw::GIT_ATTR_CHECK_FILE_THEN_INDEX as u32;
@@ -1503,6 +1522,7 @@ impl Default for AttrCheckFlags {
15031522

15041523
bitflags! {
15051524
#[allow(missing_docs)]
1525+
#[derive(PartialEq)]
15061526
pub struct DiffFlags: u32 {
15071527
/// File(s) treated as binary data.
15081528
const BINARY = raw::GIT_DIFF_FLAG_BINARY as u32;
@@ -1524,6 +1544,7 @@ impl DiffFlags {
15241544

15251545
bitflags! {
15261546
/// Options for [`Reference::normalize_name`].
1547+
#[derive(PartialEq)]
15271548
pub struct ReferenceFormat: u32 {
15281549
/// No particular normalization.
15291550
const NORMAL = raw::GIT_REFERENCE_FORMAT_NORMAL as u32;
@@ -1576,4 +1597,37 @@ mod tests {
15761597
assert_eq!(u32::from(FileMode::BlobGroupWritable), 0o100664);
15771598
assert_eq!(u32::from(FileMode::BlobExecutable), 0o100755);
15781599
}
1600+
1601+
#[test]
1602+
fn bitflags_partial_eq() {
1603+
use super::{
1604+
AttrCheckFlags, CheckoutNotificationType, CredentialType, DiffFlags, DiffStatsFormat,
1605+
IndexAddOption, IndexEntryExtendedFlag, IndexEntryFlag, MergeAnalysis, MergePreference,
1606+
OdbLookupFlags, PathspecFlags, ReferenceFormat, RepositoryInitMode,
1607+
RepositoryOpenFlags, RevparseMode, Sort, StashApplyFlags, StashFlags, Status,
1608+
SubmoduleStatus,
1609+
};
1610+
1611+
assert!(AttrCheckFlags::FILE_THEN_INDEX == AttrCheckFlags::FILE_THEN_INDEX);
1612+
assert!(CheckoutNotificationType::CONFLICT == CheckoutNotificationType::CONFLICT);
1613+
assert!(CredentialType::USER_PASS_PLAINTEXT == CredentialType::USER_PASS_PLAINTEXT);
1614+
assert!(DiffFlags::BINARY == DiffFlags::BINARY);
1615+
assert!(DiffStatsFormat::INCLUDE_SUMMARY == DiffStatsFormat::INCLUDE_SUMMARY);
1616+
assert!(IndexAddOption::CHECK_PATHSPEC == IndexAddOption::CHECK_PATHSPEC);
1617+
assert!(IndexEntryExtendedFlag::INTENT_TO_ADD == IndexEntryExtendedFlag::INTENT_TO_ADD);
1618+
assert!(IndexEntryFlag::EXTENDED == IndexEntryFlag::EXTENDED);
1619+
assert!(MergeAnalysis::ANALYSIS_FASTFORWARD == MergeAnalysis::ANALYSIS_FASTFORWARD);
1620+
assert!(MergePreference::FASTFORWARD_ONLY == MergePreference::FASTFORWARD_ONLY);
1621+
assert!(OdbLookupFlags::NO_REFRESH == OdbLookupFlags::NO_REFRESH);
1622+
assert!(PathspecFlags::FAILURES_ONLY == PathspecFlags::FAILURES_ONLY);
1623+
assert!(ReferenceFormat::ALLOW_ONELEVEL == ReferenceFormat::ALLOW_ONELEVEL);
1624+
assert!(RepositoryInitMode::SHARED_ALL == RepositoryInitMode::SHARED_ALL);
1625+
assert!(RepositoryOpenFlags::CROSS_FS == RepositoryOpenFlags::CROSS_FS);
1626+
assert!(RevparseMode::RANGE == RevparseMode::RANGE);
1627+
assert!(Sort::REVERSE == Sort::REVERSE);
1628+
assert!(StashApplyFlags::REINSTATE_INDEX == StashApplyFlags::REINSTATE_INDEX);
1629+
assert!(StashFlags::INCLUDE_IGNORED == StashFlags::INCLUDE_IGNORED);
1630+
assert!(Status::WT_MODIFIED == Status::WT_MODIFIED);
1631+
assert!(SubmoduleStatus::WD_ADDED == SubmoduleStatus::WD_ADDED);
1632+
}
15791633
}

src/revspec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl<'repo> Revspec<'repo> {
2828
}
2929

3030
/// Returns the intent of the revspec.
31-
pub fn mode(&self) -> RevparseMode {
32-
self.mode
31+
pub fn mode(&self) -> &RevparseMode {
32+
&self.mode
3333
}
3434
}

0 commit comments

Comments
 (0)