summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2016-08-25 20:57:39 -0400
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2016-08-25 20:57:42 -0400
commit1836a7b273b63d6e217e5b58322cb1a079517101 (patch)
tree9ea3d1e3de834a78274deee282a019a6696fa5bf
parent649ad06586705b25905f805544cadcfad08efc07 (diff)
parent3e27fb37196bd43ba626235850af8fa684e23e1f (diff)
downloadjgit-1836a7b273b63d6e217e5b58322cb1a079517101.tar.gz
jgit-1836a7b273b63d6e217e5b58322cb1a079517101.zip
Merge "Do not fake a SymbolicRef as an ObjectIdRef"
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRefDatabase.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectoryUpdate.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java9
4 files changed, 12 insertions, 11 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRefDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRefDatabase.java
index e5469f6b83..5611d23be7 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRefDatabase.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRefDatabase.java
@@ -217,10 +217,6 @@ public abstract class DfsRefDatabase extends RefDatabase {
else
detachingSymbolicRef = detach && ref.isSymbolic();
- if (detachingSymbolicRef) {
- ref = new ObjectIdRef.Unpeeled(NEW, refName, ref.getObjectId());
- }
-
DfsRefUpdate update = new DfsRefUpdate(this, ref);
if (detachingSymbolicRef)
update.setDetachingSymbolicRef();
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java
index e5ca736824..108065913a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java
@@ -545,8 +545,6 @@ public class RefDirectory extends RefDatabase {
ref = new ObjectIdRef.Unpeeled(NEW, name, null);
else {
detachingSymbolicRef = detach && ref.isSymbolic();
- if (detachingSymbolicRef)
- ref = new ObjectIdRef.Unpeeled(LOOSE, name, ref.getObjectId());
}
RefDirectoryUpdate refDirUpdate = new RefDirectoryUpdate(this, ref);
if (detachingSymbolicRef)
@@ -579,7 +577,7 @@ public class RefDirectory extends RefDatabase {
}
void delete(RefDirectoryUpdate update) throws IOException {
- Ref dst = update.getRef().getLeaf();
+ Ref dst = update.getRef();
String name = dst.getName();
// Write the packed-refs file using an atomic update. We might
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectoryUpdate.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectoryUpdate.java
index 0d16f79ea1..3c1916b642 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectoryUpdate.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectoryUpdate.java
@@ -56,6 +56,7 @@ import org.eclipse.jgit.lib.Repository;
class RefDirectoryUpdate extends RefUpdate {
private final RefDirectory database;
+ private boolean shouldDeref;
private LockFile lock;
RefDirectoryUpdate(final RefDirectory r, final Ref ref) {
@@ -75,6 +76,7 @@ class RefDirectoryUpdate extends RefUpdate {
@Override
protected boolean tryLock(boolean deref) throws IOException {
+ shouldDeref = deref;
Ref dst = getRef();
if (deref)
dst = dst.getLeaf();
@@ -117,7 +119,7 @@ class RefDirectoryUpdate extends RefUpdate {
msg = strResult;
}
}
- database.log(this, msg, true);
+ database.log(this, msg, shouldDeref);
}
if (!lock.commit())
return Result.LOCK_FAILURE;
@@ -140,7 +142,7 @@ class RefDirectoryUpdate extends RefUpdate {
@Override
protected Result doDelete(final Result status) throws IOException {
- if (getRef().getLeaf().getStorage() != Ref.Storage.NEW)
+ if (getRef().getStorage() != Ref.Storage.NEW)
database.delete(this);
return status;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java
index c1027f0f75..fc334f0275 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java
@@ -551,7 +551,9 @@ public abstract class RefUpdate {
* @throws IOException
*/
public Result delete(final RevWalk walk) throws IOException {
- final String myName = getRef().getLeaf().getName();
+ final String myName = detachingSymbolicRef
+ ? getRef().getName()
+ : getRef().getLeaf().getName();
if (myName.startsWith(Constants.R_HEADS) && !getRepository().isBare()) {
// Don't allow the currently checked out branch to be deleted.
Ref head = getRefDatabase().getRef(Constants.HEAD);
@@ -628,7 +630,10 @@ public abstract class RefUpdate {
if (oldValue == null && checkConflicting && getRefDatabase().isNameConflicting(getName()))
return Result.LOCK_FAILURE;
try {
- if (!tryLock(true))
+ // If we're detaching a symbolic reference, we should update the reference
+ // itself. Otherwise, we will update the leaf reference, which should be
+ // an ObjectIdRef.
+ if (!tryLock(!detachingSymbolicRef))
return Result.LOCK_FAILURE;
if (expValue != null) {
final ObjectId o;