ok/jj
1
0
Fork 0
forked from mirrors/jj

cli git push: change warning if default revset contains no branches

Previously, `jj git push; jj git push` would tell the user that "No
branches point to the specified revisions.". I found this confusing,
even though strictly speaking it is correct (as the default revset only
considers revisions that haven't been pushed to the remote).

Closes #2241
This commit is contained in:
Ilya Grigoriev 2024-02-03 19:58:34 -08:00
parent 64fa84746a
commit d7bbbd1c29
2 changed files with 17 additions and 8 deletions

View file

@ -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!(

View file

@ -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