aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2011-03-27 16:55:54 -0400
committerCode Review <codereview-daemon@eclipse.org>2011-03-27 16:55:54 -0400
commit23967441fc5b72996f5f29e197d52e763a14cb32 (patch)
treebb779309f694a1686831ad729613b0052fb56a51 /org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java
parent6e10c1da0018d2be47e4a0ac06a18205e82da673 (diff)
parent3a86868c0883d2a564db88bf9ae4a5fe235bb63f (diff)
downloadjgit-23967441fc5b72996f5f29e197d52e763a14cb32.tar.gz
jgit-23967441fc5b72996f5f29e197d52e763a14cb32.zip
Merge "Detaching HEAD when checking out the same commit."
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java20
1 files changed, 19 insertions, 1 deletions
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 e6f8933389..24af944f2f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java
@@ -168,6 +168,17 @@ public abstract class RefUpdate {
private final Ref ref;
/**
+ * Is this RefUpdate detaching a symbolic ref?
+ *
+ * We need this info since this.ref will normally be peeled of in case of
+ * detaching a symbolic ref (HEAD for example).
+ *
+ * Without this flag we cannot decide whether the ref has to be updated or
+ * not in case when it was a symbolic ref and the newValue == oldValue.
+ */
+ private boolean detachingSymbolicRef;
+
+ /**
* Construct a new update operation for the reference.
* <p>
* {@code ref.getObjectId()} will be used to seed {@link #getOldObjectId()},
@@ -254,6 +265,13 @@ public abstract class RefUpdate {
}
/**
+ * Tells this RefUpdate that it is actually detaching a symbolic ref.
+ */
+ public void setDetachingSymbolicRef() {
+ detachingSymbolicRef = true;
+ }
+
+ /**
* Set the new value the ref will update to.
*
* @param id
@@ -596,7 +614,7 @@ public abstract class RefUpdate {
newObj = safeParse(walk, newValue);
oldObj = safeParse(walk, oldValue);
- if (newObj == oldObj)
+ if (newObj == oldObj && !detachingSymbolicRef)
return store.execute(Result.NO_CHANGE);
if (newObj instanceof RevCommit && oldObj instanceof RevCommit) {