Skip to content

Commit

Permalink
Add a conflict test for worktree changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Jan 21, 2025
1 parent 93b838c commit f5456db
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
17 changes: 17 additions & 0 deletions crates/but-core/tests/core/worktree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,23 @@ fn file_to_symlink_in_worktree() -> Result<()> {
Ok(())
}

#[test]
fn conflict() -> Result<()> {
let repo = repo("conflicting")?;
let actual = changes(&repo)?;
insta::assert_debug_snapshot!(actual, @r#"
[
TreeChange {
path: "conflicting",
status: Conflict(
BothModified,
),
},
]
"#);
Ok(())
}

#[test]
#[cfg(unix)]
fn file_to_symlink_in_index() -> Result<()> {
Expand Down
14 changes: 14 additions & 0 deletions crates/but-core/tests/fixtures/worktree-changes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,17 @@ cp -Rv case-folding-worktree-changes case-folding-worktree-and-index-changes
100644 $empty_oid FILE
EOF
)

git init conflicting
(cd conflicting
touch unrelated && git add . && git commit -m "init"

empty=$(git hash-object -w --stdin </dev/null)
a=$(echo "a" | git hash-object -w --stdin)
b=$(echo "b" | git hash-object -w --stdin)
git update-index --index-info <<EOF
100644 $empty 1 conflicting
100644 $a 2 conflicting
100644 $b 3 conflicting
EOF
)

0 comments on commit f5456db

Please sign in to comment.