FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/lib/diff.js at v0.26.3 · nodegit/nodegit · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
nodegit
/
nodegit
Public
Notifications
You must be signed in to change notification settings
Fork
700
Star
5.8k
Code
Issues
343
Pull requests
20
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nodegit
/
lib
/
diff.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
113 lines (101 loc) · 3.36 KB
Breadcrumbs
nodegit
/
lib
/
diff.js
Copy path
File metadata and controls
113 lines (101 loc) · 3.36 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
var
NodeGit
=
require
(
"../"
)
;
var
Diff
=
NodeGit
.
Diff
;
var
normalizeOptions
=
NodeGit
.
Utils
.
normalizeOptions
;
var
Patch
=
NodeGit
.
Patch
;
var
_blobToBuffer
=
Diff
.
blobToBuffer
;
var
_indexToWorkdir
=
Diff
.
indexToWorkdir
;
var
_treeToIndex
=
Diff
.
treeToIndex
;
var
_treeToTree
=
Diff
.
treeToTree
;
var
_treeToWorkdir
=
Diff
.
treeToWorkdir
;
var
_treeToWorkdirWithIndex
=
Diff
.
treeToWorkdirWithIndex
;
var
_findSimilar
=
Diff
.
prototype
.
findSimilar
;
/**
* Directly run a diff between a blob and a buffer.
*
@async
*
@param
{
Blob
} old_blob Blob for old side of diff, or NULL for empty blob
*
@param
{
String
} old_as_path Treat old blob as if it had this filename;
* can be NULL
*
@param
{
String
} buffer Raw data for new side of diff, or NULL for empty
*
@param
{
String
} buffer_as_path Treat buffer as if it had this filename;
* can be NULL
*
@param
{
DiffOptions
} opts Options for diff, or NULL for default options
*
@param
{
Function
} file_cb Callback for "file"; made once if there is a diff;
* can be NULL
*
@param
{
Function
} binary_cb Callback for binary files; can be NULL
*
@param
{
Function
} hunk_cb Callback for each hunk in diff; can be NULL
*
@param
{
Function
} line_cb Callback for each line in diff; can be NULL
*/
Diff
.
blobToBuffer
=
function
(
old_blob
,
old_as_path
,
buffer
,
buffer_as_path
,
opts
,
file_cb
,
binary_cb
,
hunk_cb
,
line_cb
)
{
var
bufferText
;
var
bufferLength
;
if
(
buffer
instanceof
Buffer
)
{
bufferText
=
buffer
.
toString
(
"utf8"
)
;
bufferLength
=
Buffer
.
byteLength
(
buffer
,
"utf8"
)
;
}
else
{
bufferText
=
buffer
;
bufferLength
=
!
buffer
?
0
:
Buffer
.
byteLength
(
buffer
,
"utf8"
)
;
}
opts
=
normalizeOptions
(
opts
,
NodeGit
.
DiffOptions
)
;
return
_blobToBuffer
.
call
(
this
,
old_blob
,
old_as_path
,
bufferText
,
bufferLength
,
buffer_as_path
,
opts
,
file_cb
,
binary_cb
,
hunk_cb
,
line_cb
,
null
)
;
}
;
// Override Diff.indexToWorkdir to normalize opts
Diff
.
indexToWorkdir
=
function
(
repo
,
index
,
opts
)
{
opts
=
normalizeOptions
(
opts
,
NodeGit
.
DiffOptions
)
;
return
_indexToWorkdir
(
repo
,
index
,
opts
)
;
}
;
// Override Diff.treeToIndex to normalize opts
Diff
.
treeToIndex
=
function
(
repo
,
tree
,
index
,
opts
)
{
opts
=
normalizeOptions
(
opts
,
NodeGit
.
DiffOptions
)
;
return
_treeToIndex
(
repo
,
tree
,
index
,
opts
)
;
}
;
// Override Diff.treeToTree to normalize opts
Diff
.
treeToTree
=
function
(
repo
,
from_tree
,
to_tree
,
opts
)
{
opts
=
normalizeOptions
(
opts
,
NodeGit
.
DiffOptions
)
;
return
_treeToTree
(
repo
,
from_tree
,
to_tree
,
opts
)
;
}
;
// Override Diff.treeToWorkdir to normalize opts
Diff
.
treeToWorkdir
=
function
(
repo
,
tree
,
opts
)
{
opts
=
normalizeOptions
(
opts
,
NodeGit
.
DiffOptions
)
;
return
_treeToWorkdir
(
repo
,
tree
,
opts
)
;
}
;
// Override Diff.treeToWorkdir to normalize opts
Diff
.
treeToWorkdirWithIndex
=
function
(
repo
,
tree
,
opts
)
{
opts
=
normalizeOptions
(
opts
,
NodeGit
.
DiffOptions
)
;
return
_treeToWorkdirWithIndex
(
repo
,
tree
,
opts
)
;
}
;
// Override Diff.findSimilar to normalize opts
Diff
.
prototype
.
findSimilar
=
function
(
opts
)
{
opts
=
normalizeOptions
(
opts
,
NodeGit
.
DiffFindOptions
)
;
return
_findSimilar
.
call
(
this
,
opts
)
;
}
;
/**
* Retrieve patches in this difflist
*
*
@async
*
@return
{
Array<ConvenientPatch>
} a promise that resolves to an array of
* ConvenientPatches
*/
Diff
.
prototype
.
patches
=
function
(
)
{
return
Patch
.
convenientFromDiff
(
this
)
;
}
;
Back
|
FazBrowse Home
|
New Git URL