Skip to content

Commit c87f946

Browse files
committed
Use peel_to_commit()
1 parent 22d8a47 commit c87f946

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/cmd/uncommit.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,8 @@ fn run(matches: &ArgMatches) -> Result<()> {
102102
.map_err(|_| anyhow!("Invalid committish `{committish}`"))?;
103103

104104
let mut target_commit = target_object
105-
.peel(git2::ObjectType::Commit).ok()
106-
.and_then(|c| c.into_commit().ok())
107-
.ok_or_else(|| anyhow!("Target `{committish}` cannot be evaluated as a commit"))?;
105+
.peel_to_commit()
106+
.map_err(|_| anyhow!("Target `{committish}` does not resolve to a commit"))?;
108107

109108
let bases = repo.merge_bases(target_commit.id(), stack.base().id())?;
110109

t/t1300-uncommit.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ test_expect_success 'Uncommit when top != head' '
145145

146146
test_expect_success 'Uncommit to something that does not resolve to a commit' '
147147
command_error stg uncommit --to HEAD^{tree} 2>err &&
148-
grep -e "error: Target \`HEAD^{tree}\` cannot be evaluated as a commit" err
148+
grep -e "error: Target \`HEAD^{tree}\` does not resolve to a commit" err
149149
'
150150

151151
test_expect_success 'Uncommit to an annotated tag' '

0 commit comments

Comments
 (0)