Skip to content

Commit 01d2c0d

Browse files
committed
Fixes apply with deleted (added) file
1 parent dee9185 commit 01d2c0d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/git/actions/commit.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ export async function applyChanges(
7171
} catch {
7272
create = true;
7373

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

0 commit comments

Comments
 (0)