[JGIT] help needed to create a siimple commit

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

 



Hi,

I wrote the following unit test to learn how to make a commit with JGIT:

package org.spearce.jgit.lib;

import java.io.File;
import java.io.IOException;

public class CommitTest extends RepositoryTestCase {

	public void testASimpleCommit() throws IOException {
		
		GitIndex index = new GitIndex(db);
		index.filemode = Boolean.TRUE;
		
		File file;
		file = writeTrashFile("file1", "file1");
		
		index.add(trash, file);
		index.write();
		ObjectId objectId = index.writeTree();
		Tree tree = db.mapTree(objectId);
		tree.accept(new WriteTree(trash, db), TreeEntry.MODIFIED_ONLY);
		
		final Commit c1 = new Commit(db);
		c1.setAuthor(new PersonIdent(jauthor, 1154236443000L, -4 * 60));
		c1.setCommitter(new PersonIdent(jcommitter, 1154236443000L, -4 * 60));
		c1.setMessage("A Commit\n");
		c1.setTree(tree);
		assertEquals(tree.getTreeId(), c1.getTreeId());
		c1.commit();
		
	}
}

But the result is not brillant.
In the trash workspace, git log does not show me my commit.
git diff --cached shows me that my file is in the index but not committed...

Thank for the help.

Yann
--
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