[PATCH] Reset the graph plotter internals when HEAD has changed.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Robin Rosenberg <robin.rosenberg@xxxxxxxxxx>

When we reset HEAD to an old revision it becomes more visible than when
we add a new commit. This is an intermediate solution.

Signed-off-by: Robin Rosenberg <robin.rosenberg@xxxxxxxxxx>

diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
index 27cda08..278e1e4 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
@@ -162,6 +162,9 @@ public class GitHistoryPage extends HistoryPage {
 	/** Revision walker that allocated our graph's commit nodes. */
 	private SWTWalk currentWalk;
 
+	/** Last HEAD */
+	private AnyObjectId currentHeadId;
+
 	/**
 	 * Highlight flag that can be applied to commits to make them stand out.
 	 * <p>
@@ -521,8 +524,18 @@ public class GitHistoryPage extends HistoryPage {
 		if (db == null)
 			return false;
 
+		final AnyObjectId headId;
+		try {
+			headId = db.resolve("HEAD");
+		} catch (IOException e) {
+			Activator.logError("Cannot parse HEAD in: "
+					+ db.getDirectory().getAbsolutePath(), e);
+			return false;
+		}
+
 		if (currentWalk == null || currentWalk.getRepository() != db
-				|| pathChange(pathFilters, paths)) {
+				|| pathChange(pathFilters, paths)
+				|| headId != null && !headId.equals(currentHeadId)) {
 			currentWalk = new SWTWalk(db);
 			currentWalk.sort(RevSort.COMMIT_TIME_DESC, true);
 			currentWalk.sort(RevSort.BOUNDARY, true);
@@ -531,13 +544,12 @@ public class GitHistoryPage extends HistoryPage {
 			currentWalk.reset();
 		}
 
+		if (headId == null)
+			return false;
 		try {
-			final AnyObjectId headId = db.resolve("HEAD");
-			if (headId == null)
-				return false;
 			currentWalk.markStart(currentWalk.parseCommit(headId));
 		} catch (IOException e) {
-			Activator.logError("Cannot parse HEAD in: "
+			Activator.logError("Cannot read HEAD commit " + headId + " in: "
 					+ db.getDirectory().getAbsolutePath(), e);
 			return false;
 		}
-- 
1.5.5.1.178.g1f811

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux