git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[EGIT PATCH 05/10] Rename fields to avoid hiding of field names in ReadTreeTest

From
Robin Rosenberg <robin.rosenberg@dewire.com>
Date
Mar 16, 2009, 20:14 UTC
Message-ID
<1237234483-3405-6-git-send-email-robin.rosenberg@dewire.com>
In-Reply-To
<1237234483-3405-5-git-send-email-robin.rosenberg@dewire.com>
---
 .../tst/org/spearce/jgit/lib/ReadTreeTest.java     |  118 ++++++++++----------
 1 files changed, 59 insertions(+), 59 deletions(-)
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ReadTreeTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ReadTreeTest.java
index 6318633..c9d0565 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ReadTreeTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ReadTreeTest.java
@@ -49,10 +49,10 @@
 
 public class ReadTreeTest extends RepositoryTestCase {
 	
-	private Tree head;
-	private Tree merge;
-	private GitIndex index;
-	private WorkDirCheckout readTree;
+	private Tree theHead;
+	private Tree theMerge;
+	private GitIndex theIndex;
+	private WorkDirCheckout theReadTree;
 	// Each of these rules are from the read-tree manpage
 	// go there to see what they mean.
 	// Rule 0 is left out for obvious reasons :)
@@ -87,9 +87,9 @@ public void testRules1thru3_NoIndexEntry() throws IOException {
 	void setupCase(HashMap<String, String> headEntries, 
 			HashMap<String, String> mergeEntries, 
 			HashMap<String, String> indexEntries) throws IOException {
-		head = buildTree(headEntries);
-		merge = buildTree(mergeEntries);
-		index = buildIndex(indexEntries);
+		theHead = buildTree(headEntries);
+		theMerge = buildTree(mergeEntries);
+		theIndex = buildIndex(indexEntries);
 	}
 	
 	private GitIndex buildIndex(HashMap<String, String> indexEntries) throws IOException {
@@ -129,9 +129,9 @@ ObjectId genSha1(String data) {
 	}
 	
 	private WorkDirCheckout go() throws IOException {
-		readTree = new WorkDirCheckout(db, trash, head, index, merge);
-		readTree.prescanTwoTrees();
-		return readTree;
+		theReadTree = new WorkDirCheckout(db, trash, theHead, theIndex, theMerge);
+		theReadTree.prescanTwoTrees();
+		return theReadTree;
 	}
 
     // for these rules, they all have clean yes/no options
@@ -144,17 +144,17 @@ public void testRules4thru13_IndexEntryNotInHead() throws IOException {
 		idxMap = new HashMap<String, String>();
 		idxMap.put("foo", "foo");
 		setupCase(null, null, idxMap);
-		readTree = go();
+		theReadTree = go();
 		
-		assertTrue(readTree.updated.isEmpty());
-		assertTrue(readTree.removed.isEmpty());
-		assertTrue(readTree.conflicts.isEmpty());
+		assertTrue(theReadTree.updated.isEmpty());
+		assertTrue(theReadTree.removed.isEmpty());
+		assertTrue(theReadTree.conflicts.isEmpty());
 		
 		// rules 6 and 7
 		idxMap = new HashMap<String, String>();
 		idxMap.put("foo", "foo");
 		setupCase(null, idxMap, idxMap);
-		readTree = go();
+		theReadTree = go();
 
 		assertAllEmpty();
 		
@@ -166,9 +166,9 @@ public void testRules4thru13_IndexEntryNotInHead() throws IOException {
 		setupCase(null, mergeMap, idxMap);
 		go();
 		
-		assertTrue(readTree.updated.isEmpty());
-		assertTrue(readTree.removed.isEmpty());
-		assertTrue(readTree.conflicts.contains("foo"));
+		assertTrue(theReadTree.updated.isEmpty());
+		assertTrue(theReadTree.removed.isEmpty());
+		assertTrue(theReadTree.conflicts.contains("foo"));
 		
 		// rule 10
 		
@@ -177,29 +177,29 @@ public void testRules4thru13_IndexEntryNotInHead() throws IOException {
 		setupCase(headMap, null, idxMap);
 		go();
 		
-		assertTrue(readTree.removed.contains("foo"));
-		assertTrue(readTree.updated.isEmpty());
-		assertTrue(readTree.conflicts.isEmpty());
+		assertTrue(theReadTree.removed.contains("foo"));
+		assertTrue(theReadTree.updated.isEmpty());
+		assertTrue(theReadTree.conflicts.isEmpty());
 		
 		// rule 11
 		setupCase(headMap, null, idxMap);
 		new File(trash, "foo").delete();
 		writeTrashFile("foo", "bar");
-		index.getMembers()[0].forceRecheck();
+		theIndex.getMembers()[0].forceRecheck();
 		go();
 		
-		assertTrue(readTree.removed.isEmpty());
-		assertTrue(readTree.updated.isEmpty());
-		assertTrue(readTree.conflicts.contains("foo"));
+		assertTrue(theReadTree.removed.isEmpty());
+		assertTrue(theReadTree.updated.isEmpty());
+		assertTrue(theReadTree.conflicts.contains("foo"));
 		
 		// rule 12 & 13
 		headMap.put("foo", "head");
 		setupCase(headMap, null, idxMap);
 		go();
 		
-		assertTrue(readTree.removed.isEmpty());
-		assertTrue(readTree.updated.isEmpty());
-		assertTrue(readTree.conflicts.contains("foo"));
+		assertTrue(theReadTree.removed.isEmpty());
+		assertTrue(theReadTree.updated.isEmpty());
+		assertTrue(theReadTree.conflicts.contains("foo"));
 		
 		// rules 14 & 15
 		setupCase(headMap, headMap, idxMap);
@@ -209,7 +209,7 @@ public void testRules4thru13_IndexEntryNotInHead() throws IOException {
 		
 		// rules 16 & 17
 		setupCase(headMap, mergeMap, idxMap); go();
-		assertTrue(readTree.conflicts.contains("foo"));
+		assertTrue(theReadTree.conflicts.contains("foo"));
 		
 		// rules 18 & 19
 		setupCase(headMap, idxMap, idxMap); go();
@@ -217,51 +217,51 @@ public void testRules4thru13_IndexEntryNotInHead() throws IOException {
 		
 		// rule 20
 		setupCase(idxMap, mergeMap, idxMap); go();
-		assertTrue(readTree.updated.containsKey("foo"));
+		assertTrue(theReadTree.updated.containsKey("foo"));
 		
 		// rules 21
 		setupCase(idxMap, mergeMap, idxMap); 
 		new File(trash, "foo").delete();
 		writeTrashFile("foo", "bar");
-		index.getMembers()[0].forceRecheck();
+		theIndex.getMembers()[0].forceRecheck();
 		go();
-		assertTrue(readTree.conflicts.contains("foo"));
+		assertTrue(theReadTree.conflicts.contains("foo"));
 	}
 
 	private void assertAllEmpty() {
-		assertTrue(readTree.removed.isEmpty());
-		assertTrue(readTree.updated.isEmpty());
-		assertTrue(readTree.conflicts.isEmpty());
+		assertTrue(theReadTree.removed.isEmpty());
+		assertTrue(theReadTree.updated.isEmpty());
+		assertTrue(theReadTree.conflicts.isEmpty());
 	}
 	
 	public void testDirectoryFileSimple() throws IOException {
-		index = new GitIndex(db);
-		index.add(trash, writeTrashFile("DF", "DF"));
-		Tree treeDF = db.mapTree(index.writeTree());
+		theIndex = new GitIndex(db);
+		theIndex.add(trash, writeTrashFile("DF", "DF"));
+		Tree treeDF = db.mapTree(theIndex.writeTree());
 		
 		recursiveDelete(new File(trash, "DF"));
-		index = new GitIndex(db);
-		index.add(trash, writeTrashFile("DF/DF", "DF/DF"));
-		Tree treeDFDF = db.mapTree(index.writeTree());
+		theIndex = new GitIndex(db);
+		theIndex.add(trash, writeTrashFile("DF/DF", "DF/DF"));
+		Tree treeDFDF = db.mapTree(theIndex.writeTree());
 		
-		index = new GitIndex(db);
+		theIndex = new GitIndex(db);
 		recursiveDelete(new File(trash, "DF"));
 		
-		index.add(trash, writeTrashFile("DF", "DF"));
-		readTree = new WorkDirCheckout(db, trash, treeDF, index, treeDFDF);
-		readTree.prescanTwoTrees();
+		theIndex.add(trash, writeTrashFile("DF", "DF"));
+		theReadTree = new WorkDirCheckout(db, trash, treeDF, theIndex, treeDFDF);
+		theReadTree.prescanTwoTrees();
 		
-		assertTrue(readTree.removed.contains("DF"));
-		assertTrue(readTree.updated.containsKey("DF/DF"));
+		assertTrue(theReadTree.removed.contains("DF"));
+		assertTrue(theReadTree.updated.containsKey("DF/DF"));
 		
 		recursiveDelete(new File(trash, "DF"));
-		index = new GitIndex(db);
-		index.add(trash, writeTrashFile("DF/DF", "DF/DF"));
+		theIndex = new GitIndex(db);
+		theIndex.add(trash, writeTrashFile("DF/DF", "DF/DF"));
 		
-		readTree = new WorkDirCheckout(db, trash, treeDFDF, index, treeDF);
-		readTree.prescanTwoTrees();
-		assertTrue(readTree.removed.contains("DF/DF"));
-		assertTrue(readTree.updated.containsKey("DF"));
+		theReadTree = new WorkDirCheckout(db, trash, treeDFDF, theIndex, treeDF);
+		theReadTree.prescanTwoTrees();
+		assertTrue(theReadTree.removed.contains("DF/DF"));
+		assertTrue(theReadTree.updated.containsKey("DF"));
 	}
 	
 	/*
@@ -467,19 +467,19 @@ private void cleanUpDF() throws Exception {
 	}
 	
 	private void assertConflict(String s) {
-		assertTrue(readTree.conflicts.contains(s));
+		assertTrue(theReadTree.conflicts.contains(s));
 	}
 	
 	private void assertUpdated(String s) {
-		assertTrue(readTree.updated.containsKey(s));
+		assertTrue(theReadTree.updated.containsKey(s));
 	}
 	
 	private void assertRemoved(String s) {
-		assertTrue(readTree.removed.contains(s));
+		assertTrue(theReadTree.removed.contains(s));
 	}
 	
 	private void assertNoConflicts() {
-		assertTrue(readTree.conflicts.isEmpty());
+		assertTrue(theReadTree.conflicts.isEmpty());
 	}
 
 	private void doit(HashMap<String, String> h, HashMap<String, String>m,
@@ -545,8 +545,8 @@ public void testCloseNameConflicts1() throws IOException {
 	}
 
 	private void checkout() throws IOException {
-		readTree = new WorkDirCheckout(db, trash, head, index, merge);
-		readTree.checkout();
+		theReadTree = new WorkDirCheckout(db, trash, theHead, theIndex, theMerge);
+		theReadTree.checkout();
 	}
 	
 	public void testCheckoutOutChanges() throws IOException {
-- 
1.6.1.285.g35d8b
Previous: Robin RosenbergNext: Robin Rosenberg
Message 6 of 15 in “JGit cleanups”
  1. 00/10 JGit cleanupsRobin Rosenberg, Mar 16, 2009
  2. 01/10 Require javadoc on protected methods in jgit coreRobin Rosenberg, Mar 16, 2009
  3. 02/10 Rename the objectsUrl in the nested HttpObjectDB toRobin Rosenberg, Mar 16, 2009
  4. 03/10 Rename variables that hides others with different content in FetchProcessRobin Rosenberg, Mar 16, 2009
  5. 04/10 Rename a parameter i PackWriter that hides another with the same nameRobin Rosenberg, Mar 16, 2009
  6. 05/10 Rename fields to avoid hiding of field names in ReadTreeTestRobin Rosenberg, Mar 16, 2009
  7. 06/10 Rename the gitDir fields to indicate they refer to another dir than the defaultRobin Rosenberg, Mar 16, 2009
  8. 07/10 Rename a parameter in PushProcessTest that hides anotherRobin Rosenberg, Mar 16, 2009
  9. 08/10 Drop unused end parameters in hunk parsing codeRobin Rosenberg, Mar 16, 2009
  10. 09/10 Drop unused File arguments in IndexTreeWalker and WorkdirCheckoutRobin Rosenberg, Mar 16, 2009
  11. 10/10 Drop an effectively unused parameter in IndexTreeWalker.Robin Rosenberg, Mar 16, 2009
  12. Shawn O. PearceMar 16, 2009
  13. Shawn O. PearceMar 16, 2009
  14. Robin RosenbergMar 16, 2009
  15. Shawn O. PearceMar 16, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.