@ -652,42 +652,40 @@ public class ResolveMerger extends ThreeWayMerger {
keep ( ourDce ) ;
keep ( ourDce ) ;
// no checkout needed!
// no checkout needed!
return true ;
return true ;
} else {
}
// same content but different mode on OURS and THEIRS.
// same content but different mode on OURS and THEIRS.
// Try to merge the mode and report an error if this is
// Try to merge the mode and report an error if this is
// not possible.
// not possible.
int newMode = mergeFileModes ( modeB , modeO , modeT ) ;
int newMode = mergeFileModes ( modeB , modeO , modeT ) ;
if ( newMode ! = FileMode . MISSING . getBits ( ) ) {
if ( newMode ! = FileMode . MISSING . getBits ( ) ) {
if ( newMode = = modeO )
if ( newMode = = modeO ) {
// ours version is preferred
// ours version is preferred
keep ( ourDce ) ;
keep ( ourDce ) ;
else {
// the preferred version THEIRS has a different mode
// than ours. Check it out!
if ( isWorktreeDirty ( work , ourDce ) )
return false ;
// we know about length and lastMod only after we have written the new content.
// This will happen later. Set these values to 0 for know.
DirCacheEntry e = add ( tw . getRawPath ( ) , theirs ,
DirCacheEntry . STAGE_0 , EPOCH , 0 ) ;
addToCheckout ( tw . getPathString ( ) , e , attributes ) ;
}
return true ;
} else {
} else {
// FileModes are not mergeable. We found a conflict on modes.
// the preferred version THEIRS has a different mode
// For conflicting entries we don't know lastModified and length.
// than ours. Check it out!
add ( tw . getRawPath ( ) , base , DirCacheEntry . STAGE_1 , EPOCH , 0 ) ;
if ( isWorktreeDirty ( work , ourDce ) ) {
add ( tw . getRawPath ( ) , ours , DirCacheEntry . STAGE_2 , EPOCH , 0 ) ;
return false ;
add ( tw . getRawPath ( ) , theirs , DirCacheEntry . STAGE_3 , EPOCH ,
}
0 ) ;
// we know about length and lastMod only after we have
unmergedPaths . add ( tw . getPathString ( ) ) ;
// written the new content.
mergeResults . put (
// This will happen later. Set these values to 0 for know.
tw . getPathString ( ) ,
DirCacheEntry e = add ( tw . getRawPath ( ) , theirs ,
new MergeResult < > ( Collections
DirCacheEntry . STAGE_0 , EPOCH , 0 ) ;
. < RawText > emptyList ( ) ) ) ;
addToCheckout ( tw . getPathString ( ) , e , attributes ) ;
}
}
return true ;
return true ;
}
}
// FileModes are not mergeable. We found a conflict on modes.
// For conflicting entries we don't know lastModified and
// length.
add ( tw . getRawPath ( ) , base , DirCacheEntry . STAGE_1 , EPOCH , 0 ) ;
add ( tw . getRawPath ( ) , ours , DirCacheEntry . STAGE_2 , EPOCH , 0 ) ;
add ( tw . getRawPath ( ) , theirs , DirCacheEntry . STAGE_3 , EPOCH , 0 ) ;
unmergedPaths . add ( tw . getPathString ( ) ) ;
mergeResults . put ( tw . getPathString ( ) ,
new MergeResult < > ( Collections . < RawText > emptyList ( ) ) ) ;
return true ;
}
}
if ( modeB = = modeT & & tw . idEqual ( T_BASE , T_THEIRS ) ) {
if ( modeB = = modeT & & tw . idEqual ( T_BASE , T_THEIRS ) ) {
@ -716,21 +714,20 @@ public class ResolveMerger extends ThreeWayMerger {
addToCheckout ( tw . getPathString ( ) , e , attributes ) ;
addToCheckout ( tw . getPathString ( ) , e , attributes ) ;
}
}
return true ;
return true ;
} else {
}
// we want THEIRS ... but THEIRS contains a folder or the
// we want THEIRS ... but THEIRS contains a folder or the
// deletion of the path. Delete what's in the working tree,
// deletion of the path. Delete what's in the working tree,
// which we know to be clean.
// which we know to be clean.
if ( tw . getTreeCount ( ) > T_FILE & & tw . getRawMode ( T_FILE ) = = 0 ) {
if ( tw . getTreeCount ( ) > T_FILE & & tw . getRawMode ( T_FILE ) = = 0 ) {
// Not present in working tree, so nothing to delete
// Not present in working tree, so nothing to delete
return true ;
}
if ( modeT ! = 0 & & modeT = = modeB ) {
// Base, ours, and theirs all contain a folder: don't delete
return true ;
}
addDeletion ( tw . getPathString ( ) , nonTree ( modeO ) , attributes ) ;
return true ;
return true ;
}
}
if ( modeT ! = 0 & & modeT = = modeB ) {
// Base, ours, and theirs all contain a folder: don't delete
return true ;
}
addDeletion ( tw . getPathString ( ) , nonTree ( modeO ) , attributes ) ;
return true ;
}
}
if ( tw . isSubtree ( ) ) {
if ( tw . isSubtree ( ) ) {
@ -1310,10 +1307,9 @@ public class ResolveMerger extends ThreeWayMerger {
if ( getUnmergedPaths ( ) . isEmpty ( ) & & ! failed ( ) ) {
if ( getUnmergedPaths ( ) . isEmpty ( ) & & ! failed ( ) ) {
resultTree = dircache . writeTree ( getObjectInserter ( ) ) ;
resultTree = dircache . writeTree ( getObjectInserter ( ) ) ;
return true ;
return true ;
} else {
resultTree = null ;
return false ;
}
}
resultTree = null ;
return false ;
}
}
/ * *
/ * *