| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6951946 commit 542270c
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1240,22 +1240,27 @@ Repository.prototype.mergeheadForeach = function(callback) { | |||
| 1240 | 1240 | * @param {Boolean} stageNew Set to stage new filemode. Unset to unstage. | |
| 1241 | 1241 | * @return {Number} 0 or an error code | |
| 1242 | 1242 | */ | |
| 1243 | - Repository.prototype.stageFilemode = function(filePath, stageNew) { | ||
| 1243 | + Repository.prototype.stageFilemode = | ||
| 1244 | + function(filePath, stageNew, additionalDiffOptions) { | ||
| 1244 | 1245 | var repo = this; | |
| 1245 | 1246 | var index; | |
| 1247 | + var diffOptions = additionalDiffOptions ? { | ||
| 1248 | + flags: additionalDiffOptions | ||
| 1249 | + } : undefined; | ||
| 1246 | 1250 | var diffPromise = stageNew ? | |
| 1247 | 1251 | NodeGit.Diff.indexToWorkdir(repo, index, { | |
| 1248 | 1252 | flags: | |
| 1249 | 1253 | NodeGit.Diff.OPTION.SHOW_UNTRACKED_CONTENT | | |
| 1250 | - NodeGit.Diff.OPTION.RECURSE_UNTRACKED_DIRS | ||
| 1254 | + NodeGit.Diff.OPTION.RECURSE_UNTRACKED_DIRS | | ||
| 1255 | + (additionalDiffOptions || 0) | ||
| 1251 | 1256 | }) | |
| 1252 | 1257 | : | |
| 1253 | 1258 | repo.getHeadCommit() | |
| 1254 | 1259 | .then(function getTreeFromCommit(commit) { | |
| 1255 | 1260 | return commit.getTree(); | |
| 1256 | 1261 | }) | |
| 1257 | 1262 | .then(function getDiffFromTree(tree) { | |
| 1258 | - return NodeGit.Diff.treeToIndex(repo, tree, index); | ||
| 1263 | + return NodeGit.Diff.treeToIndex(repo, tree, index, diffOptions); | ||
| 1259 | 1264 | }); | |
| 1260 | 1265 | var filePaths = (filePath instanceof Array) ? filePath : [filePath]; | |
| 1261 | 1266 | ||
@@ -1311,7 +1316,11 @@ Repository.prototype.stageFilemode = function(filePath, stageNew) { | |||
| 1311 | 1316 | }); | |
| 1312 | 1317 | }; | |
| 1313 | 1318 | ||
| 1314 | - function getPathHunks(repo, index, filePath, isStaged) { | ||
| 1319 | + function getPathHunks(repo, index, filePath, isStaged, additionalDiffOptions) { | ||
| 1320 | + var diffOptions = additionalDiffOptions ? { | ||
| 1321 | + flags: additionalDiffOptions | ||
| 1322 | + } : undefined; | ||
| 1323 | + | ||
| 1315 | 1324 | return Promise.resolve() | |
| 1316 | 1325 | .then(function() { | |
| 1317 | 1326 | if (isStaged) { | |
@@ -1320,14 +1329,15 @@ function getPathHunks(repo, index, filePath, isStaged) { | |||
| 1320 | 1329 | return commit.getTree(); | |
| 1321 | 1330 | }) | |
| 1322 | 1331 | .then(function getDiffFromTree(tree) { | |
| 1323 | - return NodeGit.Diff.treeToIndex(repo, tree, index); | ||
| 1332 | + return NodeGit.Diff.treeToIndex(repo, tree, index, diffOptions); | ||
| 1324 | 1333 | }); | |
| 1325 | 1334 | } | |
| 1326 | 1335 | ||
| 1327 | 1336 | return NodeGit.Diff.indexToWorkdir(repo, index, { | |
| 1328 | 1337 | flags: | |
| 1329 | 1338 | NodeGit.Diff.OPTION.SHOW_UNTRACKED_CONTENT | | |
| 1330 | - NodeGit.Diff.OPTION.RECURSE_UNTRACKED_DIRS | ||
| 1339 | + NodeGit.Diff.OPTION.RECURSE_UNTRACKED_DIRS | | ||
| 1340 | + (additionalDiffOptions || 0) | ||
| 1331 | 1341 | }); | |
| 1332 | 1342 | }) | |
| 1333 | 1343 | .then(function(diff) { | |
@@ -1465,7 +1475,7 @@ function applySelectedLinesToTarget | |||
| 1465 | 1475 | * @return {Number} 0 or an error code | |
| 1466 | 1476 | */ | |
| 1467 | 1477 | Repository.prototype.stageLines = | |
| 1468 | - function(filePath, selectedLines, isSelectionStaged) { | ||
| 1478 | + function(filePath, selectedLines, isSelectionStaged, additionalDiffOptions) { | ||
| 1469 | 1479 | ||
| 1470 | 1480 | var repo = this; | |
| 1471 | 1481 | var index; | |
@@ -1479,7 +1489,8 @@ Repository.prototype.stageLines = | |||
| 1479 | 1489 | return NodeGit.Diff.indexToWorkdir(repo, index, { | |
| 1480 | 1490 | flags: | |
| 1481 | 1491 | NodeGit.Diff.OPTION.SHOW_UNTRACKED_CONTENT | | |
| 1482 | - NodeGit.Diff.OPTION.RECURSE_UNTRACKED_DIRS | ||
| 1492 | + NodeGit.Diff.OPTION.RECURSE_UNTRACKED_DIRS | | ||
| 1493 | + (additionalDiffOptions || 0) | ||
| 1483 | 1494 | }) | |
| 1484 | 1495 | .then(function(diff) { | |
| 1485 | 1496 | return diff.patches(); | |
@@ -1516,7 +1527,13 @@ Repository.prototype.stageLines = | |||
| 1516 | 1527 | .then(function(blob) { | |
| 1517 | 1528 | originalBlob = blob; | |
| 1518 | 1529 | ||
| 1519 | - return getPathHunks(repo, index, filePath, isSelectionStaged); | ||
| 1530 | + return getPathHunks( | ||
| 1531 | + repo, | ||
| 1532 | + index, | ||
| 1533 | + filePath, | ||
| 1534 | + isSelectionStaged, | ||
| 1535 | + additionalDiffOptions | ||
| 1536 | + ); | ||
| 1520 | 1537 | }) | |
| 1521 | 1538 | .then(function(hunks) { | |
| 1522 | 1539 | return applySelectedLinesToTarget( | |
@@ -1559,7 +1576,8 @@ Repository.prototype.stageLines = | |||
| 1559 | 1576 | * selected for discarding | |
| 1560 | 1577 | * @return {Number} 0 or an error code | |
| 1561 | 1578 | */ | |
| 1562 | - Repository.prototype.discardLines = function(filePath, selectedLines) { | ||
| 1579 | + Repository.prototype.discardLines = | ||
| 1580 | + function(filePath, selectedLines, additionalDiffOptions) { | ||
| 1563 | 1581 | var repo = this; | |
| 1564 | 1582 | var fullFilePath = path.join(repo.workdir(), filePath); | |
| 1565 | 1583 | var index; | |
@@ -1574,7 +1592,7 @@ Repository.prototype.discardLines = function(filePath, selectedLines) { | |||
| 1574 | 1592 | .then(function(content) { | |
| 1575 | 1593 | originalContent = content; | |
| 1576 | 1594 | ||
| 1577 | - return getPathHunks(repo, index, filePath, false); | ||
| 1595 | + return getPathHunks(repo, index, filePath, false, additionalDiffOptions); | ||
| 1578 | 1596 | }) | |
| 1579 | 1597 | .then(function(hunks) { | |
| 1580 | 1598 | return applySelectedLinesToTarget( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments