Title: "Invalid collation character" when trying to diff · Issue #1097 · nodegit/nodegit · GitHub
Open Graph Title: "Invalid collation character" when trying to diff · Issue #1097 · nodegit/nodegit
X Title: "Invalid collation character" when trying to diff · Issue #1097 · nodegit/nodegit
Description: I'm not 100% sure whether this is a nodegit or a libgit2 issue, so apologies in advanced if this isn't nodegit's fault. When trying to get diffs for certain commits, I'm getting the error "Invalid collation character" returned from nodeg...
Open Graph Description: I'm not 100% sure whether this is a nodegit or a libgit2 issue, so apologies in advanced if this isn't nodegit's fault. When trying to get diffs for certain commits, I'm getting the error "Invalid ...
X Description: I'm not 100% sure whether this is a nodegit or a libgit2 issue, so apologies in advanced if this isn't nodegit's fault. When trying to get diffs for certain commits, I'm getting the...
Opengraph URL: https://github.com/nodegit/nodegit/issues/1097
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"\"Invalid collation character\" when trying to diff","articleBody":"I'm not 100% sure whether this is a nodegit or a libgit2 issue, so apologies in advanced if this isn't nodegit's fault.\n\nWhen trying to get diffs for certain commits, I'm getting the error \"Invalid collation character\" returned from nodegit. However, this isn't for every commit, and it's not for every platform either. I've only been able to get this to happen in this situation:\n- Using nodegit (tested a whole mess of versions, mainly v0.13.2 and v0.15.1)\n- Running under electron (only tested v1.2.3)\n- On Linux (64-bit, haven't tested 32-bit; specifically on the latest releases of Debian and Ubuntu)\n\nIf I'm on any other platform (e.g. just pure nodejs not electron, or Windows or OSX) the problem doesn't happen.\n\nThe easiest way to reproduce the problem is to grab a clone of the sources for git itself: https://github.com/git/git\n\nAnd then run some variation of this script under electron:\n\n``` js\nvar git = require(\"nodegit\");\n\ngit.Repository.open(\"/home/tyler/Desktop/git\")\n .then(\n (repo) =\u003e {\n console.log(\"Repo is open.\");\n\n return repo.getCommit(\"f5236a776f31de2654bca9001aa74ef9fe0819d8\")\n .then(\n (commit) =\u003e {\n return commit.getTree();\n }\n )\n .then(\n (tree) =\u003e {\n return git.Diff.treeToWorkdir(repo, tree, new git.DiffOptions());\n }\n )\n ;\n }\n )\n .then(\n (diff) =\u003e {\n console.log(\"Got the diff\");\n\n return diff.patches()\n .then(\n (patches) =\u003e {\n console.log(\"Got the patches.\");\n console.log(\"Files changed:\");\n\n patches.forEach(\n (patch) =\u003e {\n let newPath = patch.newFile().path();\n let oldPath = patch.oldFile().path();\n console.log(newPath, oldPath);\n }\n );\n }\n )\n ;\n }\n )\n .then(\n () =\u003e {\n console.log(\"Done!\");\n }\n )\n .catch(\n (error) =\u003e {\n console.error(\"Some error occurred:\");\n console.error(error);\n }\n )\n;\n```\n\nWhich, instead of logging the files changed in that commit as I would expect, it outputs this instead:\n\n```\nRepo is open.\nGot the diff\nSome error occurred:\nError: Invalid collation character\n at Error (native)\n```\n\nI'm not terribly familiar with debugging C programs on linux, but I was able to piece together this stack trace:\n\n```\nGitPatch::ConvenientFromDiffWorker::Execute\ngit_patch_from_diff\ndiff_patch_alloc_from_diff\ndiff_patch_init_from_diff\ngit_diff_file_content__init_from_diff\ndiff_file_content_init_common\ngit_diff_driver_lookup\ngit_diff_driver_load\ngit_diff_driver_builtin\nregcomp # The function that actually returns the error.\n```\n\nFor some reason `git_diff_driver_builtin` is using a regex to determine the diff driver to use, and that regex is failing for whatever reason.\n\nEven weirder, it doesn't fail for every commit, but a lot of them. Here are some notes I took while trying to figure this out:\n\n```\nmaster (as of this writing): f8f7adce9fc50a11a764d57815602dcb818d1816\nLast good commit on master (found by using git reset --hard HEAD~1): b48dfd86c90cae3f98dca01101b7e298c0192d16\nFirst bad commit on master: ad2d77760434e1650c186c71fa04a8fdbd77266c\nLast bad commit on master: f5236a776f31de2654bca9001aa74ef9fe0819d8\nFirst good commit before the above bad commit: 566fdaf611f44724120412a43132c07b020fc4f1\nUseful command for going back that far: git reset --hard HEAD~35\n```\n\nReasons why I'm filing a nodegit issue instead of a libgit2 issue:\n- I'm only seeing this under electron, so maybe nodegit is doing something funny when compiled for electron?\n- Perhaps we could patch nodegit so that we can specify the diff driver to use for `diff.patches()`? Otherwise I'm not sure how to work around this.\n\nLet me know if there's any other information I can provide, or generally if anyone has any ideas. I can follow the libgit2 code, but I haven't been able to figure out understand why a regex would be (seemly randomly) failing.\n","author":{"url":"https://github.com/tylerchurch","@type":"Person","name":"tylerchurch"},"datePublished":"2016-08-01T23:30:34.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":20},"url":"https://github.com/1097/nodegit/issues/1097"}
| 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:be9c8ff3-7e9c-4006-f60d-f09f41f13226 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 924A:16A45E:BC69FE:106044B:6970F657 |
| html-safe-nonce | 2e366a8abfac96124203af6529bb54e2858cd61d505e5c6e71119f7a44907850 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MjRBOjE2QTQ1RTpCQzY5RkU6MTA2MDQ0Qjo2OTcwRjY1NyIsInZpc2l0b3JfaWQiOiI0NTA5NDcwNzU5MjM4ODI1NTU5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 21b57402353059a45e5fe4baaf84490c2a9f2fca06453cbeaf514e70e0d7eb7b |
| hovercard-subject-tag | issue:168765822 |
| 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/1097/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1d3a5ce8a15dfb86a8745b23e27e80d2a68c9d987f22cb52a487e22acfb7f4c9/nodegit/nodegit/issues/1097 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1d3a5ce8a15dfb86a8745b23e27e80d2a68c9d987f22cb52a487e22acfb7f4c9/nodegit/nodegit/issues/1097 |
| og:image:alt | I'm not 100% sure whether this is a nodegit or a libgit2 issue, so apologies in advanced if this isn't nodegit's fault. When trying to get diffs for certain commits, I'm getting the error "Invalid ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tylerchurch |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1b239ebed690c3053869ff31a3b7597834c25673659d63e7b6fd6a9b5d7853de |
| 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 | aeacfd55297f3de5395c83f200ac35d1f474115e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width