layout
default
menu_item
api
title
Patch
description
Version 0.26.1
return_to
API Documentation Index
/api/
sections
convenientFromDiff
fromBlobs
fromDiff
#getDelta
#getHunk
#getLineInHunk
#lineStats
#numHunks
#numLinesInHunk
#size
#convenientFromDiff
#fromBlobs
#fromDiff
#getDelta
#getHunk
#getLineInHunk
#lineStats
#numHunks
#numLinesInHunk
#size
Patch. convenientFromDiff Async
Patch . convenientFromDiff ( diff ) . then ( function ( stdVectorPatchdata ) {
// Use stdVectorPatchdata
} ) ;
Parameters
Type
diff
Diff
Returns
StdVectorPatchdata
Patch . fromBlobs ( old_blob , old_as_path , new_blob , new_as_path , opts ) . then ( function ( patch ) {
// Use patch
} ) ;
Parameters
Type
old_blob
Blob
Blob for old side of diff, or NULL for empty blob
old_as_path
String
Treat old blob as if it had this filename; can be NULL
new_blob
Blob
Blob for new side of diff, or NULL for empty blob
new_as_path
String
Treat new blob as if it had this filename; can be NULL
opts
DiffOptions
Options for diff, or NULL for default options
Returns
Patch
The generated patch; NULL on error
Patch . fromDiff ( diff , idx ) . then ( function ( patch ) {
// Use patch
} ) ;
Parameters
Type
diff
Diff
Diff list object
idx
Number
Index into diff list
Returns
Patch
Output parameter for the delta patch object
var diffDelta = patch . getDelta ( ) ;
patch . getHunk ( hunk_idx ) . then ( function ( result ) {
// Use result
} ) ;
| Parameters | Type |
| --- | --- | --- |
| hunk_idx | Number | Input index of hunk to get information about |
Returns
Number
Output count of total lines in this hunk
Patch# getLineInHunk Async
patch . getLineInHunk ( hunk_idx , line_of_hunk ) . then ( function ( diffLine ) {
// Use diffLine
} ) ;
| Parameters | Type |
| --- | --- | --- |
| hunk_idx | Number | The index of the hunk |
| line_of_hunk | Number | The index of the line in the hunk |
Returns
DiffLine
The git_diff_line data for this line
var result = patch . lineStats ( ) ;
Returns
Number
Count of deletion lines in output, can be NULL.
var result = patch . numHunks ( ) ;
Patch# numLinesInHunk Sync
var result = patch . numLinesInHunk ( hunk_idx ) ;
| Parameters | Type |
| --- | --- | --- |
| hunk_idx | Number | Index of the hunk |
Returns
Number
Number of lines in hunk or GIT_ENOTFOUND if invalid hunk index
var result = patch . size ( include_context , include_hunk_headers , include_file_headers ) ;
| Parameters | Type |
| --- | --- | --- |
| include_context | Number | Include context lines in size if non-zero |
| include_hunk_headers | Number | Include hunk header lines if non-zero |
| include_file_headers | Number | Include file header lines if non-zero |
Returns
Number
The number of bytes of data