test_class.file: server-core/src/test/java/io/onedev/server/git/BlobEditsTest.java
test_class.identifier: BlobEditsTest
test_class.superclass: extends AbstractGitTest
test_case.body: @Test
  	public void testOrder() throws IOException {
  		addFileAndCommit("file", "", "first commit");
  		createDir("client/security");
  		addFileAndCommit("client/security/file", "a", "add a");
  				
  		String refName = "refs/heads/master";
  		ObjectId oldCommitId = git.getRepository().resolve(refName);
  
  		Map<String, BlobContent> newBlobs = new HashMap<>();
  		newBlobs.put("client/dir2/file4", new BlobContent.Immutable("c".getBytes(), FileMode.REGULAR_FILE));
  		newBlobs.put("client/security/dir1/file2", new BlobContent.Immutable("d".getBytes(), FileMode.REGULAR_FILE));
  		newBlobs.put("client/security/dir2/file3", new BlobContent.Immutable("d".getBytes(), FileMode.REGULAR_FILE));
  		newBlobs.put("client/dir1/file1", new BlobContent.Immutable("d".getBytes(), FileMode.REGULAR_FILE));
  		newBlobs.put("client/security/dir1/subdir/file", new BlobContent.Immutable("d".getBytes(), FileMode.REGULAR_FILE));
  		newBlobs.put("client/dir1/file0", new BlobContent.Immutable("d".getBytes(), FileMode.REGULAR_FILE));
  		newBlobs.put("server/file2", new BlobContent.Immutable("d".getBytes(), FileMode.REGULAR_FILE));
  		newBlobs.put("server/file1", new BlobContent.Immutable("d".getBytes(), FileMode.REGULAR_FILE));
  		BlobEdits edits = new BlobEdits(Sets.newHashSet(), newBlobs);
  		ObjectId newCommitId = edits.commit(git.getRepository(), refName, oldCommitId, oldCommitId, user, "test add");
  
  		List<String> paths = new ArrayList<>();
  		try (	RevWalk revWalk = new RevWalk(git.getRepository());
  				TreeWalk treeWalk = new TreeWalk(git.getRepository());) {
  			treeWalk.addTree(revWalk.parseCommit(newCommitId).getTree());
  			treeWalk.setRecursive(true);
  			while (treeWalk.next()) {
  				paths.add(treeWalk.getPathString());
  			}
  		}
  
  		assertEquals(10, paths.size());
  		assertEquals("client/dir1/file0", paths.get(0));
  		assertEquals("client/dir1/file1", paths.get(1));
  		assertEquals("client/dir2/file4", paths.get(2));
  		assertEquals("client/security/dir1/file2", paths.get(3));
  		assertEquals("client/security/dir1/subdir/file", paths.get(4));
  		assertEquals("client/security/dir2/file3", paths.get(5));
  		assertEquals("client/security/file", paths.get(6));
  		assertEquals("file", paths.get(7));
  		assertEquals("server/file1", paths.get(8));
  		assertEquals("server/file2", paths.get(9));
  	}
test_case.class_method_signature: BlobEditsTest.testOrder()
test_case.full_signature: @Test public void testOrder()
test_case.identifier: testOrder
test_case.invocations: addFileAndCommit createDir addFileAndCommit resolve getRepository put getBytes put getBytes put getBytes put getBytes put getBytes put getBytes put getBytes put getBytes newHashSet commit getRepository getRepository getRepository addTree getTree parseCommit setRecursive next add getPathString assertEquals size assertEquals get assertEquals get assertEquals get assertEquals get assertEquals get assertEquals get assertEquals get assertEquals get assertEquals get assertEquals get
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testOrder()
focal_class.declarator: serialVersionUID = 1L
focal_class.modifier: private static final
focal_class.original_string: private static final long serialVersionUID = 1L;
focal_class.type: long
focal_class.var_name: serialVersionUID
focal_class.declarator: oldPaths
focal_class.modifier: private final
focal_class.original_string: private final Set<String> oldPaths;
focal_class.type: Set<String>
focal_class.var_name: oldPaths
focal_class.declarator: newBlobs
focal_class.modifier: private final
focal_class.original_string: private final Map<String, BlobContent> newBlobs;
focal_class.type: Map<String, BlobContent>
focal_class.var_name: newBlobs
focal_class.file: server-core/src/main/java/io/onedev/server/git/BlobEdits.java
focal_class.identifier: BlobEdits
focal_class.interfaces: implements Serializable
focal_class.class_method_signature: BlobEdits.BlobEdits(Set<String> oldPaths, Map<String, BlobContent> newBlobs)
focal_class.full_signature: public  BlobEdits(Set<String> oldPaths, Map<String, BlobContent> newBlobs)
focal_class.identifier: BlobEdits
focal_class.modifiers: public
focal_class.parameters: (Set<String> oldPaths, Map<String, BlobContent> newBlobs)
focal_class.signature:  BlobEdits(Set<String> oldPaths, Map<String, BlobContent> newBlobs)
focal_class.class_method_signature: BlobEdits.getOldPaths()
focal_class.full_signature: public Set<String> getOldPaths()
focal_class.identifier: getOldPaths
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Set<String>
focal_class.signature: Set<String> getOldPaths()
focal_class.class_method_signature: BlobEdits.getNewBlobs()
focal_class.full_signature: public Map<String, BlobContent> getNewBlobs()
focal_class.identifier: getNewBlobs
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Map<String, BlobContent>
focal_class.signature: Map<String, BlobContent> getNewBlobs()
focal_class.class_method_signature: BlobEdits.insertTree(RevTree revTree, TreeWalk treeWalk, ObjectInserter inserter, 
  			String parentPath, Set<String> currentOldPaths, Map<String, BlobContent> currentNewBlobs)
