From 354ab4aef6c43076762e3ae8da9432839fba305c Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 10 Nov 2023 16:09:59 +0900 Subject: [PATCH] Inline-ish notes_dirty on the Rust side --- src/cinnabar-notes.c | 5 ----- src/cinnabar-notes.h | 2 -- src/libcinnabar.rs | 5 ++--- src/libgit.rs | 4 ++++ 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/cinnabar-notes.c b/src/cinnabar-notes.c index db84e95de..5a8c07552 100644 --- a/src/cinnabar-notes.c +++ b/src/cinnabar-notes.c @@ -109,11 +109,6 @@ const struct object_id *get_abbrev_note(struct cinnabar_notes_tree *t, return found ? &found->val_oid : NULL; } -int notes_dirty(struct cinnabar_notes_tree *notes) -{ - return notes->current.dirty || notes->additions.dirty; -} - int cinnabar_add_note( struct cinnabar_notes_tree *t, const struct object_id *object_oid, const struct object_id *note_oid) diff --git a/src/cinnabar-notes.h b/src/cinnabar-notes.h index 1b364e4e0..481621f66 100644 --- a/src/cinnabar-notes.h +++ b/src/cinnabar-notes.h @@ -25,8 +25,6 @@ struct cinnabar_notes_tree { #define for_each_note cinnabar_for_each_note #define write_notes_tree cinnabar_write_notes_tree -int notes_dirty(struct notes_tree *notes); - extern const struct object_id *get_abbrev_note( struct notes_tree *t, const struct object_id *object_oid, size_t len); diff --git a/src/libcinnabar.rs b/src/libcinnabar.rs index ccf8df765..ecb0897fd 100644 --- a/src/libcinnabar.rs +++ b/src/libcinnabar.rs @@ -176,8 +176,6 @@ extern "C" { fn cinnabar_remove_note(notes: *mut cinnabar_notes_tree, object_sha1: *const u8); - fn notes_dirty(notes: *const cinnabar_notes_tree) -> c_int; - fn cinnabar_write_notes_tree( notes: *mut cinnabar_notes_tree, result: *mut object_id, @@ -292,7 +290,8 @@ pub unsafe fn store_metadata_notes( ) -> CommitId { let mut result = object_id::default(); let mut tree = object_id::default(); - if notes_dirty(notes) != 0 { + let notes = notes.as_mut().unwrap(); + if notes.current.dirty() || notes.additions.dirty() { let mode = if ptr::eq(notes, &HG2GIT.0) { FileMode::GITLINK } else { diff --git a/src/libgit.rs b/src/libgit.rs index 08d9f9d72..074d0202d 100644 --- a/src/libgit.rs +++ b/src/libgit.rs @@ -1289,4 +1289,8 @@ impl notes_tree { pub const fn initialized(&self) -> bool { self.initialized != 0 } + + pub const fn dirty(&self) -> bool { + self.dirty != 0 + } }