mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-30 16:10:23 +00:00
git-push: do not error out on empty revision set
"-r REVISIONS" here specifies the search space of the branches to push, and warned if no branches are found in that space. I don't think an empty set should be an error, but a warning for consistency. The warning message will be improved by the subsequent patches.
This commit is contained in:
parent
02c0927734
commit
bc7a42a00e
2 changed files with 8 additions and 10 deletions
|
@ -41,9 +41,8 @@ use jj_lib::workspace::Workspace;
|
||||||
use maplit::hashset;
|
use maplit::hashset;
|
||||||
|
|
||||||
use crate::cli_util::{
|
use crate::cli_util::{
|
||||||
parse_string_pattern, print_trackable_remote_branches, resolve_multiple_nonempty_revsets,
|
parse_string_pattern, print_trackable_remote_branches, short_change_hash, short_commit_hash,
|
||||||
short_change_hash, short_commit_hash, start_repo_transaction, CommandHelper, RevisionArg,
|
start_repo_transaction, CommandHelper, RevisionArg, WorkspaceCommandHelper,
|
||||||
WorkspaceCommandHelper,
|
|
||||||
};
|
};
|
||||||
use crate::command_error::{
|
use crate::command_error::{
|
||||||
user_error, user_error_with_hint, user_error_with_hint_opt, user_error_with_message,
|
user_error, user_error_with_hint, user_error_with_hint_opt, user_error_with_message,
|
||||||
|
@ -1190,11 +1189,9 @@ fn find_branches_targeted_by_revisions<'a>(
|
||||||
current_branches_revset.iter().collect()
|
current_branches_revset.iter().collect()
|
||||||
} else {
|
} else {
|
||||||
// TODO: Narrow search space to local target commits.
|
// TODO: Narrow search space to local target commits.
|
||||||
// TODO: Remove redundant CommitId -> Commit -> CommitId round trip.
|
let expression = workspace_command.parse_union_revsets(revisions)?;
|
||||||
resolve_multiple_nonempty_revsets(revisions, workspace_command)?
|
let revset = workspace_command.evaluate_revset(expression)?;
|
||||||
.iter()
|
revset.iter().collect()
|
||||||
.map(|commit| commit.id().clone())
|
|
||||||
.collect()
|
|
||||||
};
|
};
|
||||||
let branches_targeted = workspace_command
|
let branches_targeted = workspace_command
|
||||||
.repo()
|
.repo()
|
||||||
|
|
|
@ -454,9 +454,10 @@ fn test_git_push_revisions() {
|
||||||
std::fs::write(workspace_root.join("file"), "modified again").unwrap();
|
std::fs::write(workspace_root.join("file"), "modified again").unwrap();
|
||||||
|
|
||||||
// Push an empty set
|
// Push an empty set
|
||||||
let stderr = test_env.jj_cmd_failure(&workspace_root, &["git", "push", "-r=none()"]);
|
let (_stdout, stderr) = test_env.jj_cmd_ok(&workspace_root, &["git", "push", "-r=none()"]);
|
||||||
insta::assert_snapshot!(stderr, @r###"
|
insta::assert_snapshot!(stderr, @r###"
|
||||||
Error: Empty revision set
|
No branches point to the specified revisions.
|
||||||
|
Nothing changed.
|
||||||
"###);
|
"###);
|
||||||
// Push a revision with no branches
|
// Push a revision with no branches
|
||||||
let (stdout, stderr) = test_env.jj_cmd_ok(&workspace_root, &["git", "push", "-r=@--"]);
|
let (stdout, stderr) = test_env.jj_cmd_ok(&workspace_root, &["git", "push", "-r=@--"]);
|
||||||
|
|
Loading…
Reference in a new issue