From: Yann Simon <yann.simon.fr@gmail.com>
To: "Shawn O. Pearce" <spearce@spearce.org>,
Robin Rosenberg <robin.rosenberg@dewire.com>
Cc: git@vger.kernel.org
Subject: [JGIT] help needed to create a siimple commit
Date: Tue, 3 Feb 2009 12:07:33 +0100 [thread overview]
Message-ID: <551f769b0902030307s2a9204cch7967df17c1f2c8a6@mail.gmail.com> (raw)
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
next reply other threads:[~2009-02-03 11:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-03 11:07 Yann Simon [this message]
2009-02-03 15:51 ` [JGIT] help needed to create a siimple commit Shawn O. Pearce
2009-02-04 16:10 ` Yann Simon
2009-02-04 17:07 ` Shawn O. Pearce
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=551f769b0902030307s2a9204cch7967df17c1f2c8a6@mail.gmail.com \
--to=yann.simon.fr@gmail.com \
--cc=git@vger.kernel.org \
--cc=robin.rosenberg@dewire.com \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).