@@ -9,8 +9,10 @@ Copyright (c) 2011, Tim Branyen @tbranyen <tim@tabdeveloper.com>
99#include " ../vendor/libgit2/src/git2.h"
1010
1111#include " repo.h"
12+ #include " blob.h"
1213#include " tree.h"
1314#include " object.h"
15+ #include " oid.h"
1416#include " tree_entry.h"
1517
1618using namespace v8 ;
@@ -37,8 +39,12 @@ const char* GitTreeEntry::Name() {
3739 return git_tree_entry_name (this ->entry );
3840}
3941
42+ const git_oid* GitTreeEntry::Id () {
43+ return git_tree_entry_id (this ->entry );
44+ }
45+
4046int GitTreeEntry::ToObject (git_object** obj) {
41- return git_tree_entry_2object (obj, entry);
47+ return git_tree_entry_2object (obj, this -> entry );
4248}
4349
4450Handle<Value> GitTreeEntry::New (const Arguments& args) {
@@ -59,20 +65,36 @@ Handle<Value> GitTreeEntry::Name(const Arguments& args) {
5965 return String::New (entry->Name ());
6066}
6167
68+ Handle<Value> GitTreeEntry::Id (const Arguments& args) {
69+ HandleScope scope;
70+
71+ GitTreeEntry *entry = ObjectWrap::Unwrap<GitTreeEntry>(args.This ());
72+
73+ if (args.Length () == 0 || !args[0 ]->IsObject ()) {
74+ return ThrowException (Exception::Error (String::New (" Oid is required and must be an Object." )));
75+ }
76+
77+ Oid* oid = ObjectWrap::Unwrap<Oid>(args[0 ]->ToObject ());
78+
79+ oid->SetValue (const_cast <git_oid *>(entry->Id ()));
80+
81+ return Undefined ();
82+ }
83+
6284Handle<Value> GitTreeEntry::ToObject (const Arguments& args) {
6385 HandleScope scope;
6486
6587 GitTreeEntry *entry = ObjectWrap::Unwrap<GitTreeEntry>(args.This ());
6688
6789 if (args.Length () == 0 || !args[0 ]->IsObject ()) {
68- return ThrowException (Exception::Error (String::New (" Object is required and must be an Object." )));
90+ return ThrowException (Exception::Error (String::New (" Blob is required and must be an Object." )));
6991 }
7092
71- GitObject*obj = ObjectWrap::Unwrap<GitObject >(args[0 ]->ToObject ());
93+ Blob* blob = ObjectWrap::Unwrap<Blob >(args[0 ]->ToObject ());
7294
7395 git_object* out;
7496 entry->ToObject (&out);
75- obj ->SetValue (out);
97+ blob ->SetValue ((git_blob *) out);
7698
7799 return Undefined ();
78100}
0 commit comments