|
|
@ -491,15 +491,22 @@ public class RefDirectory extends RefDatabase { |
|
|
|
|
|
|
|
|
|
|
|
public RefDirectoryUpdate newUpdate(String name, boolean detach) |
|
|
|
public RefDirectoryUpdate newUpdate(String name, boolean detach) |
|
|
|
throws IOException { |
|
|
|
throws IOException { |
|
|
|
|
|
|
|
boolean detachingSymbolicRef = false; |
|
|
|
final RefList<Ref> packed = getPackedRefs(); |
|
|
|
final RefList<Ref> packed = getPackedRefs(); |
|
|
|
Ref ref = readRef(name, packed); |
|
|
|
Ref ref = readRef(name, packed); |
|
|
|
if (ref != null) |
|
|
|
if (ref != null) |
|
|
|
ref = resolve(ref, 0, null, null, packed); |
|
|
|
ref = resolve(ref, 0, null, null, packed); |
|
|
|
if (ref == null) |
|
|
|
if (ref == null) |
|
|
|
ref = new ObjectIdRef.Unpeeled(NEW, name, null); |
|
|
|
ref = new ObjectIdRef.Unpeeled(NEW, name, null); |
|
|
|
else if (detach && ref.isSymbolic()) |
|
|
|
else { |
|
|
|
ref = new ObjectIdRef.Unpeeled(LOOSE, name, ref.getObjectId()); |
|
|
|
detachingSymbolicRef = detach && ref.isSymbolic(); |
|
|
|
return new RefDirectoryUpdate(this, ref); |
|
|
|
if (detachingSymbolicRef) |
|
|
|
|
|
|
|
ref = new ObjectIdRef.Unpeeled(LOOSE, name, ref.getObjectId()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
RefDirectoryUpdate refDirUpdate = new RefDirectoryUpdate(this, ref); |
|
|
|
|
|
|
|
if (detachingSymbolicRef) |
|
|
|
|
|
|
|
refDirUpdate.setDetachingSymbolicRef(); |
|
|
|
|
|
|
|
return refDirUpdate; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|