Skip to content

Commit 0db82ea

Browse files
committed
Replace all relevant occurrences of integration with workspace
1 parent 9acab66 commit 0db82ea

File tree

32 files changed

+170
-176
lines changed

32 files changed

+170
-176
lines changed

crates/gitbutler-branch-actions/benches/branches.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub fn benchmark_list_branches(c: &mut Criterion) {
1818
(
1919
"list-branches[tiny repo]",
2020
3,
21-
("one-vbranch-on-integration-two-remotes", "for-listing.sh"),
21+
("one-vbranch-in-workspace-two-remotes", "for-listing.sh"),
2222
),
2323
(
2424
"list-branches[many local branches [packed]]",
@@ -59,7 +59,7 @@ pub fn benchmark_branch_details(c: &mut Criterion) {
5959
(
6060
"branch-details [tiny no change]",
6161
(
62-
"one-vbranch-on-integration-two-remotes",
62+
"one-vbranch-in-workspace-two-remotes",
6363
"main",
6464
0,
6565
"for-listing.sh",

crates/gitbutler-branch-actions/src/base.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::{
1717
branch_manager::BranchManagerExt,
1818
conflicts::RepoConflictsExt,
1919
hunk::VirtualBranchHunk,
20-
integration::update_gitbutler_integration,
20+
integration::update_workspace_commit,
2121
remote::{commit_to_remote_commit, RemoteCommit},
2222
status::get_applied_status,
2323
VirtualBranchesExt,
@@ -105,7 +105,7 @@ fn go_back_to_integration(ctx: &CommandContext, default_target: &Target) -> Resu
105105
.context("failed to checkout tree")?;
106106

107107
let base = target_to_base_branch(ctx, default_target)?;
108-
update_gitbutler_integration(&vb_state, ctx)?;
108+
update_workspace_commit(&vb_state, ctx)?;
109109
Ok(base)
110110
}
111111

@@ -260,7 +260,7 @@ pub(crate) fn set_base_branch(
260260

261261
set_exclude_decoration(ctx)?;
262262

263-
update_gitbutler_integration(&vb_state, ctx)?;
263+
update_workspace_commit(&vb_state, ctx)?;
264264

265265
let base = target_to_base_branch(ctx, &target)?;
266266
Ok(base)
@@ -549,7 +549,7 @@ pub(crate) fn update_base_branch(
549549
})?;
550550

551551
// Rewriting the integration commit is necessary after changing target sha.
552-
crate::integration::update_gitbutler_integration(&vb_state, ctx)?;
552+
crate::integration::update_workspace_commit(&vb_state, ctx)?;
553553
Ok(unapplied_branch_names)
554554
}
555555

crates/gitbutler-branch-actions/src/branch_manager/branch_creation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{
1616
conflicts::{self, RepoConflictsExt},
1717
ensure_selected_for_changes,
1818
hunk::VirtualBranchHunk,
19-
integration::update_gitbutler_integration,
19+
integration::update_workspace_commit,
2020
set_ownership, undo_commit, VirtualBranchesExt,
2121
};
2222

@@ -514,7 +514,7 @@ impl BranchManager<'_> {
514514
}
515515
}
516516

517-
update_gitbutler_integration(&vb_state, self.ctx)?;
517+
update_workspace_commit(&vb_state, self.ctx)?;
518518

519519
Ok(branch.name)
520520
}

crates/gitbutler-branch-actions/src/branch_manager/branch_removal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl BranchManager<'_> {
4949
// Ensure we still have a default target
5050
ensure_selected_for_changes(&vb_state).context("failed to ensure selected for changes")?;
5151

52-
crate::integration::update_gitbutler_integration(&vb_state, self.ctx)?;
52+
crate::integration::update_workspace_commit(&vb_state, self.ctx)?;
5353

5454
real_branch.reference_name()
5555
}

