mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-02 09:28:40 +00:00
repo: inline single-caller, and surprising, Commit::is_empty()
I would expect `Commit::is_empty()` to check if the commit is empty in our usual sense, i.e. that there are no changes compared to the auto-merged parents. However, it would return `false` for any merge commit (and for the root commit). Since we only use it in one place, let's inline it there. The use there does seem reasonable, because it's about abandoning an "uninteresting" working-copy commit.
This commit is contained in:
parent
615862dde8
commit
aaf75b4793
2 changed files with 2 additions and 7 deletions
|
@ -117,12 +117,6 @@ impl Commit {
|
|||
&self.data
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
let parents = self.parents();
|
||||
// TODO: Perhaps the root commit should also be considered empty.
|
||||
parents.len() == 1 && parents[0].tree_id() == self.tree_id()
|
||||
}
|
||||
|
||||
pub fn description(&self) -> &str {
|
||||
&self.data.description
|
||||
}
|
||||
|
|
|
@ -835,7 +835,8 @@ impl MutableRepo {
|
|||
.store()
|
||||
.get_commit(&wc_commit_id)
|
||||
.map_err(EditCommitError::WorkingCopyCommitNotFound)?;
|
||||
if wc_commit.is_empty()
|
||||
if wc_commit.parent_ids().len() == 1
|
||||
&& wc_commit.parents()[0].tree_id() == wc_commit.tree_id()
|
||||
&& wc_commit.description().is_empty()
|
||||
&& self.view().heads().contains(wc_commit.id())
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue