Skip to content

Commit

Permalink
next/prev: move current_short variable closer to first use
Browse files Browse the repository at this point in the history
  • Loading branch information
martinvonz committed Feb 12, 2024
1 parent 7c5cfa7 commit c63d4ff
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cli/src/commands/next.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ pub(crate) fn cmd_next(
.get_wc_commit_id()
.ok_or_else(|| user_error("This command requires a working copy"))?;
let current_wc = workspace_command.repo().store().get_commit(current_wc_id)?;
let current_short = short_commit_hash(current_wc.id());
// If we're editing, start at the working-copy commit.
// Otherwise start from our direct parent.
let start_id = if edit {
Expand Down Expand Up @@ -140,6 +139,7 @@ pub(crate) fn cmd_next(
}
commits => choose_commit(ui, &workspace_command, "next", commits)?,
};
let current_short = short_commit_hash(current_wc.id());
let target_short = short_commit_hash(target.id());
// We're editing, just move to the target commit.
if edit {
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/prev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ pub(crate) fn cmd_prev(
.get_wc_commit_id()
.ok_or_else(|| user_error("This command requires a working copy"))?;
let current_wc = workspace_command.repo().store().get_commit(current_wc_id)?;
let current_short = short_commit_hash(current_wc.id());
let start_id = if edit {
current_wc_id
} else {
Expand Down Expand Up @@ -106,6 +105,7 @@ pub(crate) fn cmd_prev(
commits => choose_commit(ui, &workspace_command, "prev", commits)?,
};
// Generate a short commit hash, to make it readable in the op log.
let current_short = short_commit_hash(current_wc.id());
let target_short = short_commit_hash(target.id());
// If we're editing, just move to the revision directly.
if edit {
Expand Down

0 comments on commit c63d4ff

Please sign in to comment.