File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9392,7 +9392,12 @@ async function mergeTree({
93929392 }
93939393
93949394 // deleted by both
9395- if ( base && ! ours && ! theirs && ( await base . type ( ) ) === 'blob' ) {
9395+ if (
9396+ base &&
9397+ ! ours &&
9398+ ! theirs &&
9399+ ( ( await base . type ( ) ) === 'blob' || ( await base . type ( ) ) === 'tree' )
9400+ ) {
93969401 return undefined
93979402 }
93989403
@@ -9416,9 +9421,19 @@ async function mergeTree({
94169421 if ( ! parent ) return
94179422
94189423 // automatically delete directories if they have been emptied
9419- if ( parent && parent . type === 'tree' && entries . length === 0 ) return
9424+ // except for the root directory
9425+ if (
9426+ parent &&
9427+ parent . type === 'tree' &&
9428+ entries . length === 0 &&
9429+ parent . path !== '.'
9430+ )
9431+ return
94209432
9421- if ( entries . length > 0 ) {
9433+ if (
9434+ entries . length > 0 ||
9435+ ( parent . path === '.' && entries . length === 0 )
9436+ ) {
94229437 const tree = new GitTree ( entries ) ;
94239438 const object = tree . toObject ( ) ;
94249439 const oid = await _writeObject ( {
@@ -9682,7 +9697,7 @@ async function _merge({
96829697 ) ;
96839698
96849699 // Defer throwing error until the index lock is relinquished and index is
9685- // written to filsesystem
9700+ // written to filesystem
96869701 if ( tree instanceof MergeConflictError ) throw tree
96879702
96889703 if ( ! message ) {
Original file line number Diff line number Diff line change @@ -9386,7 +9386,12 @@ async function mergeTree({
93869386 }
93879387
93889388 // deleted by both
9389- if ( base && ! ours && ! theirs && ( await base . type ( ) ) === 'blob' ) {
9389+ if (
9390+ base &&
9391+ ! ours &&
9392+ ! theirs &&
9393+ ( ( await base . type ( ) ) === 'blob' || ( await base . type ( ) ) === 'tree' )
9394+ ) {
93909395 return undefined
93919396 }
93929397
@@ -9410,9 +9415,19 @@ async function mergeTree({
94109415 if ( ! parent ) return
94119416
94129417 // automatically delete directories if they have been emptied
9413- if ( parent && parent . type === 'tree' && entries . length === 0 ) return
9418+ // except for the root directory
9419+ if (
9420+ parent &&
9421+ parent . type === 'tree' &&
9422+ entries . length === 0 &&
9423+ parent . path !== '.'
9424+ )
9425+ return
94149426
9415- if ( entries . length > 0 ) {
9427+ if (
9428+ entries . length > 0 ||
9429+ ( parent . path === '.' && entries . length === 0 )
9430+ ) {
94169431 const tree = new GitTree ( entries ) ;
94179432 const object = tree . toObject ( ) ;
94189433 const oid = await _writeObject ( {
@@ -9676,7 +9691,7 @@ async function _merge({
96769691 ) ;
96779692
96789693 // Defer throwing error until the index lock is relinquished and index is
9679- // written to filsesystem
9694+ // written to filesystem
96809695 if ( tree instanceof MergeConflictError ) throw tree
96819696
96829697 if ( ! message ) {
Load Diff Large diffs are not rendered by default.
You can’t perform that action at this time.
0 commit comments