Skip to content

Commit eeb8271

Browse files
gnillevisomorphic-git-bot
authored andcommitted
fix: Handling of deleted trees on checkout (#2114)
* fix: handling of deleted trees on checkout * chore: add entry in contributors-rc * docs: update @gnillev as a contributor * chore: add unit test
1 parent b55ae60 commit eeb8271

File tree

6 files changed

+12
-11
lines changed

6 files changed

+12
-11
lines changed

js/isomorphic-git/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
389389
<td align="center"><a href="https://tomlarkworthy.endpointservices.net/"><img src="https://avatars.githubusercontent.com/u/1848162?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Tom Larkworthy</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=tomlarkworthy" title="Documentation">📖</a></td>
390390
<td align="center"><a href="https://github.com/kofta999"><img src="https://avatars.githubusercontent.com/u/99273340?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Mostafa Mahmoud</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=kofta999" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=kofta999" title="Tests">⚠️</a> <a href="#question-kofta999" title="Answering Questions">💬</a></td>
391391
<td align="center"><a href="https://github.com/ARBhosale"><img src="https://avatars.githubusercontent.com/u/26981417?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Aniket Bhosale</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=ARBhosale" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=ARBhosale" title="Documentation">📖</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=ARBhosale" title="Tests">⚠️</a></td>
392+
<td align="center"><a href="https://github.com/gnillev"><img src="https://avatars.githubusercontent.com/u/8965094?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Mathias Nisted Velling</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=gnillev" title="Code">💻</a><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=gnillev" title="Tests">⚠️</a></td>
392393
</tr>
393394
</table>
394395

js/isomorphic-git/index.cjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6446,10 +6446,10 @@ async function _checkout({
64466446
if (method === 'rmdir' || method === 'rmdir-index') {
64476447
const filepath = `${dir}/${fullpath}`;
64486448
try {
6449-
if (method === 'rmdir-index') {
6450-
index.delete({ filepath: fullpath });
6449+
if (method === 'rmdir') {
6450+
await fs.rmdir(filepath);
64516451
}
6452-
await fs.rmdir(filepath);
6452+
index.delete({ filepath: fullpath });
64536453
if (onProgress) {
64546454
await onProgress({
64556455
phase: 'Updating workdir',
@@ -6780,7 +6780,7 @@ async function analyze({
67806780
case '101': {
67816781
switch (await stage.type()) {
67826782
case 'tree': {
6783-
return ['rmdir', fullpath]
6783+
return ['rmdir-index', fullpath]
67846784
}
67856785
case 'blob': {
67866786
// Git checks that the workdir.oid === stage.oid before deleting file

js/isomorphic-git/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6440,10 +6440,10 @@ async function _checkout({
64406440
if (method === 'rmdir' || method === 'rmdir-index') {
64416441
const filepath = `${dir}/${fullpath}`;
64426442
try {
6443-
if (method === 'rmdir-index') {
6444-
index.delete({ filepath: fullpath });
6443+
if (method === 'rmdir') {
6444+
await fs.rmdir(filepath);
64456445
}
6446-
await fs.rmdir(filepath);
6446+
index.delete({ filepath: fullpath });
64476447
if (onProgress) {
64486448
await onProgress({
64496449
phase: 'Updating workdir',
@@ -6774,7 +6774,7 @@ async function analyze({
67746774
case '101': {
67756775
switch (await stage.type()) {
67766776
case 'tree': {
6777-
return ['rmdir', fullpath]
6777+
return ['rmdir-index', fullpath]
67786778
}
67796779
case 'blob': {
67806780
// Git checks that the workdir.oid === stage.oid before deleting file

js/isomorphic-git/index.umd.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/isomorphic-git/index.umd.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/isomorphic-git/size_report.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)