Skip to content

Commit ba8713a

Browse files
committed
Remove ideas about being unapplied
1 parent 57ede83 commit ba8713a

File tree

9 files changed

+73
-193
lines changed

9 files changed

+73
-193
lines changed

crates/gitbutler-core/src/ops/oplog.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ impl Project {
8080
let mut head_tree_ids = Vec::new();
8181

8282
for branch in vb_state.list_branches()? {
83-
if branch.applied {
84-
head_tree_ids.push(branch.tree);
85-
}
83+
head_tree_ids.push(branch.tree);
8684

8785
// commits in virtual branches (tree and commit data)
8886
// calculate all the commits between branch.head and the target and codify them
@@ -685,10 +683,7 @@ fn lines_since_snapshot(project: &Project, repo: &git2::Repository) -> Result<us
685683

686684
let vbranches = project.virtual_branches().list_branches()?;
687685
let mut lines_changed = 0;
688-
let dirty_branches = vbranches
689-
.iter()
690-
.filter(|b| b.applied)
691-
.filter(|b| !b.ownership.claims.is_empty());
686+
let dirty_branches = vbranches.iter().filter(|b| !b.ownership.claims.is_empty());
692687
for branch in dirty_branches {
693688
lines_changed += branch_lines_since_snapshot(branch, repo, oplog_commit_id)?;
694689
}
@@ -782,12 +777,8 @@ fn tree_from_applied_vbranches(
782777

783778
let vbs_from_toml: crate::virtual_branches::VirtualBranchesState =
784779
toml::from_str(from_utf8(vb_toml_blob.content())?)?;
785-
let applied_branch_trees: Vec<git2::Oid> = vbs_from_toml
786-
.branches
787-
.values()
788-
.filter(|b| b.applied)
789-
.map(|b| b.tree)
790-
.collect();
780+
let applied_branch_trees: Vec<git2::Oid> =
781+
vbs_from_toml.branches.values().map(|b| b.tree).collect();
791782

792783
let mut workdir_tree_id = target_tree.id();
793784
let base_tree = target_tree;

crates/gitbutler-core/src/virtual_branches/base.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ use super::{
1111
},
1212
target, BranchId, RemoteCommit, VirtualBranchHunk, VirtualBranchesHandle,
1313
};
14-
use crate::{
15-
git::BranchExt, git::RepositoryExt, types::ReferenceName, virtual_branches::errors::Marker,
16-
};
14+
use crate::{git::RepositoryExt, virtual_branches::errors::Marker};
1715
use crate::{
1816
git::{self, diff},
1917
project_repository::{self, LogUntil},
@@ -69,11 +67,6 @@ fn go_back_to_integration(
6967
.list_branches()
7068
.context("failed to read virtual branches")?;
7169

72-
let applied_virtual_branches = all_virtual_branches
73-
.iter()
74-
.filter(|branch| branch.applied)
75-
.collect::<Vec<_>>();
76-
7770
let target_commit = project_repository
7871
.repo()
7972
.find_commit(default_target.sha)
@@ -85,7 +78,7 @@ fn go_back_to_integration(
8578
let mut final_tree = target_commit
8679
.tree()
8780
.context("failed to get base tree from commit")?;
88-
for branch in &applied_virtual_branches {
81+
for branch in &all_virtual_branches {
8982
// merge this branches tree with our tree
9083
let branch_head = project_repository
9184
.repo()
@@ -243,7 +236,7 @@ pub fn set_base_branch(
243236
id: BranchId::generate(),
244237
name: head_name.to_string().replace("refs/heads/", ""),
245238
notes: String::new(),
246-
applied: true,
239+
old_applied: true,
247240
upstream,
248241
upstream_head,
249242
created_timestamp_ms: now_ms,
@@ -547,7 +540,6 @@ pub fn update_base_branch<'repo>(
547540

548541
let final_tree = updated_vbranches
549542
.iter()
550-
.filter(|branch| branch.applied)
551543
.fold(new_target_commit.tree(), |final_tree, branch| {
552544
let repo: &git2::Repository = repo;
553545
let final_tree = final_tree?;

crates/gitbutler-core/src/virtual_branches/branch/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ pub struct Branch {
2121
pub id: BranchId,
2222
pub name: String,
2323
pub notes: String,
24-
pub applied: bool,
24+
/// Previously used to determine if the branch should be shown on the board. If a branch is not shown on the board, it is converted to a real git branch.
25+
#[serde(rename = "applied")]
26+
pub old_applied: bool,
2527
pub upstream: Option<git::RemoteRefname>,
2628
// upstream_head is the last commit on we've pushed to the upstream branch
2729
#[serde(with = "crate::serde::oid_opt", default)]

crates/gitbutler-core/src/virtual_branches/branch/ownership.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ pub fn reconcile_claims(
134134
) -> Result<Vec<ClaimOutcome>> {
135135
let mut other_branches = all_branches
136136
.into_iter()
137-
.filter(|branch| branch.applied)
138137
.filter(|branch| branch.id != claiming_branch.id)
139138
.collect::<Vec<_>>();
140139

crates/gitbutler-core/src/virtual_branches/integration.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,20 @@ pub fn get_workspace_head(
4444
let vb_state = project_repo.project().virtual_branches();
4545

4646
let all_virtual_branches = vb_state.list_branches()?;
47-
let applied_branches = all_virtual_branches
48-
.iter()
49-
.filter(|branch| branch.applied)
50-
.collect::<Vec<_>>();
47+
let branches = all_virtual_branches.iter().collect::<Vec<_>>();
5148

5249
let target_commit = repo.find_commit(target.sha)?;
5350
let mut workspace_tree = target_commit.tree()?;
5451

5552
if conflicts::is_conflicting(project_repo, None)? {
5653
let merge_parent =
5754
conflicts::merge_parent(project_repo)?.ok_or(anyhow!("No merge parent"))?;
58-
let first_branch = applied_branches.first().ok_or(anyhow!("No branches"))?;
55+
let first_branch = branches.first().ok_or(anyhow!("No branches"))?;
5956

6057
let merge_base = repo.merge_base(first_branch.head, merge_parent)?;
6158
workspace_tree = repo.find_commit(merge_base)?.tree()?;
6259
} else {
63-
for branch in &applied_branches {
60+
for branch in &branches {
6461
let branch_tree = repo.find_commit(branch.head)?.tree()?;
6562
let merge_tree = repo.find_commit(target.sha)?.tree()?;
6663
let mut index = repo.merge_trees(&merge_tree, &workspace_tree, &branch_tree, None)?;
@@ -73,7 +70,7 @@ pub fn get_workspace_head(
7370
}
7471
}
7572

76-
let branch_heads = applied_branches
73+
let branch_heads = branches
7774
.iter()
7875
.map(|b| repo.find_commit(b.head))
7976
.collect::<Result<Vec<_>, _>>()?;
@@ -87,7 +84,7 @@ pub fn get_workspace_head(
8784
// TODO(mg): Can we make this a constant?
8885
let committer = get_integration_commiter()?;
8986

90-
let mut heads: Vec<git2::Commit<'_>> = applied_branches
87+
let mut heads: Vec<git2::Commit<'_>> = branches
9188
.iter()
9289
.filter(|b| b.head != target.sha)
9390
.map(|b| repo.find_commit(b.head))
@@ -177,11 +174,6 @@ pub fn update_gitbutler_integration(
177174
.list_branches()
178175
.context("failed to list virtual branches")?;
179176

180-
let applied_virtual_branches = all_virtual_branches
181-
.iter()
182-
.filter(|branch| branch.applied)
183-
.collect::<Vec<_>>();
184-
185177
let integration_commit =
186178
repo.find_commit(get_workspace_head(&vb_state, project_repository)?)?;
187179
let integration_tree = integration_commit.tree()?;
@@ -200,7 +192,7 @@ pub fn update_gitbutler_integration(
200192
message.push_str("If you switch to another branch, GitButler will need to be reinitialized.\n");
201193
message.push_str("If you commit on this branch, GitButler will throw it away.\n\n");
202194
message.push_str("Here are the branches that are currently applied:\n");
203-
for branch in &applied_virtual_branches {
195+
for branch in &all_virtual_branches {
204196
message.push_str(" - ");
205197
message.push_str(branch.name.as_str());
206198
message.push_str(format!(" ({})", &branch.refname()).as_str());

0 commit comments

Comments
 (0)