René's URL Explorer Experiment


Title: generateUnifiedDiff starts an empty hunk range one line too high · Issue #239 · java-diff-utils/java-diff-utils · GitHub

Open Graph Title: generateUnifiedDiff starts an empty hunk range one line too high · Issue #239 · java-diff-utils/java-diff-utils

X Title: generateUnifiedDiff starts an empty hunk range one line too high · Issue #239 · java-diff-utils/java-diff-utils

Description: This bug was found by an automated program we have running that writes tests with hegel (but I have personally reviewed it). More details at the bottom, but the short version is that I am not personally affected by this bug, and if that'...

Open Graph Description: This bug was found by an automated program we have running that writes tests with hegel (but I have personally reviewed it). More details at the bottom, but the short version is that I am not perso...

X Description: This bug was found by an automated program we have running that writes tests with hegel (but I have personally reviewed it). More details at the bottom, but the short version is that I am not perso...

Opengraph URL: https://github.com/java-diff-utils/java-diff-utils/issues/239

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"generateUnifiedDiff starts an empty hunk range one line too high","articleBody":"> This bug was found by an automated program we have running that writes tests with [hegel](https://github.com/hegeldev/hegel-java) (but I have personally reviewed it). More details at the bottom, but the short version is that I am not personally affected by this bug, and if that's not welcome then please feel free to disregard it.\n\n**Describe the bug**\n\nWhen one side of a hunk is empty (an insertion written with no context lines, or the deletion of a whole file), `generateUnifiedDiff` starts that range one line later than `diff -U0` and `git diff -U0` do: appending `x` to a three-line file gives `@@ -4,0 +4,1 @@` where both tools write `@@ -3,0 +4,1 @@`, and deleting all three lines gives `@@ -1,3 +1,0 @@` where both write `@@ -1,3 +0,0 @@`. `patch` refuses the first diff, since the original has no line 4. The same append with one line of context is numbered correctly.\n\n**To Reproduce**\n\n```java\nimport com.github.difflib.DiffUtils;\nimport com.github.difflib.UnifiedDiffUtils;\nimport java.util.Arrays;\nimport java.util.List;\n\npublic class Main {\n    static void show(List\u003cString> orig, List\u003cString> rev, int context) {\n        UnifiedDiffUtils.generateUnifiedDiff(\"f\", \"f\", orig, DiffUtils.diff(orig, rev), context).forEach(System.out::println);\n        System.out.println();\n    }\n\n    public static void main(String[] args) {\n        List\u003cString> abc = Arrays.asList(\"a\", \"b\", \"c\");\n        show(abc, Arrays.asList(\"a\", \"b\", \"c\", \"x\"), 0);\n        show(abc, Arrays.asList(\"a\", \"b\", \"c\", \"x\"), 1);\n        show(abc, Arrays.asList(), 3);\n    }\n}\n```\n\nOutput:\n\n```\n--- f\n+++ f\n@@ -4,0 +4,1 @@\n+x\n\n--- f\n+++ f\n@@ -3,1 +3,2 @@\n c\n+x\n\n--- f\n+++ f\n@@ -1,3 +1,0 @@\n-a\n-b\n-c\n```\n\nSaving the first diff as `append.diff` and applying it to a file `f` containing the lines a, b, c:\n\n```\n$ patch f append.diff\npatching file f\nNo such line 4 in input file, ignoring\npatch: **** misordered hunks! output would be garbled\n```\n\nWith the header changed to `@@ -3,0 +4,1 @@`, `patch` applies it and `f` ends in `x`. `patch` does accept the `@@ -1,3 +1,0 @@` deletion, but `diff -u` and `git diff` both write `@@ -1,3 +0,0 @@` for that change.\n\n**Expected behavior**\n\nAn empty range to start at the line before the change, as `diff -U0` and `git diff -U0` write it: `@@ -3,0 +4,1 @@` for the append and `@@ -1,3 +0,0 @@` for the deletion, so that `patch` applies the generated diff.\n\n**System**\n\n- Java: OpenJDK 27\n- Version: java-diff-utils 4.17 from Maven Central, and 4.18-SNAPSHOT built from current `master` (0643852); the output is identical on both. `patch` is macOS's (2.0-12u11-Apple, FreeBSD-derived), `diff` is Apple's, `git` is 2.50.1.\n\nAs mentioned at the top, this was found by an automated program that writes property-based tests for various open source projects using [hegel](https://github.com/hegeldev/hegel-java), and the report was reviewed by hand before filing. We've also potentially found (but not yet hand validated) 8 other bugs in java-diff-utils. You can see the tests at https://github.com/hegeldev/hegel-zoo/tree/main/targets/java/java-diff-utils. Let us know if you would like us to file the other bugs found and/or contribute the tests. NB the tests are currently LLM generated and probably not yet suitable for inclusion as is, but we're happy to help get them into a better state if you want them.\n","author":{"url":"https://github.com/DRMacIver","@type":"Person","name":"DRMacIver"},"datePublished":"2026-10-08T15:00:06Z","url":"https://github.com/java-diff-utils/java-diff-utils/issues/239"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:11d18ee0-ae5f-2f79-9c47-f23dd8b24ab1
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8EF8:1D20B7:2AAA0E4:361888A:6B01DDC8
html-safe-noncebb12f0e39fff09d742c67dd9005741d4637cd101c34263ab0ffeda9d6773726d
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RUY4OjFEMjBCNzoyQUFBMEU0OjM2MTg4OEE6NkIwMUREQzgiLCJ2aXNpdG9yX2lkIjoiOTA5NDc2NzMwMDMyOTk4NzUyOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacb17f371b4cf93fa49cc5d1053d13e920d4bde199e09c0669684c2bd2a84e69e3
hovercard-subject-tagissue:5764063455
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/java-diff-utils/java-diff-utils/239/issue_layout
twitter:imagehttps://opengraph.githubassets.com/914a8864c35a9ee990c3c3165fbbd9e803979c7f51ff36e3d1a58877b7480f9f/java-diff-utils/java-diff-utils/issues/239
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/914a8864c35a9ee990c3c3165fbbd9e803979c7f51ff36e3d1a58877b7480f9f/java-diff-utils/java-diff-utils/issues/239
og:image:altThis bug was found by an automated program we have running that writes tests with hegel (but I have personally reviewed it). More details at the bottom, but the short version is that I am not perso...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameDRMacIver
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/java-diff-utils/java-diff-utils git https://github.com/java-diff-utils/java-diff-utils.git
octolytics-dimension-user_id40540835
octolytics-dimension-user_loginjava-diff-utils
octolytics-dimension-repository_id86663812
octolytics-dimension-repository_nwojava-diff-utils/java-diff-utils
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id86663812
octolytics-dimension-repository_network_root_nwojava-diff-utils/java-diff-utils
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/java-diff-utils/java-diff-utils/issues/239#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fjava-diff-utils%2Fjava-diff-utils%2Fissues%2F239
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fjava-diff-utils%2Fjava-diff-utils%2Fissues%2F239
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=java-diff-utils%2Fjava-diff-utils
Reloadhttps://github.com/java-diff-utils/java-diff-utils/issues/239
Reloadhttps://github.com/java-diff-utils/java-diff-utils/issues/239
Reloadhttps://github.com/java-diff-utils/java-diff-utils/issues/239
java-diff-utilshttps://github.com/java-diff-utils
java-diff-utilshttps://github.com/java-diff-utils/java-diff-utils
Codehttps://github.com/java-diff-utils/java-diff-utils
Issues2 (2)https://github.com/java-diff-utils/java-diff-utils/issues
Pull requests2 (2)https://github.com/java-diff-utils/java-diff-utils/pulls
Discussionshttps://github.com/java-diff-utils/java-diff-utils/discussions
Actionshttps://github.com/java-diff-utils/java-diff-utils/actions
Projectshttps://github.com/java-diff-utils/java-diff-utils/projects
Wikihttps://github.com/java-diff-utils/java-diff-utils/wiki
Security and qualityhttps://github.com/java-diff-utils/java-diff-utils/security
Insightshttps://github.com/java-diff-utils/java-diff-utils/insights
https://github.com/java-diff-utils/java-diff-utils
New issuehttps://github.com/login?return_to=https://github.com/java-diff-utils/java-diff-utils/issues/239
New issuehttps://github.com/login?return_to=https://github.com/java-diff-utils/java-diff-utils/issues/239
generateUnifiedDiff starts an empty hunk range one line too highhttps://github.com/java-diff-utils/java-diff-utils/issues/239#top
https://github.com/DRMacIver
DRMacIverhttps://github.com/DRMacIver
on Oct 8, 2026https://github.com/java-diff-utils/java-diff-utils/issues/239#issue-5764063455
hegelhttps://github.com/hegeldev/hegel-java
0643852https://github.com/java-diff-utils/java-diff-utils/commit/06438525cfb139ecf813312ff7305b847dd569b9
hegelhttps://github.com/hegeldev/hegel-java
https://github.com/hegeldev/hegel-zoo/tree/main/targets/java/java-diff-utilshttps://github.com/hegeldev/hegel-zoo/tree/main/targets/java/java-diff-utils
Sign up for freehttps://github.com/signup?return_to=https://github.com/java-diff-utils/java-diff-utils/issues/239
Sign in to commenthttps://github.com/login?return_to=https://github.com/java-diff-utils/java-diff-utils/issues/239
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.