From 14d35b01986dad53a489b4f82a3b263cdbafa06b Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Mon, 21 Aug 2023 22:34:58 -0700 Subject: [PATCH] cli: make `jj git push -r` just warn if no branches targeted If there are branches in the revset that don't need to be pushed because they already match the destination, we currently just print `Nothing changed.` It seems consistent with that to also treat it as success if there are no branches in the specified set to start with. This patch makes the command print a warning in that case instead. --- cli/src/commands/git.rs | 5 ++++- cli/tests/test_git_push.rs | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cli/src/commands/git.rs b/cli/src/commands/git.rs index 827779707..f877fc384 100644 --- a/cli/src/commands/git.rs +++ b/cli/src/commands/git.rs @@ -791,7 +791,10 @@ fn cmd_git_push( } } if !args.revisions.is_empty() && branches_targeted.is_empty() { - return Err(user_error("No branches point to the specified revisions.")); + writeln!( + ui.warning(), + "No branches point to the specified revisions." + )?; } tx_description = format!( diff --git a/cli/tests/test_git_push.rs b/cli/tests/test_git_push.rs index fbbe58b04..b5ef3ddb6 100644 --- a/cli/tests/test_git_push.rs +++ b/cli/tests/test_git_push.rs @@ -341,9 +341,12 @@ fn test_git_push_revisions() { Error: Empty revision set "###); // Push a revision with no branches - let stderr = test_env.jj_cmd_failure(&workspace_root, &["git", "push", "-r=@--"]); + let (stdout, stderr) = test_env.jj_cmd_ok(&workspace_root, &["git", "push", "-r=@--"]); + insta::assert_snapshot!(stdout, @r###" + Nothing changed. + "###); insta::assert_snapshot!(stderr, @r###" - Error: No branches point to the specified revisions. + No branches point to the specified revisions. "###); // Push a revision with a single branch let stdout = test_env.jj_cmd_success(&workspace_root, &["git", "push", "-r=@-", "--dry-run"]);