Skip to content

Commit

Permalink
Rearrange branches of if statement in jj git push
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyagr committed Dec 21, 2022
1 parent 2f00fcb commit 0285a20
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3869,7 +3869,25 @@ fn cmd_git_push(
let mut tx;
let mut branch_updates = vec![];
let mut seen_branches = hashset! {};
if !args.branch.is_empty() {
if args.all {
// TODO: Is it useful to warn about conflicted branches?
for (branch_name, branch_target) in workspace_command.repo().view().branches() {
if !seen_branches.insert(branch_name.clone()) {
continue;
}
let push_action = classify_branch_push_action(branch_target, &args.remote);
match push_action {
BranchPushAction::AlreadyMatches => {}
BranchPushAction::LocalConflicted => {}
BranchPushAction::RemoteConflicted => {}
BranchPushAction::Update(update) => {
branch_updates.push((branch_name.clone(), update));
}
}
}
tx = workspace_command
.start_transaction(&format!("push all branches to git remote {}", &args.remote));
} else if !args.branch.is_empty() {
for branch_name in &args.branch {
if !seen_branches.insert(branch_name.clone()) {
continue;
Expand Down Expand Up @@ -3946,24 +3964,6 @@ fn cmd_git_push(
)?;
}
}
} else if args.all {
// TODO: Is it useful to warn about conflicted branches?
for (branch_name, branch_target) in workspace_command.repo().view().branches() {
if !seen_branches.insert(branch_name.clone()) {
continue;
}
let push_action = classify_branch_push_action(branch_target, &args.remote);
match push_action {
BranchPushAction::AlreadyMatches => {}
BranchPushAction::LocalConflicted => {}
BranchPushAction::RemoteConflicted => {}
BranchPushAction::Update(update) => {
branch_updates.push((branch_name.clone(), update));
}
}
}
tx = workspace_command
.start_transaction(&format!("push all branches to git remote {}", &args.remote));
} else {
match workspace_command
.repo()
Expand Down

0 comments on commit 0285a20

Please sign in to comment.