FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Made the diff methods prototype methods · usrlocalts/nodegit@a2a5479 · GitHub

Repository navigation

Commit a2a5479

Browse files
committed
Made the diff methods prototype methods
1 parent 8c83ea5 commit a2a5479

11 files changed

Lines changed: 612 additions & 613 deletions

File tree

‎include/diff_list.h‎

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -31,78 +31,6 @@ class GitDiffList : public ObjectWrap {
3131
static Handle<Value> New(const Arguments& args);
3232

3333

34-
static Handle<Value> TreeToTree(const Arguments& args);
35-
static void TreeToTreeWork(uv_work_t* req);
36-
static void TreeToTreeAfterWork(uv_work_t* req);
37-
38-
struct TreeToTreeBaton {
39-
uv_work_t request;
40-
int error_code;
41-
const git_error* error;
42-
git_diff_list * diff;
43-
Persistent<Value> repoReference;
44-
git_repository * repo;
45-
Persistent<Value> old_treeReference;
46-
git_tree * old_tree;
47-
Persistent<Value> new_treeReference;
48-
git_tree * new_tree;
49-
Persistent<Value> optsReference;
50-
const git_diff_options * opts;
51-
Persistent<Function> callback;
52-
};
53-
static Handle<Value> TreeToIndex(const Arguments& args);
54-
static void TreeToIndexWork(uv_work_t* req);
55-
static void TreeToIndexAfterWork(uv_work_t* req);
56-
57-
struct TreeToIndexBaton {
58-
uv_work_t request;
59-
int error_code;
60-
const git_error* error;
61-
git_diff_list * diff;
62-
Persistent<Value> repoReference;
63-
git_repository * repo;
64-
Persistent<Value> old_treeReference;
65-
git_tree * old_tree;
66-
Persistent<Value> indexReference;
67-
git_index * index;
68-
Persistent<Value> optsReference;
69-
const git_diff_options * opts;
70-
Persistent<Function> callback;
71-
};
72-
static Handle<Value> IndexToWorkdir(const Arguments& args);
73-
static void IndexToWorkdirWork(uv_work_t* req);
74-
static void IndexToWorkdirAfterWork(uv_work_t* req);
75-
76-
struct IndexToWorkdirBaton {
77-
uv_work_t request;
78-
int error_code;
79-
const git_error* error;
80-
git_diff_list * diff;
81-
Persistent<Value> repoReference;
82-
git_repository * repo;
83-
Persistent<Value> indexReference;
84-
git_index * index;
85-
Persistent<Value> optsReference;
86-
const git_diff_options * opts;
87-
Persistent<Function> callback;
88-
};
89-
static Handle<Value> TreeToWorkdir(const Arguments& args);
90-
static void TreeToWorkdirWork(uv_work_t* req);
91-
static void TreeToWorkdirAfterWork(uv_work_t* req);
92-
93-
struct TreeToWorkdirBaton {
94-
uv_work_t request;
95-
int error_code;
96-
const git_error* error;
97-
git_diff_list * diff;
98-
Persistent<Value> repoReference;
99-
git_repository * repo;
100-
Persistent<Value> old_treeReference;
101-
git_tree * old_tree;
102-
Persistent<Value> optsReference;
103-
const git_diff_options * opts;
104-
Persistent<Function> callback;
105-
};
10634
static Handle<Value> Merge(const Arguments& args);
10735
static Handle<Value> FindSimilar(const Arguments& args);
10836
static Handle<Value> Size(const Arguments& args);

‎include/index.h‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,23 @@ class GitIndex : public ObjectWrap {
119119
static Handle<Value> ConflictRemove(const Arguments& args);
120120
static Handle<Value> ConflictCleanup(const Arguments& args);
121121
static Handle<Value> HasConflicts(const Arguments& args);
122+
static Handle<Value> IndexToWorkdir(const Arguments& args);
123+
static void IndexToWorkdirWork(uv_work_t* req);
124+
static void IndexToWorkdirAfterWork(uv_work_t* req);
125+
126+
struct IndexToWorkdirBaton {
127+
uv_work_t request;
128+
int error_code;
129+
const git_error* error;
130+
git_diff_list * diff;
131+
Persistent<Value> repoReference;
132+
git_repository * repo;
133+
Persistent<Value> indexReference;
134+
git_index * index;
135+
Persistent<Value> optsReference;
136+
const git_diff_options * opts;
137+
Persistent<Function> callback;
138+
};
122139
git_index *raw;
123140
};
124141

‎include/tree.h‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,61 @@ class GitTree : public ObjectWrap {
5151
const char * path;
5252
Persistent<Function> callback;
5353
};
54+
static Handle<Value> DiffTree(const Arguments& args);
55+
static void DiffTreeWork(uv_work_t* req);
56+
static void DiffTreeAfterWork(uv_work_t* req);
57+
58+
struct DiffTreeBaton {
59+
uv_work_t request;
60+
int error_code;
61+
const git_error* error;
62+
git_diff_list * diff;
63+
Persistent<Value> repoReference;
64+
git_repository * repo;
65+
Persistent<Value> old_treeReference;
66+
git_tree * old_tree;
67+
Persistent<Value> new_treeReference;
68+
git_tree * new_tree;
69+
Persistent<Value> optsReference;
70+
const git_diff_options * opts;
71+
Persistent<Function> callback;
72+
};
73+
static Handle<Value> DiffIndex(const Arguments& args);
74+
static void DiffIndexWork(uv_work_t* req);
75+
static void DiffIndexAfterWork(uv_work_t* req);
76+
77+
struct DiffIndexBaton {
78+
uv_work_t request;
79+
int error_code;
80+
const git_error* error;
81+
git_diff_list * diff;
82+
Persistent<Value> repoReference;
83+
git_repository * repo;
84+
Persistent<Value> old_treeReference;
85+
git_tree * old_tree;
86+
Persistent<Value> indexReference;
87+
git_index * index;
88+
Persistent<Value> optsReference;
89+
const git_diff_options * opts;
90+
Persistent<Function> callback;
91+
};
92+
static Handle<Value> DiffWorkDir(const Arguments& args);
93+
static void DiffWorkDirWork(uv_work_t* req);
94+
static void DiffWorkDirAfterWork(uv_work_t* req);
95+
96+
struct DiffWorkDirBaton {
97+
uv_work_t request;
98+
int error_code;
99+
const git_error* error;
100+
git_diff_list * diff;
101+
Persistent<Value> repoReference;
102+
git_repository * repo;
103+
Persistent<Value> old_treeReference;
104+
git_tree * old_tree;
105+
Persistent<Value> optsReference;
106+
const git_diff_options * opts;
107+
Persistent<Function> callback;
108+
};
54109
git_tree *raw;
55110
};
56111

