[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jgit-dev] Implementing git-cat-file, git-ls-tree...
|
On Tue, Aug 17, 2010 at 8:46 AM, Ketan Padegaonkar
<ketanpadegaonkar@xxxxxxxxx> wrote:
> I'm in the process of implementing an open source jruby web based source
> browser for git across a product we build.
>
> In order to get this to work, I *think* what I need at the bare minimum is
> something like git-cat-file that can output contents of files/blobs, and
> git-ls-tree to view a snapshot of the directory listings.
>
> Are there any quick examples that I can look at to implement these features
> and contribute them back as patches ?
Well, we have ls-tree already implemented:
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsTree.java
And cat-file is reasonably simple:
int type;
if (argv[0].equals("blob"))
type = Constants.OBJ_BLOB;
...
ObjectId id = ObjectId.fromString(argv[1]);
ObjectLoader ldr = db.open(id, type);
byte[] tmp = new byte[1024];
InputStream in = ldr.openInputStream();
int n;
while ((n = in.read(tmp)) > 0)
System.out.write(tmp, 0, n);
in.close();
--
Shawn.