Skip to content

Commit 7db74c6

Browse files
committed
Use qualified git2 symbols in transaction.rs
The goal is to make it a bit more obvious where all the git2 dependencies lie.
1 parent 6af0292 commit 7db74c6

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/stack/transaction.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ use std::collections::BTreeMap;
3131
use std::io::Write;
3232

3333
use anyhow::{anyhow, Result};
34-
use git2::{Commit, Oid};
3534
use indexmap::IndexSet;
3635
use termcolor::WriteColor;
3736

@@ -85,9 +84,9 @@ pub(crate) struct StackTransaction<'repo> {
8584
applied: Vec<PatchName>,
8685
unapplied: Vec<PatchName>,
8786
hidden: Vec<PatchName>,
88-
updated_head: Option<Commit<'repo>>,
89-
updated_base: Option<Commit<'repo>>,
90-
current_tree_id: Oid,
87+
updated_head: Option<git2::Commit<'repo>>,
88+
updated_base: Option<git2::Commit<'repo>>,
89+
current_tree_id: git2::Oid,
9190
error: Option<anyhow::Error>,
9291
printed_top: bool,
9392
}
@@ -419,7 +418,7 @@ impl<'repo> ExecuteContext<'repo> {
419418
}
420419

421420
impl<'repo> StackTransaction<'repo> {
422-
fn checkout(&mut self, commit: &Commit<'_>) -> Result<()> {
421+
fn checkout(&mut self, commit: &git2::Commit<'_>) -> Result<()> {
423422
let repo = self.stack.repo;
424423
if !self.options.allow_bad_head {
425424
self.stack.check_head_top_mismatch()?;
@@ -571,7 +570,11 @@ impl<'repo> StackTransaction<'repo> {
571570
///
572571
/// Any notes associated with the patch's previous commit are copied to the new
573572
/// commit.
574-
pub(crate) fn update_patch(&mut self, patchname: &PatchName, commit_id: Oid) -> Result<()> {
573+
pub(crate) fn update_patch(
574+
&mut self,
575+
patchname: &PatchName,
576+
commit_id: git2::Oid,
577+
) -> Result<()> {
575578
let commit = self.stack.repo.find_commit(commit_id)?;
576579
let old_commit = self.get_patch_commit(patchname);
577580
// Failure to copy is okay. The old commit may not have a note to copy.
@@ -590,7 +593,7 @@ impl<'repo> StackTransaction<'repo> {
590593
///
591594
/// The commit for the new patch must be parented by the former top commit of the
592595
/// stack.
593-
pub(crate) fn new_applied(&mut self, patchname: &PatchName, oid: Oid) -> Result<()> {
596+
pub(crate) fn new_applied(&mut self, patchname: &PatchName, oid: git2::Oid) -> Result<()> {
594597
let commit = self.stack.repo.find_commit(oid)?;
595598
assert_eq!(commit.parent_id(0).unwrap(), self.top().id());
596599
self.applied.push(patchname.clone());
@@ -606,7 +609,7 @@ impl<'repo> StackTransaction<'repo> {
606609
pub(crate) fn new_unapplied(
607610
&mut self,
608611
patchname: &PatchName,
609-
commit_id: Oid,
612+
commit_id: git2::Oid,
610613
insert_pos: usize,
611614
) -> Result<()> {
612615
let commit = self.stack.repo.find_commit(commit_id)?;
@@ -1470,23 +1473,23 @@ impl<'repo> StackStateAccess<'repo> for StackTransaction<'repo> {
14701473
}
14711474
}
14721475

1473-
fn top(&self) -> &Commit<'repo> {
1476+
fn top(&self) -> &git2::Commit<'repo> {
14741477
if let Some(patchname) = self.applied.last() {
14751478
self.get_patch_commit(patchname)
14761479
} else {
14771480
self.base()
14781481
}
14791482
}
14801483

1481-
fn head(&self) -> &Commit<'repo> {
1484+
fn head(&self) -> &git2::Commit<'repo> {
14821485
if let Some(commit) = self.updated_head.as_ref() {
14831486
commit
14841487
} else {
14851488
self.top()
14861489
}
14871490
}
14881491

1489-
fn base(&self) -> &Commit<'repo> {
1492+
fn base(&self) -> &git2::Commit<'repo> {
14901493
if let Some(commit) = self.updated_base.as_ref() {
14911494
commit
14921495
} else {

0 commit comments

Comments
 (0)