Skip to content

Commit baaa417

Browse files
committed
Updated to libgit2 v12, a few minor tweaks
1 parent 9cc3fbf commit baaa417

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2842
-551
lines changed

example/stress/revwalk.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var git = require( 'nodegit' );
1515
//console.log( 'Branch opened' );
1616

1717
this.history().on( 'commit', function( i, commit ) {
18-
console.log( commit.id.toString(40) );
18+
//console.log( commit.id.toString(40) );
1919
});
2020

2121
});

src/tree.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ size_t GitTree::EntryCount() {
4545
}
4646

4747
git_tree_entry* GitTree::EntryByIndex(int idx) {
48-
return git_tree_entry_byindex(this->tree, idx);
48+
return const_cast<git_tree_entry*>(git_tree_entry_byindex(this->tree, idx));
4949
}
5050

5151
git_tree_entry* GitTree::EntryByName(const char* name) {
52-
return git_tree_entry_byname(this->tree, name);
52+
return const_cast<git_tree_entry*>(git_tree_entry_byname(this->tree, name));
5353
}
5454

5555
int GitTree::SortEntries() {

src/tree_entry.cc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,25 +97,25 @@ Handle<Value> GitTreeEntry::Id(const Arguments& args) {
9797
Handle<Value> GitTreeEntry::ToObject(const Arguments& args) {
9898
HandleScope scope;
9999

100-
GitTreeEntry *entry = ObjectWrap::Unwrap<GitTreeEntry>(args.This());
100+
//GitTreeEntry *entry = ObjectWrap::Unwrap<GitTreeEntry>(args.This());
101101

102-
if(args.Length() == 0 || !args[0]->IsObject()) {
103-
return ThrowException(Exception::Error(String::New("Repo is required and must be an Object.")));
104-
}
102+
//if(args.Length() == 0 || !args[0]->IsObject()) {
103+
// return ThrowException(Exception::Error(String::New("Repo is required and must be an Object.")));
104+
//}
105105

106-
if(args.Length() == 1 || !args[1]->IsObject()) {
107-
return ThrowException(Exception::Error(String::New("Object is required and must be an Object.")));
108-
}
106+
//if(args.Length() == 1 || !args[1]->IsObject()) {
107+
// return ThrowException(Exception::Error(String::New("Object is required and must be an Object.")));
108+
//}
109109

110-
GitRepo* repo = ObjectWrap::Unwrap<GitRepo>(args[0]->ToObject());
111-
GitObject* object = ObjectWrap::Unwrap<GitObject(args[1]->ToObject());
110+
//GitRepo* repo = ObjectWrap::Unwrap<GitRepo>(args[0]->ToObject());
111+
//GitObject* object = ObjectWrap::Unwrap<GitObject(args[1]->ToObject());
112112

113-
git_object* out;
114-
entry->ToObject(repo->GetValue(), &out);
113+
//git_object* out;
114+
//entry->ToObject(repo->GetValue(), &out);
115115

116-
GitObject->SetValue(out);
117-
118-
return scope.Close(;
116+
//GitObject->SetValue(out);
117+
//
118+
return scope.Close(Undefined());
119119
}
120120
Persistent<FunctionTemplate> GitTreeEntry::constructor_template;
121121

vendor/libgit2/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ The waf build system for libgit2 accepts the following flags:
8585
--arch=[ia64|x64|x86|x86_amd64|x86_ia64]
8686
Force a specific architecture for compilers that support it.
8787

88-
--without-sqlite
89-
Disable sqlite support.
88+
--with-sqlite
89+
Enable sqlite support.
9090

9191
You can run `./waf --help` to see a full list of install options and
9292
targets.

vendor/libgit2/include/git2.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
#ifndef INCLUDE_git_git_h__
2727
#define INCLUDE_git_git_h__
2828

29-
#define LIBGIT2_VERSION "0.11.0"
29+
#define LIBGIT2_VERSION "0.12.0"
3030
#define LIBGIT2_VER_MAJOR 0
31-
#define LIBGIT2_VER_MINOR 10
31+
#define LIBGIT2_VER_MINOR 12
3232
#define LIBGIT2_VER_REVISION 0
3333

3434
#include "git2/common.h"

vendor/libgit2/include/git2/commit.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,16 @@ GIT_EXTERN(const git_signature *) git_commit_author(git_commit *commit);
135135
*/
136136
GIT_EXTERN(int) git_commit_tree(git_tree **tree_out, git_commit *commit);
137137

138+
/**
139+
* Get the id of the tree pointed to by a commit. This differs from
140+
* `git_commit_tree` in that no attempts are made to fetch an object
141+
* from the ODB.
142+
*
143+
* @param commit a previously loaded commit.
144+
* @return the id of tree pointed to by commit.
145+
*/
146+
GIT_EXTERN(const git_oid *) git_commit_tree_oid(git_commit *commit);
147+
138148
/**
139149
* Get the number of parents of this commit
140150
*
@@ -153,6 +163,16 @@ GIT_EXTERN(unsigned int) git_commit_parentcount(git_commit *commit);
153163
*/
154164
GIT_EXTERN(int) git_commit_parent(git_commit **parent, git_commit *commit, unsigned int n);
155165

166+
/**
167+
* Get the oid of a specified parent for a commit. This is different from
168+
* `git_commit_parent`, which will attempt to load the parent commit from
169+
* the ODB.
170+
*
171+
* @param commit a previously loaded commit.
172+
* @param n the position of the parent (from 0 to `parentcount`)
173+
* @return the id of the parent, NULL on error.
174+
*/
175+
GIT_EXTERN(const git_oid *) git_commit_parent_oid(git_commit *commit, unsigned int n);
156176

157177
/**
158178
* Create a new commit in the repository

vendor/libgit2/include/git2/common.h

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -84,83 +84,6 @@
8484
* @{
8585
*/
8686

87-
/** Operation completed successfully. */
88-
#define GIT_SUCCESS 0
89-
90-
/**
91-
* Operation failed, with unspecified reason.
92-
* This value also serves as the base error code; all other
93-
* error codes are subtracted from it such that all errors
94-
* are < 0, in typical POSIX C tradition.
95-
*/
96-
#define GIT_ERROR -1
97-
98-
/** Input was not a properly formatted Git object id. */
99-
#define GIT_ENOTOID (GIT_ERROR - 1)
100-
101-
/** Input does not exist in the scope searched. */
102-
#define GIT_ENOTFOUND (GIT_ERROR - 2)
103-
104-
/** Not enough space available. */
105-
#define GIT_ENOMEM (GIT_ERROR - 3)
106-
107-
/** Consult the OS error information. */
108-
#define GIT_EOSERR (GIT_ERROR - 4)
109-
110-
/** The specified object is of invalid type */
111-
#define GIT_EOBJTYPE (GIT_ERROR - 5)
112-
113-
/** The specified object has its data corrupted */
114-
#define GIT_EOBJCORRUPTED (GIT_ERROR - 6)
115-
116-
/** The specified repository is invalid */
117-
#define GIT_ENOTAREPO (GIT_ERROR - 7)
118-
119-
/** The object type is invalid or doesn't match */
120-
#define GIT_EINVALIDTYPE (GIT_ERROR - 8)
121-
122-
/** The object cannot be written because it's missing internal data */
123-
#define GIT_EMISSINGOBJDATA (GIT_ERROR - 9)
124-
125-
/** The packfile for the ODB is corrupted */
126-
#define GIT_EPACKCORRUPTED (GIT_ERROR - 10)
127-
128-
/** Failed to acquire or release a file lock */
129-
#define GIT_EFLOCKFAIL (GIT_ERROR - 11)
130-
131-
/** The Z library failed to inflate/deflate an object's data */
132-
#define GIT_EZLIB (GIT_ERROR - 12)
133-
134-
/** The queried object is currently busy */
135-
#define GIT_EBUSY (GIT_ERROR - 13)
136-
137-
/** The index file is not backed up by an existing repository */
138-
#define GIT_EBAREINDEX (GIT_ERROR - 14)
139-
140-
/** The name of the reference is not valid */
141-
#define GIT_EINVALIDREFNAME (GIT_ERROR - 15)
142-
143-
/** The specified reference has its data corrupted */
144-
#define GIT_EREFCORRUPTED (GIT_ERROR - 16)
145-
146-
/** The specified symbolic reference is too deeply nested */
147-
#define GIT_ETOONESTEDSYMREF (GIT_ERROR - 17)
148-
149-
/** The pack-refs file is either corrupted or its format is not currently supported */
150-
#define GIT_EPACKEDREFSCORRUPTED (GIT_ERROR - 18)
151-
152-
/** The path is invalid */
153-
#define GIT_EINVALIDPATH (GIT_ERROR - 19)
154-
155-
/** The revision walker is empty; there are no more commits left to iterate */
156-
#define GIT_EREVWALKOVER (GIT_ERROR - 20)
157-
158-
/** The state of the reference is not valid */
159-
#define GIT_EINVALIDREFSTATE (GIT_ERROR - 21)
160-
161-
/** This feature has not been implemented yet */
162-
#define GIT_ENOTIMPLEMENTED (GIT_ERROR - 22)
163-
16487
GIT_BEGIN_DECL
16588

16689
typedef struct {

vendor/libgit2/include/git2/errors.h

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,112 @@
3333
*/
3434
GIT_BEGIN_DECL
3535

36+
/** Operation completed successfully. */
37+
#define GIT_SUCCESS 0
38+
39+
/**
40+
* Operation failed, with unspecified reason.
41+
* This value also serves as the base error code; all other
42+
* error codes are subtracted from it such that all errors
43+
* are < 0, in typical POSIX C tradition.
44+
*/
45+
#define GIT_ERROR -1
46+
47+
/** Input was not a properly formatted Git object id. */
48+
#define GIT_ENOTOID (GIT_ERROR - 1)
49+
50+
/** Input does not exist in the scope searched. */
51+
#define GIT_ENOTFOUND (GIT_ERROR - 2)
52+
53+
/** Not enough space available. */
54+
#define GIT_ENOMEM (GIT_ERROR - 3)
55+
56+
/** Consult the OS error information. */
57+
#define GIT_EOSERR (GIT_ERROR - 4)
58+
59+
/** The specified object is of invalid type */
60+
#define GIT_EOBJTYPE (GIT_ERROR - 5)
61+
62+
/** The specified object has its data corrupted */
63+
#define GIT_EOBJCORRUPTED (GIT_ERROR - 6)
64+
65+
/** The specified repository is invalid */
66+
#define GIT_ENOTAREPO (GIT_ERROR - 7)
67+
68+
/** The object type is invalid or doesn't match */
69+
#define GIT_EINVALIDTYPE (GIT_ERROR - 8)
70+
71+
/** The object cannot be written because it's missing internal data */
72+
#define GIT_EMISSINGOBJDATA (GIT_ERROR - 9)
73+
74+
/** The packfile for the ODB is corrupted */
75+
#define GIT_EPACKCORRUPTED (GIT_ERROR - 10)
76+
77+
/** Failed to acquire or release a file lock */
78+
#define GIT_EFLOCKFAIL (GIT_ERROR - 11)
79+
80+
/** The Z library failed to inflate/deflate an object's data */
81+
#define GIT_EZLIB (GIT_ERROR - 12)
82+
83+
/** The queried object is currently busy */
84+
#define GIT_EBUSY (GIT_ERROR - 13)
85+
86+
/** The index file is not backed up by an existing repository */
87+
#define GIT_EBAREINDEX (GIT_ERROR - 14)
88+
89+
/** The name of the reference is not valid */
90+
#define GIT_EINVALIDREFNAME (GIT_ERROR - 15)
91+
92+
/** The specified reference has its data corrupted */
93+
#define GIT_EREFCORRUPTED (GIT_ERROR - 16)
94+
95+
/** The specified symbolic reference is too deeply nested */
96+
#define GIT_ETOONESTEDSYMREF (GIT_ERROR - 17)
97+
98+
/** The pack-refs file is either corrupted or its format is not currently supported */
99+
#define GIT_EPACKEDREFSCORRUPTED (GIT_ERROR - 18)
100+
101+
/** The path is invalid */
102+
#define GIT_EINVALIDPATH (GIT_ERROR - 19)
103+
104+
/** The revision walker is empty; there are no more commits left to iterate */
105+
#define GIT_EREVWALKOVER (GIT_ERROR - 20)
106+
107+
/** The state of the reference is not valid */
108+
#define GIT_EINVALIDREFSTATE (GIT_ERROR - 21)
109+
110+
/** This feature has not been implemented yet */
111+
#define GIT_ENOTIMPLEMENTED (GIT_ERROR - 22)
112+
113+
/** A reference with this name already exists */
114+
#define GIT_EEXISTS (GIT_ERROR - 23)
115+
116+
/** The given integer literal is too large to be parsed */
117+
#define GIT_EOVERFLOW (GIT_ERROR - 24)
118+
119+
/** The given literal is not a valid number */
120+
#define GIT_ENOTNUM (GIT_ERROR - 25)
121+
122+
/** Streaming error */
123+
#define GIT_ESTREAM (GIT_ERROR - 26)
124+
125+
/** invalid arguments to function */
126+
#define GIT_EINVALIDARGS (GIT_ERROR - 27)
127+
128+
/**
129+
* Return a detailed error string with the latest error
130+
* that occurred in the library.
131+
* @return a string explaining the error
132+
*/
133+
GIT_EXTERN(const char *) git_lasterror(void);
134+
36135
/**
37136
* strerror() for the Git library
137+
*
138+
* Get a string description for a given error code.
139+
* NOTE: This method will be eventually deprecated in favor
140+
* of the new `git_lasterror`.
141+
*
38142
* @param num The error code to explain
39143
* @return a string explaining the error code
40144
*/

0 commit comments

Comments
 (0)