Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash

set -eu -o pipefail
source "${BASH_SOURCE[0]%/*}/shared.sh"

### Description
# Similar to myers-false-conflict-same-file but with multiple sequential commits
# per branch, to test squash and amend operations in the context of false conflicts.
#
# Base file:
# alpha_x
# (blank)
# bravo_x
# charlie_x
# (blank)
#
# Branch "edit-alpha" has two commits:
# 1. Adds a comment line at the top
# 2. Deletes alpha_x (replaces with blank) and removes trailing blank
#
# Branch "edit-bravo" has two commits:
# 1. Adds a comment line at the bottom
# 2. Deletes bravo_x
#
# The final state of each branch triggers the Myers false conflict.
# Squashing the two commits in either branch should also work but may
# trigger merge issues during the rebase.

git init

# Create the base content on main
printf 'alpha_x\n\nbravo_x\ncharlie_x\n\n' > shared-file
git add shared-file
git commit -m "base: shared-file with alpha, bravo, charlie"

git branch gitbutler/workspace

# Branch A: two sequential commits
git checkout -b edit-alpha main

# First commit: add a header comment (doesn't conflict with anything)
printf '# header\nalpha_x\n\nbravo_x\ncharlie_x\n\n' > shared-file
git add shared-file
git commit -m "add header to shared-file"

# Second commit: delete alpha_x and trailing blank
printf '# header\n\n\nbravo_x\ncharlie_x\n' > shared-file
git add shared-file
git commit -m "delete alpha_x from shared-file"

# Branch B: two sequential commits
git checkout -b edit-bravo main

# First commit: add a footer comment (doesn't conflict with anything)
printf 'alpha_x\n\nbravo_x\ncharlie_x\n\n# footer\n' > shared-file
git add shared-file
git commit -m "add footer to shared-file"

# Second commit: delete bravo_x
printf 'alpha_x\n\ncharlie_x\n\n# footer\n' > shared-file
git add shared-file
git commit -m "delete bravo_x from shared-file"
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash

set -eu -o pipefail
source "${BASH_SOURCE[0]%/*}/shared.sh"

### Description
# Two independent branches editing the same file with non-overlapping changes.
# This triggers a false merge conflict with Myers diff algorithm due to
# split hunks with empty insertions.
# See: https://github.com/GitoxideLabs/gitoxide/issues/2475
#
# Base file has:
# alpha_x
# (blank)
# bravo_x
# charlie_x
# (blank)
#
# Branch "delete-alpha" removes alpha_x (replaces with blank) and trailing blank.
# Branch "delete-bravo" removes bravo_x.
# These are non-overlapping edits that git merge-file resolves cleanly,
# but Myers diff produces a false conflict.

git init

# Create the base content on main
printf 'alpha_x\n\nbravo_x\ncharlie_x\n\n' > shared-file
git add shared-file
git commit -m "base: shared-file with alpha, bravo, charlie"

git branch gitbutler/workspace

# Branch A: delete alpha_x (replace with blank line) and remove trailing blank
git checkout -b delete-alpha main
printf '\n\nbravo_x\ncharlie_x\n' > shared-file
git add shared-file
git commit -m "delete alpha_x from shared-file"

# Branch B: delete bravo_x
git checkout -b delete-bravo main
printf 'alpha_x\n\ncharlie_x\n\n' > shared-file
git add shared-file
git commit -m "delete bravo_x from shared-file"
2 changes: 2 additions & 0 deletions crates/but-workspace/tests/workspace/commit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ mod move_commit;
mod reword;
mod uncommit_changes;

mod myers_false_conflict;

mod from_new_merge_with_metadata {
use bstr::ByteSlice;
use but_graph::init::{Options, Overlay};
Expand Down
Loading
Loading