crates/gitbutler-branch-actions/src/integration.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub const GITBUTLER_WORKSPACE_COMMIT_TITLE: &str = "GitButler Workspace Commit";
2727
/// what files have been modified.
2828
///
2929
/// This should be used to update the `gitbutler/workspace` ref with, which is usually
30-
/// done from [`update_gitbutler_integration()`], after any of its input changes.
30+
/// done from [`update_workspace_commit()`], after any of its input changes.
3131
/// This is namely the conflicting state, or any head of the virtual branches.
3232
#[instrument(level = tracing::Level::DEBUG, skip(ctx))]
3333
pub(crate) fn get_workspace_head(ctx: &CommandContext) -> Result<git2::Oid> {
@@ -105,7 +105,7 @@ struct PreviousHead {
105105
sha: String,
106106
}
107107

108-
fn read_integration_file(path: &PathBuf) -> Result<Option<PreviousHead>> {
108+
fn read_workspace_file(path: &PathBuf) -> Result<Option<PreviousHead>> {
109109
if let Ok(prev_data) = std::fs::read_to_string(path) {
110110
let parts: Vec<&str> = prev_data.split(':').collect();
111111
let prev_head = parts[0].to_string();
@@ -119,13 +119,13 @@ fn read_integration_file(path: &PathBuf) -> Result<Option<PreviousHead>> {
119119
}
120120
}
121121

122-
fn write_integration_file(head: &git2::Reference, path: PathBuf) -> Result<()> {
122+
fn write_workspace_file(head: &git2::Reference, path: PathBuf) -> Result<()> {
123123
let sha = head.target().unwrap().to_string();
124124
std::fs::write(path, format!(":{}", sha))?;
125125
Ok(())
126126
}
127127
#[instrument(level = tracing::Level::DEBUG, skip(vb_state, ctx), err(Debug))]
128-
pub fn update_gitbutler_integration(
128+
pub fn update_workspace_commit(
129129
vb_state: &VirtualBranchesHandle,
130130
ctx: &CommandContext,
131131
) -> Result<git2::Oid> {
@@ -137,13 +137,13 @@ pub fn update_gitbutler_integration(
137137

138138
// get current repo head for reference
139139
let head_ref = repo.head()?;
140-
let integration_filepath = repo.path().join("integration");
141-
let mut prev_branch = read_integration_file(&integration_filepath)?;
140+
let workspace_filepath = repo.path().join("workspace");
141+
let mut prev_branch = read_workspace_file(&workspace_filepath)?;
142142
if let Some(branch) = &prev_branch {
143143
if branch.head != GITBUTLER_WORKSPACE_REFERENCE.to_string() {
144144
// we are moving from a regular branch to our gitbutler workspace branch, write a file to
145-
// .git/integration with the previous head and name
146-
write_integration_file(&head_ref, integration_filepath)?;
145+
// .git/workspace with the previous head and name
146+
write_workspace_file(&head_ref, workspace_filepath)?;
147147
prev_branch = Some(PreviousHead {
148148
head: head_ref.target().unwrap().to_string(),
149149
sha: head_ref.target().unwrap().to_string(),
@@ -230,7 +230,7 @@ pub fn update_gitbutler_integration(
230230
&GITBUTLER_WORKSPACE_REFERENCE.clone().to_string(),
231231
final_commit,
232232
true,
233-
"updated integration commit",
233+
"updated workspace commit",
234234
)?;
235235
repo.set_head(&GITBUTLER_WORKSPACE_REFERENCE.clone().to_string())?;
236236

@@ -333,7 +333,7 @@ fn verify_head_is_clean(ctx: &CommandContext, perm: &mut WorktreeWritePermission
333333
.log(head_commit.id(), LogUntil::Commit(default_target.sha))
334334
.context("failed to get log")?;
335335

336-
let integration_index = commits
336+
let workspace_index = commits
337337
.iter()
338338
.position(|commit| {
339339
commit.message().is_some_and(|message| {
@@ -342,8 +342,8 @@ fn verify_head_is_clean(ctx: &CommandContext, perm: &mut WorktreeWritePermission
342342
})
343343
})
344344
.context("GitButler workspace commit not found")?;
345-
let integration_commit = &commits[integration_index];
346-
let mut extra_commits = commits[..integration_index].to_vec();
345+
let workspace_commit = &commits[workspace_index];
346+
let mut extra_commits = commits[..workspace_index].to_vec();
347347
extra_commits.reverse();
348348

349349
if extra_commits.is_empty() {
@@ -352,8 +352,8 @@ fn verify_head_is_clean(ctx: &CommandContext, perm: &mut WorktreeWritePermission
352352
}
353353

354354
ctx.repository()
355-
.reset(integration_commit.as_object(), git2::ResetType::Soft, None)
356-
.context("failed to reset to integration commit")?;
355+
.reset(workspace_commit.as_object(), git2::ResetType::Soft, None)
356+
.context("failed to reset to workspace commit")?;
357357

358358
let branch_manager = ctx.branch_manager();
359359
let mut new_branch = branch_manager

crates/gitbutler-branch-actions/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ mod base;
1212
pub use base::BaseBranch;
1313

1414
mod integration;
15-
pub use integration::{update_gitbutler_integration, verify_branch};
15+
pub use integration::{update_workspace_commit, verify_branch};
1616

1717
mod file;
1818
pub use file::{Get, RemoteBranchFile};

crates/gitbutler-branch-actions/src/status.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ pub fn get_applied_status_cached(
5555
// TODO(ST): Ideally, we can avoid calling `get_workspace_head()` as everyone who modifies
5656
// any of its inputs will update the intragration commit right away.
5757
// It's for another day though - right now the integration commit may be slightly stale.
58-
let integration_commit_id = get_workspace_head(ctx)?;
59-
gitbutler_diff::workdir(ctx.repository(), integration_commit_id.to_owned())
58+
let workspace_head = get_workspace_head(ctx)?;
59+
gitbutler_diff::workdir(ctx.repository(), workspace_head.to_owned())
6060
.context("failed to diff workdir")
6161
})?;
6262

@@ -270,12 +270,12 @@ fn compute_locks(
270270
})
271271
.collect::<Vec<_>>();
272272

273-
let mut integration_hunks_by_path =
273+
let mut workspace_hunks_by_path =
274274
HashMap::<PathBuf, Vec<(gitbutler_diff::GitHunk, &Branch)>>::new();
275275

276276
for (branch, hunks_by_filepath) in branch_path_diffs {
277277
for (path, hunks) in hunks_by_filepath {
278-
integration_hunks_by_path.entry(path).or_default().extend(
278+
workspace_hunks_by_path.entry(path).or_default().extend(
279279
hunks
280280
.hunks
281281
.iter()
@@ -288,17 +288,14 @@ fn compute_locks(
288288
let locked_hunks = unstaged_hunks_by_path
289289
.iter()
290290
.filter_map(|(path, hunks)| {
291-
let integration_hunks = integration_hunks_by_path.get(path)?;
291+
let workspace_hunks = workspace_hunks_by_path.get(path)?;
292292

293293
let (unapplied_hunk, branches) = hunks.iter().find_map(|unapplied_hunk| {
294294
// Find all branches that have a hunk that intersects with the unapplied hunk
295-
let locked_to = integration_hunks
295+
let locked_to = workspace_hunks
296296
.iter()
297-
.filter_map(|(integration_hunk, branch)| {
298-
if GitHunk::integration_intersects_unapplied(
299-
integration_hunk,
300-
unapplied_hunk,
301-
) {
297+
.filter_map(|(workspace_hunk, branch)| {
298+
if GitHunk::workspace_intersects_unapplied(workspace_hunk, unapplied_hunk) {
302299
Some(*branch)
303300
} else {
304301
None

0 commit comments

Comments
 (0)