Skip to main content

Note

Struct Note 

Source
pub struct Note;
Expand description

Git-notes operations.

Implementations§

Source§

impl Note

Source

pub fn show(repo: &Repository, commit: &str) -> Option<String>

The note attached to commit, or None when there is none.

git notes show exits non-zero for a commit with no note, which is the ordinary case rather than a failure — hence Option, not Err. A caller opening an edit buffer wants an empty buffer there, not an error.

Source

pub fn set(repo: &Repository, commit: &str, text: &str) -> Result<()>

Write text as commit’s note, replacing any existing one.

-F - reads the note from stdin, the same seam crate::Index::apply_patch uses and for the same reasons: a temp file leaks on a crash and races a concurrent magit in the same repository. (It also does not work here — a first attempt wrote one and git reported “could not open or read” it.)

--force because this is “set”, not “add”: the buffer was seeded with the existing note, so refusing to overwrite would refuse every edit after the first.

Source

pub fn remove(repo: &Repository, commit: &str) -> Result<()>

Remove commit’s note.

--ignore-missing: removing a note that is not there is what the user asked for either way, and erroring would make “clear this buffer and save” fail on a commit that never had one.

Source

pub fn prune(repo: &Repository, dry_run: bool) -> Result<String>

Drop notes for objects that no longer exist.

dry_run reports what would go without removing anything — magit’s -n on this transient, and worth having because the operation is otherwise unreviewable.

Source

pub fn merge( repo: &Repository, from: &str, strategy: NoteMergeStrategy, ) -> Result<String>

Merge the notes ref from into the current notes ref.

With NoteMergeStrategy::Manual a conflict leaves the merge in progress; Self::merge_commit / Self::merge_abort finish it. The other strategies resolve without stopping.

Source

pub fn merge_commit(repo: &Repository) -> Result<()>

Commit a notes merge that stopped on a conflict.

Source

pub fn merge_abort(repo: &Repository) -> Result<()>

Abandon a notes merge that stopped on a conflict.

Source

pub fn merge_in_progress(gitdir: &Path) -> bool

Is a notes merge stopped mid-flight?

Git records one as NOTES_MERGE_REF in the gitdir. Checked so the menu can offer commit / abort only when they mean something — the same gating magit-notes does, and the same reason B bisect is gated (MG.21g): outside a merge git errors on both, so ungated rows would look actionable and fail.

Auto Trait Implementations§

§

impl Freeze for Note

§

impl RefUnwindSafe for Note

§

impl Send for Note

§

impl Sync for Note

§

impl Unpin for Note

§

impl UnsafeUnpin for Note

§

impl UnwindSafe for Note

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.