diff --git a/cli/src/commands/git.rs b/cli/src/commands/git.rs index 235414f09..a062a483b 100644 --- a/cli/src/commands/git.rs +++ b/cli/src/commands/git.rs @@ -780,11 +780,20 @@ fn cmd_git_push( Err(reason) => reason.print(ui)?, } } - if (!args.revisions.is_empty() || use_default_revset) && branches_targeted.is_empty() { - writeln!( - ui.warning(), - "No branches point to the specified revisions." - )?; + if branches_targeted.is_empty() { + if use_default_revset { + writeln!( + ui.warning(), + "No branches found in the default push revset, \ + `remote_branches(remote={remote})..@`." + )?; + } else if !args.revisions.is_empty() { + writeln!( + ui.warning(), + "No branches point to the specified revisions." + )?; + } else { /* A plain "Nothing changed" message will suffice */ + } } tx_description = format!( diff --git a/cli/tests/test_git_push.rs b/cli/tests/test_git_push.rs index ecc1679ee..ec44760c8 100644 --- a/cli/tests/test_git_push.rs +++ b/cli/tests/test_git_push.rs @@ -135,7 +135,7 @@ fn test_git_push_no_matching_branch() { let (stdout, stderr) = test_env.jj_cmd_ok(&workspace_root, &["git", "push"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###" - No branches point to the specified revisions. + No branches found in the default push revset, `remote_branches(remote=origin)..@`. Nothing changed. "###); } @@ -147,7 +147,7 @@ fn test_git_push_matching_branch_unchanged() { let (stdout, stderr) = test_env.jj_cmd_ok(&workspace_root, &["git", "push"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###" - No branches point to the specified revisions. + No branches found in the default push revset, `remote_branches(remote=origin)..@`. Nothing changed. "###); } @@ -190,7 +190,7 @@ fn test_git_push_other_remote_has_branch() { let (stdout, stderr) = test_env.jj_cmd_ok(&workspace_root, &["git", "push"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###" - No branches point to the specified revisions. + No branches found in the default push revset, `remote_branches(remote=origin)..@`. Nothing changed. "###); // But it will still get pushed to another remote