pub struct Note;Expand description
Git-notes operations.
Implementations§
Source§impl Note
impl Note
Sourcepub fn show(repo: &Repository, commit: &str) -> Option<String>
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.
Sourcepub fn set(repo: &Repository, commit: &str, text: &str) -> Result<()>
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.
Sourcepub fn remove(repo: &Repository, commit: &str) -> Result<()>
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.
Sourcepub fn prune(repo: &Repository, dry_run: bool) -> Result<String>
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.
Sourcepub fn merge(
repo: &Repository,
from: &str,
strategy: NoteMergeStrategy,
) -> Result<String>
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.
Sourcepub fn merge_commit(repo: &Repository) -> Result<()>
pub fn merge_commit(repo: &Repository) -> Result<()>
Commit a notes merge that stopped on a conflict.
Sourcepub fn merge_abort(repo: &Repository) -> Result<()>
pub fn merge_abort(repo: &Repository) -> Result<()>
Abandon a notes merge that stopped on a conflict.
Sourcepub fn merge_in_progress(gitdir: &Path) -> bool
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.