focal_class.full_signature: private ObjectId insertTree(RevTree revTree, TreeWalk treeWalk, ObjectInserter inserter, 
  			String parentPath, Set<String> currentOldPaths, Map<String, BlobContent> currentNewBlobs)
focal_class.identifier: insertTree
focal_class.modifiers: private
focal_class.parameters: (RevTree revTree, TreeWalk treeWalk, ObjectInserter inserter, 
  			String parentPath, Set<String> currentOldPaths, Map<String, BlobContent> currentNewBlobs)
focal_class.return: ObjectId
focal_class.signature: ObjectId insertTree(RevTree revTree, TreeWalk treeWalk, ObjectInserter inserter, 
  			String parentPath, Set<String> currentOldPaths, Map<String, BlobContent> currentNewBlobs)
focal_class.class_method_signature: BlobEdits.commit(Repository repository, String refName, ObjectId expectedOldCommitId, ObjectId parentCommitId, 
  			PersonIdent authorAndCommitter, String commitMessage)
focal_class.full_signature: public ObjectId commit(Repository repository, String refName, ObjectId expectedOldCommitId, ObjectId parentCommitId, 
  			PersonIdent authorAndCommitter, String commitMessage)
focal_class.identifier: commit
focal_class.modifiers: public
focal_class.parameters: (Repository repository, String refName, ObjectId expectedOldCommitId, ObjectId parentCommitId, 
  			PersonIdent authorAndCommitter, String commitMessage)
focal_class.return: ObjectId
focal_class.signature: ObjectId commit(Repository repository, String refName, ObjectId expectedOldCommitId, ObjectId parentCommitId, 
  			PersonIdent authorAndCommitter, String commitMessage)
focal_method.body: public ObjectId commit(Repository repository, String refName, ObjectId expectedOldCommitId, ObjectId parentCommitId, 
  			PersonIdent authorAndCommitter, String commitMessage) {
  		
  		try (	RevWalk revWalk = new RevWalk(repository); 
  				TreeWalk treeWalk = new TreeWalk(repository);
  				ObjectInserter inserter = repository.newObjectInserter();) {
  
  	        CommitBuilder commit = new CommitBuilder();
  	        
  	        commit.setAuthor(authorAndCommitter);
  	        commit.setCommitter(authorAndCommitter);
  	        commit.setMessage(commitMessage);
  
  			RevTree revTree;
  	        if (!parentCommitId.equals(ObjectId.zeroId())) {
  	        	commit.setParentId(parentCommitId);
  				revTree = revWalk.parseCommit(parentCommitId).getTree();
  				treeWalk.addTree(revTree);
  	        } else {
  				revTree = null;
  	        }
  
  			ObjectId treeId = insertTree(revTree, treeWalk, inserter, null, new HashSet<>(oldPaths), 
  					new HashMap<>(newBlobs));
  	        
  	        if (treeId != null)
  	        	commit.setTreeId(treeId);
  	        else 
  	        	commit.setTreeId(inserter.insert(new TreeFormatter()));
  	        
  	        ObjectId commitId = inserter.insert(commit);
  	        inserter.flush();
  	        RefUpdate ru = repository.updateRef(refName);
  	        ru.setRefLogIdent(authorAndCommitter);
  	        ru.setNewObjectId(commitId);
  	        ru.setExpectedOldObjectId(expectedOldCommitId);
  	        GitUtils.updateRef(ru);
  	        
  	        return commitId;
  		} catch (RevisionSyntaxException | IOException e) {
  			throw new RuntimeException(e);
  		}
  	}
focal_method.class_method_signature: BlobEdits.commit(Repository repository, String refName, ObjectId expectedOldCommitId, ObjectId parentCommitId, 
  			PersonIdent authorAndCommitter, String commitMessage)
focal_method.full_signature: public ObjectId commit(Repository repository, String refName, ObjectId expectedOldCommitId, ObjectId parentCommitId, 
  			PersonIdent authorAndCommitter, String commitMessage)
focal_method.identifier: commit
focal_method.invocations: newObjectInserter setAuthor setCommitter setMessage equals zeroId setParentId getTree parseCommit addTree insertTree setTreeId setTreeId insert insert flush updateRef setRefLogIdent setNewObjectId setExpectedOldObjectId updateRef
focal_method.modifiers: public
focal_method.parameters: (Repository repository, String refName, ObjectId expectedOldCommitId, ObjectId parentCommitId, 
  			PersonIdent authorAndCommitter, String commitMessage)
focal_method.return: ObjectId
focal_method.signature: ObjectId commit(Repository repository, String refName, ObjectId expectedOldCommitId, ObjectId parentCommitId, 
  			PersonIdent authorAndCommitter, String commitMessage)