Skip to content

Commit

Permalink
Fixes apply with deleted (added) file
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Feb 27, 2025
1 parent dee9185 commit 01d2c0d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/git/actions/commit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ export async function applyChanges(
} catch {
create = true;

ref2 = ref1;
ref1 = `${ref1}^`;
// If restoring a deleted file (e.g. a newly added file), swap the refs to restore from the previous commit
[ref1, ref2] = [ref2 === '' ? 'HEAD' : ref2 ?? `${ref1}^`, ref1];
}
}
}
Expand Down

0 comments on commit 01d2c0d

Please sign in to comment.