Skip to content

Commit

Permalink
Do not allow copying a file into itself
Browse files Browse the repository at this point in the history
  • Loading branch information
bennetbo committed Jun 13, 2024
1 parent cf70890 commit 04247cf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion crates/worktree/src/worktree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1611,7 +1611,13 @@ impl LocalWorktree {
let file_name = source.file_name()?;
let mut target = target_directory.clone();
target.push(file_name);
Some((source, target))

// Do not allow copying the same file to itself.
if source.as_ref() != target.as_path() {
Some((source, target))
} else {
None
}
})
.collect::<Vec<_>>();

Expand Down

0 comments on commit 04247cf

Please sign in to comment.