diff --git a/cli/src/commands/git/push.rs b/cli/src/commands/git/push.rs index 40596b65aa7..f93c1225d89 100644 --- a/cli/src/commands/git/push.rs +++ b/cli/src/commands/git/push.rs @@ -467,12 +467,12 @@ fn update_change_branches( for change_arg in changes { let workspace_command = tx.base_workspace_helper(); let commit = workspace_command.resolve_single_rev(change_arg)?; + let short_change_id = short_change_hash(commit.change_id()); let mut branch_name = format!("{branch_prefix}{}", commit.change_id().hex()); let view = tx.base_repo().view(); if view.get_local_branch(&branch_name).is_absent() { // A local branch with the full change ID doesn't exist already, so use the // short ID if it's not ambiguous (which it shouldn't be most of the time). - let short_change_id = short_change_hash(commit.change_id()); if workspace_command .resolve_single_rev(&RevisionArg::from(short_change_id.clone())) .is_ok() @@ -484,7 +484,7 @@ fn update_change_branches( if view.get_local_branch(&branch_name).is_absent() { writeln!( ui.status(), - "Creating branch {branch_name} for revision {change_arg}", + "Creating branch {branch_name} for revision {short_change_id}", )?; } tx.mut_repo() diff --git a/cli/tests/test_git_push.rs b/cli/tests/test_git_push.rs index 9e3b01ce25b..c5b709d5feb 100644 --- a/cli/tests/test_git_push.rs +++ b/cli/tests/test_git_push.rs @@ -580,7 +580,7 @@ fn test_git_push_changes() { let (stdout, stderr) = test_env.jj_cmd_ok(&workspace_root, &["git", "push", "--change", "@"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###" - Creating branch push-yostqsxwqrlt for revision @ + Creating branch push-yostqsxwqrlt for revision yostqsxwqrlt Branch changes to push to origin: Add branch push-yostqsxwqrlt to 28d7620ea63a "###); @@ -589,7 +589,7 @@ fn test_git_push_changes() { let (stdout, stderr) = test_env.jj_cmd_ok(&workspace_root, &["git", "push", "-c=@", "-c=@-"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###" - Creating branch push-yqosqzytrlsw for revision @- + Creating branch push-yqosqzytrlsw for revision yqosqzytrlsw Branch changes to push to origin: Move sideways branch push-yostqsxwqrlt from 28d7620ea63a to 48d8c7948133 Add branch push-yqosqzytrlsw to fa16a14170fb @@ -664,7 +664,7 @@ fn test_git_push_changes() { ); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###" - Creating branch test-yostqsxwqrlt for revision @ + Creating branch test-yostqsxwqrlt for revision yostqsxwqrlt Branch changes to push to origin: Add branch test-yostqsxwqrlt to 3e2ce808759b "###); @@ -759,7 +759,7 @@ fn test_git_push_mixed() { ); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###" - Creating branch push-yqosqzytrlsw for revision @-- + Creating branch push-yqosqzytrlsw for revision yqosqzytrlsw Branch changes to push to origin: Add branch push-yqosqzytrlsw to fa16a14170fb Add branch branch-1 to 7decc7932d9c