Skip to content

Commit

Permalink
working_copy: move creation of parent dirs to one place
Browse files Browse the repository at this point in the history
I'm about to add handling of parent dirs that are existing ignored
files, so it's better to have it in one place. The only functional
difference should be that we now create parent directories for git
submodules. I don't think that matters.
  • Loading branch information
martinvonz committed Oct 7, 2023
1 parent 187ba94 commit 3db5c52
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/src/local_working_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,6 @@ impl TreeState {
id: &FileId,
executable: bool,
) -> Result<FileState, CheckoutError> {
create_parent_dirs(&self.working_copy_path, path)?;
let mut file = OpenOptions::new()
.write(true)
.create_new(true) // Don't overwrite un-ignored file. Don't follow symlink.
Expand Down Expand Up @@ -1109,7 +1108,6 @@ impl TreeState {
path: &RepoPath,
id: &SymlinkId,
) -> Result<FileState, CheckoutError> {
create_parent_dirs(&self.working_copy_path, path)?;
let target = self.store.read_symlink(path, id)?;
#[cfg(windows)]
{
Expand Down Expand Up @@ -1139,7 +1137,6 @@ impl TreeState {
path: &RepoPath,
conflict: &Merge<Option<TreeValue>>,
) -> Result<FileState, CheckoutError> {
create_parent_dirs(&self.working_copy_path, path)?;
let mut file = OpenOptions::new()
.write(true)
.create_new(true) // Don't overwrite un-ignored file. Don't follow symlink.
Expand Down Expand Up @@ -1238,6 +1235,9 @@ impl TreeState {
if before.is_present() {
fs::remove_file(&disk_path).ok();
}
if after.is_present() {
create_parent_dirs(&self.working_copy_path, &path)?;
}
// TODO: Check that the file has not changed before overwriting/removing it.
match after.into_resolved() {
Ok(None) => {
Expand Down

0 comments on commit 3db5c52

Please sign in to comment.