Skip to content

Commit be4ddb1

Browse files
authored
Merge pull request #4670 from Byron/git2-to-gix
branch details with `gix`
2 parents acf902c + fcafaec commit be4ddb1

File tree

35 files changed

+11197
-559
lines changed

35 files changed

+11197
-559
lines changed

Cargo.lock

Lines changed: 299 additions & 225 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ resolver = "2"
3636
[workspace.dependencies]
3737
bstr = "1.10.0"
3838
# Add the `tracing` or `tracing-detail` features to see more of gitoxide in the logs. Useful to see which programs it invokes.
39-
gix = { git = "https://github.com/Byron/gitoxide", rev = "d51f330e9d364c6f7b068116b59bf5c0160e47af", default-features = false, features = [
40-
] }
39+
gix = { git = "https://github.com/Byron/gitoxide", rev = "242fedc973c56b6c1b6f150af99dda972a67f547", default-features = false, features = [] }
4140
git2 = { version = "0.18.3", features = [
4241
"vendored-openssl",
4342
"vendored-libgit2",
@@ -52,6 +51,8 @@ fslock = "0.2.1"
5251
parking_lot = "0.12.3"
5352
futures = "0.3.30"
5453
toml = "0.8.13"
54+
tracing = "0.1.40"
55+
tracing-subscriber = "0.3.17"
5556

5657
gitbutler-id = { path = "crates/gitbutler-id" }
5758
gitbutler-git = { path = "crates/gitbutler-git" }

crates/gitbutler-branch-actions/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ authors = ["GitButler <[email protected]>"]
66
publish = false
77

88
[dependencies]
9-
tracing = "0.1.40"
9+
tracing.workspace = true
1010
anyhow = "1.0.86"
1111
git2.workspace = true
12-
gix.workspace = true
12+
gix = { workspace = true, features = ["blob-diff"] }
1313
tokio.workspace = true
1414
gitbutler-oplog.workspace = true
1515
gitbutler-repo.workspace = true
@@ -43,7 +43,7 @@ reqwest = { version = "0.12.4", features = ["json"] }
4343
once_cell = "1.19"
4444
pretty_assertions = "1.4"
4545
gitbutler-testsupport.workspace = true
46-
gix = { workspace = true, features = ["max-performance-safe"] }
46+
gix = { workspace = true, features = ["max-performance"] }
4747
gitbutler-git = { workspace = true, features = ["test-askpass-path"] }
4848
glob = "0.3.1"
4949
serial_test = "3.1.1"

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

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput};
2-
use gitbutler_branch_actions::list_branches;
2+
use gitbutler_branch_actions::{get_branch_listing_details, list_branches};
33
use gitbutler_command_context::CommandContext;
44
use gitbutler_project::Project;
55

@@ -50,5 +50,74 @@ pub fn benchmark_list_branches(c: &mut Criterion) {
5050
}
5151
}
5252

53-
criterion_group!(benches, benchmark_list_branches);
53+
pub fn benchmark_branch_details(c: &mut Criterion) {
54+
for (bench_name, (repo_name, branch_name, files_to_diff, script_name)) in [
55+
(
56+
"branch-details [many branches no change]",
57+
("many-local", "virtual", 0, "branch-benches.sh"),
58+
),
59+
(
60+
"branch-details [tiny no change]",
61+
(
62+
"one-vbranch-on-integration-two-remotes",
63+
"main",
64+
0,
65+
"for-listing.sh",
66+
),
67+
),
68+
(
69+
"branch-details [big repo no change]",
70+
(
71+
"big-repo-clone",
72+
"no-change",
73+
0,
74+
"branch-details-benches.sh",
75+
),
76+
),
77+
(
78+
"branch-details [every-file-changed]",
79+
(
80+
"big-repo-clone-one-commit-ahead",
81+
"change-with-new-content",
82+
10_000,
83+
"branch-details-benches.sh",
84+
),
85+
),
86+
] {
87+
let mut group = c.benchmark_group(bench_name);
88+
let project = fixture_project(repo_name, script_name);
89+
if files_to_diff != 0 {
90+
group.throughput(Throughput::Elements(files_to_diff));
91+
}
92+
group.bench_function("list details of known branch", |b| {
93+
b.iter(|| {
94+
let ctx = CommandContext::open(&project).unwrap();
95+
let details =
96+
get_branch_listing_details(black_box(&ctx), Some(branch_name)).unwrap();
97+
assert_eq!(details.len(), 1, "{script_name}:{repo_name}:{branch_name}");
98+
assert_eq!(
99+
details[0].number_of_files, files_to_diff as usize,
100+
"currently it creates a new vbranch for changes in local-commits, something we leverage here"
101+
);
102+
})
103+
});
104+
}
105+
106+
let mut group = c.benchmark_group("branch-details [revwalk]");
107+
let project = fixture_project("revwalk-repo", "branch-details-benches.sh");
108+
group.throughput(Throughput::Elements(100 + 15 + 50));
109+
group.bench_function("count commits/collect authors", |b| {
110+
b.iter(|| {
111+
let ctx = CommandContext::open(&project).unwrap();
112+
let details = get_branch_listing_details(
113+
black_box(&ctx),
114+
["feature", "main", "non-virtual-feature"],
115+
)
116+
.unwrap();
117+
assert_eq!(details.len(), 3);
118+
})
119+
});
120+
}
121+
122+
criterion_group!(benches, benchmark_list_branches, benchmark_branch_details);
54123
criterion_main!(benches);

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,12 @@ fn _print_tree(repo: &git2::Repository, tree: &git2::Tree) -> Result<()> {
314314
Ok(())
315315
}
316316

317-
// try to update the target branch
318-
// this means that we need to:
319-
// determine if what the target branch is now pointing to is mergeable with our current working directory
320-
// merge the target branch into our current working directory
321-
// update the target sha
317+
/// try to update the target branch
318+
/// this means that we need to:
319+
/// - determine if what the target branch is now pointing to is mergeable with our current working directory,
320+
/// - merge the target branch into our current working directory
321+
/// - update the target sha
322+
/// - return all conflicting references that were unapplied to avoid the conflict
322323
pub(crate) fn update_base_branch(
323324
ctx: &CommandContext,
324325
perm: &mut WorktreeWritePermission,

0 commit comments

Comments
 (0)