Title: `Repository.mergeBranches` creates dirty index after a non-conflicting merge · Issue #1217 · nodegit/nodegit · GitHub
Open Graph Title: `Repository.mergeBranches` creates dirty index after a non-conflicting merge · Issue #1217 · nodegit/nodegit
X Title: `Repository.mergeBranches` creates dirty index after a non-conflicting merge · Issue #1217 · nodegit/nodegit
Description: Run the code below. You will see that stuff gets printed indicating a dirty index. cd merge-commit-bug git status > git status On branch master Changes to be committed: (use "git reset HEAD
Open Graph Description: Run the code below. You will see that stuff gets printed indicating a dirty index. cd merge-commit-bug git status > git status On branch master Changes to be committed: (use "git reset HEAD
X Description: Run the code below. You will see that stuff gets printed indicating a dirty index. cd merge-commit-bug git status > git status On branch master Changes to be committed: (use "git reset HEAD...
Opengraph URL: https://github.com/nodegit/nodegit/issues/1217
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`Repository.mergeBranches` creates dirty index after a non-conflicting merge","articleBody":"1. Run the code below.\r\n2. You will see that stuff gets printed indicating a dirty index.\r\n3. `cd merge-commit-bug`\r\n4. `git status`\r\n```\r\n\u003e git status\r\nOn branch master\r\nChanges to be committed:\r\n (use \"git reset HEAD \u003cfile\u003e...\" to unstage)\r\n\r\n modified: test.txt\r\n```\r\n\r\nAll the tests in [`merge.js`](https://github.com/nodegit/nodegit/blob/4c8f601880a68d96ff59d18332e2d72524c05fe0/test/tests/merge.js) merges two random branches so the bug doesn't appear. The bug will only surfaces if you merge `HEAD` with another branch.\r\n\r\n```JavaScript\r\nvar path = require(\"path\");\r\nvar fs = require(\"fs\");\r\nvar git = require('.');\r\nvar repoDir = path.resolve(__dirname, \"merge-commit-bug\");\r\nvar name = \"test.txt\";\r\nvar name2 = \"test2.txt\";\r\nvar fileName = path.resolve(repoDir, name);\r\nvar fileName2 = path.resolve(repoDir, name2);\r\nvar repository;\r\nvar index;\r\nvar head;\r\nvar leftBranch;\r\n\r\nreturn git.Repository.init(repoDir, 0)\r\n.then(function(repo) {\r\n\trepository = repo;\r\n\tfs.writeFileSync(fileName, \"A\", null);\r\n\treturn repository.refreshIndex();\r\n})\r\n.then(function(idx) {\r\n\tindex = idx;\r\n\treturn index.addByPath(name);\r\n})\r\n.then(function() {\r\n\treturn index.writeTree();\r\n})\r\n.then(function(oid) {\r\n\treturn repository.createCommit(\"HEAD\",\r\n\t\tgit.Signature.default(repository),\r\n\t\tgit.Signature.default(repository),\r\n\t\t\"message\", oid, []);\r\n})\r\n.then(function(oid) {\r\n\thead = oid;\r\n\tfs.writeFileSync(fileName, \"B\", null);\r\n\treturn repository.refreshIndex();\r\n})\r\n.then(function(idx) {\r\n\tindex = idx;\r\n\treturn index.addByPath(name);\r\n})\r\n.then(function() {\r\n\treturn index.write();\r\n})\r\n.then(function() {\r\n\treturn index.writeTree();\r\n})\r\n.then(function(oid) {\r\n\treturn repository.createCommit(\"HEAD\",\r\n\t\tgit.Signature.default(repository),\r\n\t\tgit.Signature.default(repository),\r\n\t\t\"left\", oid, [ head ]);\r\n})\r\n.then(function(left) {\r\n\treturn repository.getCommit(left);\r\n})\r\n.then(function(commit) {\r\n\treturn git.Branch.create(repository, \"leftBranch\", commit, false);\r\n})\r\n.then(function(branch) {\r\n\tleftBranch = branch;\r\n\treturn repository.getCommit(head);\r\n})\r\n.then(function(commit) {\r\n\treturn git.Reset.reset(repository, commit, git.Reset.TYPE.HARD, {});\r\n})\r\n.then(function() {\r\n\tfs.writeFileSync(fileName2, \"C\", null);\r\n\treturn repository.refreshIndex();\r\n})\r\n.then(function(idx) {\r\n\tindex = idx;\r\n\treturn index.addByPath(name2);\r\n})\r\n.then(function() {\r\n\treturn index.write();\r\n})\r\n.then(function() {\r\n\treturn index.writeTree();\r\n})\r\n.then(function(oid) {\r\n\treturn repository.createCommit(\"HEAD\",\r\n\t\tgit.Signature.default(repository),\r\n\t\tgit.Signature.default(repository),\r\n\t\t\"right\", oid, [ head ]);\r\n})\r\n.then(function(commit) {\r\n\treturn repository.mergeBranches(\"master\", leftBranch, git.Signature.default(repository), null, null);\r\n})\r\n.then(function() {\r\n\treturn repository.getStatus();\r\n})\r\n.then(function(statuses) {\r\n\tconsole.log(statuses);\r\n\tconsole.log(statuses[0].path());\r\n})\r\n.catch(function(err) {\r\n\tconsole.log(err);\r\n});\r\n```","author":{"url":"https://github.com/rcjsuen","@type":"Person","name":"rcjsuen"},"datePublished":"2017-02-08T10:50:18.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/1217/nodegit/issues/1217"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:178e67e0-c80b-1077-d994-9726c951388d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C752:A2119:1EE76DD:29DCB13:6970822F |
| html-safe-nonce | cefdbacbec3829aac35667d1e42fd28b1b41ca07d85a413bfe2a57a798ca6b70 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNzUyOkEyMTE5OjFFRTc2REQ6MjlEQ0IxMzo2OTcwODIyRiIsInZpc2l0b3JfaWQiOiIxNTYyMDE5NzA5NzEwMjcxMDIzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 7033233c33fc251ca7aaf93b4ff8f426f013d50f27fe9dcbe88fc4ef2ed89097 |
| hovercard-subject-tag | issue:206161069 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodegit/nodegit/1217/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ac2932cbc3cb35b9ebdc7cff5e16aeeb92f4f7cf4e12bcb60285a3b4a2b54b7d/nodegit/nodegit/issues/1217 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ac2932cbc3cb35b9ebdc7cff5e16aeeb92f4f7cf4e12bcb60285a3b4a2b54b7d/nodegit/nodegit/issues/1217 |
| og:image:alt | Run the code below. You will see that stuff gets printed indicating a dirty index. cd merge-commit-bug git status > git status On branch master Changes to be committed: (use "git reset HEAD |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rcjsuen |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9920a62ba22d06470388e2904804fb7e5ec51c9e35f81784e9191394c74b2bd2 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodegit/nodegit git https://github.com/nodegit/nodegit.git |
| octolytics-dimension-user_id | 657068 |
| octolytics-dimension-user_login | nodegit |
| octolytics-dimension-repository_id | 1383170 |
| octolytics-dimension-repository_nwo | nodegit/nodegit |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1383170 |
| octolytics-dimension-repository_network_root_nwo | nodegit/nodegit |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7d6181066430cc06553c8396ca201e194ae33cb9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width