@ -73,6 +73,7 @@ import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger ;
import java.util.concurrent.atomic.AtomicInteger ;
import java.util.concurrent.atomic.AtomicReference ;
import java.util.concurrent.atomic.AtomicReference ;
import org.eclipse.jgit.annotations.NonNull ;
import org.eclipse.jgit.errors.InvalidObjectIdException ;
import org.eclipse.jgit.errors.InvalidObjectIdException ;
import org.eclipse.jgit.errors.LockFailedException ;
import org.eclipse.jgit.errors.LockFailedException ;
import org.eclipse.jgit.errors.MissingObjectException ;
import org.eclipse.jgit.errors.MissingObjectException ;
@ -715,17 +716,21 @@ public class RefDirectory extends RefDatabase {
* /
* /
private Ref peeledPackedRef ( Ref f )
private Ref peeledPackedRef ( Ref f )
throws MissingObjectException , IOException {
throws MissingObjectException , IOException {
if ( f . getStorage ( ) . isPacked ( ) & & f . isPeeled ( ) )
if ( f . getStorage ( ) . isPacked ( ) & & f . isPeeled ( ) ) {
return f ;
return f ;
if ( ! f . isPeeled ( ) )
}
if ( ! f . isPeeled ( ) ) {
f = peel ( f ) ;
f = peel ( f ) ;
if ( f . getPeeledObjectId ( ) ! = null )
}
ObjectId peeledObjectId = f . getPeeledObjectId ( ) ;
if ( peeledObjectId ! = null ) {
return new ObjectIdRef . PeeledTag ( PACKED , f . getName ( ) ,
return new ObjectIdRef . PeeledTag ( PACKED , f . getName ( ) ,
f . getObjectId ( ) , f . getPeeledObjectId ( ) ) ;
f . getObjectId ( ) , p eeledObjectId) ;
else
} else {
return new ObjectIdRef . PeeledNonTag ( PACKED , f . getName ( ) ,
return new ObjectIdRef . PeeledNonTag ( PACKED , f . getName ( ) ,
f . getObjectId ( ) ) ;
f . getObjectId ( ) ) ;
}
}
}
void log ( final RefUpdate update , final String msg , final boolean deref )
void log ( final RefUpdate update , final String msg , final boolean deref )
throws IOException {
throws IOException {
@ -985,7 +990,7 @@ public class RefDirectory extends RefDatabase {
try {
try {
id = ObjectId . fromString ( buf , 0 ) ;
id = ObjectId . fromString ( buf , 0 ) ;
if ( ref ! = null & & ! ref . isSymbolic ( )
if ( ref ! = null & & ! ref . isSymbolic ( )
& & ref . getTarget ( ) . getObjectId ( ) . equals ( id ) ) {
& & id . equals ( ref . getTarget ( ) . getObjectId ( ) ) ) {
assert ( currentSnapshot ! = null ) ;
assert ( currentSnapshot ! = null ) ;
currentSnapshot . setClean ( otherSnapshot ) ;
currentSnapshot . setClean ( otherSnapshot ) ;
return ref ;
return ref ;
@ -1103,8 +1108,8 @@ public class RefDirectory extends RefDatabase {
implements LooseRef {
implements LooseRef {
private final FileSnapshot snapShot ;
private final FileSnapshot snapShot ;
LoosePeeledTag ( FileSnapshot snapshot , String refName , ObjectId id ,
LoosePeeledTag ( FileSnapshot snapshot , @NonNull String refName ,
ObjectId p ) {
@NonNull ObjectId id , @NonNull ObjectId p ) {
super ( LOOSE , refName , id , p ) ;
super ( LOOSE , refName , id , p ) ;
this . snapShot = snapshot ;
this . snapShot = snapshot ;
}
}
@ -1122,7 +1127,8 @@ public class RefDirectory extends RefDatabase {
implements LooseRef {
implements LooseRef {
private final FileSnapshot snapShot ;
private final FileSnapshot snapShot ;
LooseNonTag ( FileSnapshot snapshot , String refName , ObjectId id ) {
LooseNonTag ( FileSnapshot snapshot , @NonNull String refName ,
@NonNull ObjectId id ) {
super ( LOOSE , refName , id ) ;
super ( LOOSE , refName , id ) ;
this . snapShot = snapshot ;
this . snapShot = snapshot ;
}
}
@ -1140,7 +1146,8 @@ public class RefDirectory extends RefDatabase {
implements LooseRef {
implements LooseRef {
private FileSnapshot snapShot ;
private FileSnapshot snapShot ;
LooseUnpeeled ( FileSnapshot snapShot , String refName , ObjectId id ) {
LooseUnpeeled ( FileSnapshot snapShot , @NonNull String refName ,
@NonNull ObjectId id ) {
super ( LOOSE , refName , id ) ;
super ( LOOSE , refName , id ) ;
this . snapShot = snapShot ;
this . snapShot = snapShot ;
}
}
@ -1149,13 +1156,24 @@ public class RefDirectory extends RefDatabase {
return snapShot ;
return snapShot ;
}
}
@NonNull
@Override
public ObjectId getObjectId ( ) {
ObjectId id = super . getObjectId ( ) ;
assert id ! = null ; // checked in constructor
return id ;
}
public LooseRef peel ( ObjectIdRef newLeaf ) {
public LooseRef peel ( ObjectIdRef newLeaf ) {
if ( newLeaf . getPeeledObjectId ( ) ! = null )
ObjectId peeledObjectId = newLeaf . getPeeledObjectId ( ) ;
ObjectId objectId = getObjectId ( ) ;
if ( peeledObjectId ! = null ) {
return new LoosePeeledTag ( snapShot , getName ( ) ,
return new LoosePeeledTag ( snapShot , getName ( ) ,
getObjectId ( ) , newLeaf . getPeeledObjectId ( ) ) ;
objectId , peeledObjectId ) ;
else
} else {
return new LooseNonTag ( snapShot , getName ( ) ,
return new LooseNonTag ( snapShot , getName ( ) ,
getObjectId ( ) ) ;
objectId ) ;
}
}
}
}
}
@ -1163,7 +1181,8 @@ public class RefDirectory extends RefDatabase {
LooseRef {
LooseRef {
private final FileSnapshot snapShot ;
private final FileSnapshot snapShot ;
LooseSymbolicRef ( FileSnapshot snapshot , String refName , Ref target ) {
LooseSymbolicRef ( FileSnapshot snapshot , @NonNull String refName ,
@NonNull Ref target ) {
super ( refName , target ) ;
super ( refName , target ) ;
this . snapShot = snapshot ;
this . snapShot = snapshot ;
}
}