‎lib/commit.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ Commit.prototype.history = function() {
161161
event.emit('commit', null, commit);
162162
commits.push(commit);
163163
});
164-
}
164+
};
165165
return event;
166166
};
167167

@@ -183,7 +183,7 @@ Commit.prototype.parents = function(callback) {
183183

184184
rawCommit.parent(n, function nextParent(error, rawParentCommit) {
185185
if (error) return callback(error);
186-
processParents(rawParentCommit, n-1, acc.concat([new Commit(self.repo, rawParentCommit)]), callback)
186+
processParents(rawParentCommit, n-1, acc.concat([new Commit(self.repo, rawParentCommit)]), callback);
187187
});
188188
}
189189

@@ -214,7 +214,7 @@ Commit.prototype.parentsDiffTrees = function(callback) {
214214
self.getTree(function(error, thisTree) {
215215
if (error) return callback(error);
216216

217-
git.diffList.treeToTree(self.repo, parentTree, thisTree, function walkDiffList(error, diffList) {
217+
parentTree.diff(thisTree, function walkDiffList(error, diffList) {
218218
if (error) return callback(error);
219219

220220
parentDiffLists.push(diffList);

‎lib/diff_list.js‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,6 @@ DiffList.LineOrigin = {
4949
/** 'B' */ Binary: 102
5050
};
5151

52-
DiffList.treeToTree = function(repo, oldTree, newTree, callback) {
53-
git.raw.DiffList.treeToTree(repo.rawRepo, oldTree.rawTree, newTree.rawTree, null, function(error, rawDiffList) {
54-
if (error) return callback(new git.error(error.message, error.code), null);
55-
56-
callback(null, new DiffList(rawDiffList));
57-
});
58-
};
59-
6052

6153
/**
6254
* Retrieve patches

‎lib/tree.js‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,18 @@ Tree.prototype.entry = function(path, callback) {
4444
* Retrieve the number of entries in this tree.
4545
*/
4646
Tree.prototype.size = function() {
47-
return self.rawTree.size();
47+
return this.rawTree.size();
48+
};
49+
50+
/**
51+
* Diff two trees
52+
*/
53+
Tree.prototype.diff = function(that, callback) {
54+
this.rawTree.diffTree(this.repo.rawRepo, that.rawTree, null, function(error, rawDiffList) {
55+
if (error) return callback(error);
56+
57+
callback(null, new git.diffList(rawDiffList));
58+
});
4859
};
4960

5061
/**

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL