Title: UnifiedDiffReader.parseUnifiedDiff(): Using unified diff with no prefix in file names leads to cut file names in some cases. · Issue #141 · java-diff-utils/java-diff-utils · GitHub
Open Graph Title: UnifiedDiffReader.parseUnifiedDiff(): Using unified diff with no prefix in file names leads to cut file names in some cases. · Issue #141 · java-diff-utils/java-diff-utils
X Title: UnifiedDiffReader.parseUnifiedDiff(): Using unified diff with no prefix in file names leads to cut file names in some cases. · Issue #141 · java-diff-utils/java-diff-utils
Description: Describe the bug When using an unified diff with no a/, b/ prefix in file names as input for UnifiedDiffReader.parseUnifiedDiff(), extracted file names are cut when they start with one of a, b, old new. This seems to be due to this piece...
Open Graph Description: Describe the bug When using an unified diff with no a/, b/ prefix in file names as input for UnifiedDiffReader.parseUnifiedDiff(), extracted file names are cut when they start with one of a, b, old...
X Description: Describe the bug When using an unified diff with no a/, b/ prefix in file names as input for UnifiedDiffReader.parseUnifiedDiff(), extracted file names are cut when they start with one of a, b, old...
Opengraph URL: https://github.com/java-diff-utils/java-diff-utils/issues/141
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"UnifiedDiffReader.parseUnifiedDiff(): Using unified diff with no prefix in file names leads to cut file names in some cases.","articleBody":"**Describe the bug**\r\nWhen using an unified diff with no a/, b/ prefix in file names as input for UnifiedDiffReader.parseUnifiedDiff(), extracted file names are cut when they start with one of a, b, old new. This seems to be due to this piece of code:\r\n```\r\nreturn line.substring(4).replaceFirst(\"^(a|b|old|new)(\\\\/)?\", \"\")\r\n .trim();\r\n```\r\nwhich is located at UnifiedDiffReader::356 in a method called `extractFileName`.\r\n\r\n**To Reproduce**\r\nSteps to reproduce the behavior:\r\n1. Example data: Use an unified diff that contains at least one file whose name starts with \"a\", \"b\", \"old\" or \"new\".\r\nFor example:\r\n```\r\n--- a.txt\r\n+++ a1.txt\r\n@@ -8,7 +8,7 @@\r\n \u003cSetting\u003e\r\n \u003cSetting a\u003e\r\n \u003csetting b\u003e\r\n- \u003cvalue\u003e23\u003c/value\u003e\r\n+ \u003cvalue\u003e24\u003c/value\u003e\r\n \u003c/setting b\u003e\r\n \u003csetting c\u003e\r\n \u003cvalue\u003e1\u003c/value\u003e\r\n```\r\n2. simple program snippet\r\n```\r\nval diff = \"\"\"\r\n --- a.txt\r\n +++ a1.txt\r\n @@ -8,7 +8,7 @@\r\n \u003cSetting\u003e\r\n \u003cSetting a\u003e\r\n \u003csetting b\u003e\r\n - \u003cvalue\u003e23\u003c/value\u003e\r\n + \u003cvalue\u003e24\u003c/value\u003e\r\n \u003c/setting b\u003e\r\n \u003csetting c\u003e\r\n \u003cvalue\u003e1\u003c/value\u003e\r\n \"\"\".trimIndent()\r\nval unifiedDiff = UnifiedDiffReader.parseUnifiedDiff(diff.byteInputStream())\r\nunifiedDiff.files.forEach { unifiedDiffFile -\u003e\r\n println(unifiedDiffFile.fromFile)\r\n println(unifiedDiffFile.toFile)\r\n}\r\n```\r\n3. See error\r\n\r\nThis snipet prints:\r\n```\r\n.txt\r\n1.txt\r\n```\r\n**Expected behavior**\r\nThe snippet should print:\r\n```\r\na.txt\r\na1.txt\r\n```\r\n\r\n**System**\r\n - Java version 11\r\n - Version 4.11\r\n","author":{"url":"https://github.com/IgnacioGarcia198","@type":"Person","name":"IgnacioGarcia198"},"datePublished":"2022-01-11T09:09:38.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/141/java-diff-utils/issues/141"}
| 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:c4933d90-9203-a024-787b-277914a2f5f3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D064:3053B5:11B11D:180FA0:6969648F |
| html-safe-nonce | 2c3b8dc9c890f7af6d3657963637333e55bcac0010950e64b7a6c067c00a9dd6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMDY0OjMwNTNCNToxMUIxMUQ6MTgwRkEwOjY5Njk2NDhGIiwidmlzaXRvcl9pZCI6IjE4NDM2MjE2NTQyNDM2NjUwMzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d34a7c0571a20550364faf98519b35d09111efac50091c96aefa82c27b063a6e |
| hovercard-subject-tag | issue:1098885536 |
| 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/java-diff-utils/java-diff-utils/141/issue_layout |
| twitter:image | https://opengraph.githubassets.com/937a424a101873388b8725763f22bbe47ef376f53499bd5ffa762f6ba69d932a/java-diff-utils/java-diff-utils/issues/141 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/937a424a101873388b8725763f22bbe47ef376f53499bd5ffa762f6ba69d932a/java-diff-utils/java-diff-utils/issues/141 |
| og:image:alt | Describe the bug When using an unified diff with no a/, b/ prefix in file names as input for UnifiedDiffReader.parseUnifiedDiff(), extracted file names are cut when they start with one of a, b, old... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | IgnacioGarcia198 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 48487c1ad776a7975b7132d95f4240ff3ae37cd5b8e3cb597102a4edb76738f1 |
| turbo-cache-control | no-preview |
| go-import | github.com/java-diff-utils/java-diff-utils git https://github.com/java-diff-utils/java-diff-utils.git |
| octolytics-dimension-user_id | 40540835 |
| octolytics-dimension-user_login | java-diff-utils |
| octolytics-dimension-repository_id | 86663812 |
| octolytics-dimension-repository_nwo | java-diff-utils/java-diff-utils |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 86663812 |
| octolytics-dimension-repository_network_root_nwo | java-diff-utils/java-diff-utils |
| 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 | 669463fcc54773a88c1f5a44eef6b99a5504b9c7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width