mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-04 05:28:02 +00:00
cli: report no updates to current branch
Fix a bug where `jj git push` would print "No current branch." when there is a current branch but it is unchanged. We were conflating the two because we print the message when no updates were performed, instead of only when no branches were found.
This commit is contained in:
parent
3418c8ff73
commit
b338c916c0
2 changed files with 13 additions and 3 deletions
|
@ -659,6 +659,9 @@ fn cmd_git_push(
|
|||
);
|
||||
}
|
||||
}
|
||||
if branches.is_empty() {
|
||||
return Err(user_error("No current branch."));
|
||||
}
|
||||
for (branch_name, branch_target) in branches {
|
||||
if !seen_branches.insert(branch_name.clone()) {
|
||||
continue;
|
||||
|
@ -675,9 +678,6 @@ fn cmd_git_push(
|
|||
}
|
||||
}
|
||||
}
|
||||
if branch_updates.is_empty() {
|
||||
return Err(user_error("No current branch."));
|
||||
}
|
||||
tx = workspace_command.start_transaction(&format!(
|
||||
"push current branch(es) to git remote {}",
|
||||
&remote
|
||||
|
|
|
@ -129,6 +129,16 @@ fn test_git_push_no_current_branch() {
|
|||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_git_push_current_branch_unchanged() {
|
||||
let (test_env, workspace_root) = set_up();
|
||||
test_env.jj_cmd_success(&workspace_root, &["co", "branch1"]);
|
||||
let stdout = test_env.jj_cmd_success(&workspace_root, &["git", "push"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
Nothing changed.
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_git_push_multiple() {
|
||||
let (test_env, workspace_root) = set_up();
|
||||
|
|
Loading…
Reference in a new issue