forked from nodegit/nodegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiff.js
More file actions
61 lines (57 loc) · 1.31 KB
/
diff.js
File metadata and controls
61 lines (57 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
var git = require('../');
var Diff = git.Diff;
var Patch = git.Patch;
var ConvenientPatch = require('./convenient_patch').ConvenientPatch;
var events = require('events');
Object.defineProperties(Diff.prototype, {
size: {
value: Diff.prototype.numDeltas,
enumerable: false
}
});
/**
* Refer to vendor/libgit2/include/git2/diff.h for delta type definitions.
*
* @readonly
* @enum {Integer}
*/
Diff.Delta = {
/** 0 */ Unmodified: 0,
/** 1 */ Added: 1,
/** 2 */ Deleted: 2,
/** 3 */ Modified: 3,
/** 4 */ Renamed: 4,
/** 5 */ Copied: 5,
/** 6 */ Ignored: 6,
/** 7 */ Untracked: 7,
/** 8 */ TypeChange: 8
};
/**
* Refer to vendor/libgit2/include/git2/diff.h for line origin type definitions.
*
* @readOnly
* @enum {String}
*/
Diff.LineOrigin = {
/** ' ' */ Context: 32,
/** '+' */ Addition: 43,
/** '-' */ Deletion: 45,
/** '\n' */ AddEofNl: 13,
/** '' */ DelEofNl: 0,
/** 'F' */ FileHdr: 106,
/** 'H' */ HunkHdr: 110,
/** 'B' */ Binary: 102
};
/**
* Retrieve patches in this difflist
*
* @return {[ConvenientPatch]} an array of ConvenientPatches
*/
Diff.prototype.patches = function() {
var size = this.size();
var result = [];
for (var i = 0; i < size; i++) {
result.push(new ConvenientPatch(this.getDelta(i), Patch.fromDiff(this, i)));
}
return result;
};