TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

The Art of Manually Editing Hunks

25 pointsby alraj7 months ago

6 comments

qazxcvbnm6 months ago
Sounds like a problem for rediff (<a href="https:&#x2F;&#x2F;github.com&#x2F;twaugh&#x2F;patchutils">https:&#x2F;&#x2F;github.com&#x2F;twaugh&#x2F;patchutils</a>).<p>Instead of directly editing the unified diff file, make a copy and edit the copy. Once you’re done, call rediff original-patch edited-patch to get a patchfile with fixed offsets.<p>Note that rediff only fixes your offsets, and doesn’t remove empty hunks. patch is not happy about empty hunks existing, so if you happen to revert all changes in a hunk, remember to delete the hunk after rediff. Probably this ought to be contributed back upstream.
lionelw6 months ago
If this is about staging partial file changes, then I think this is where git GUIs especially excel. It&#x27;s typically a matter of selecting and deselecting individual lines of change. The concept and term &quot;hunk&quot; (to mean a group of lines, and honestly &quot;chunk&quot; would&#x27;ve been a better choice) never shows up. Pretty intuitive and foolproof.<p>I&#x27;ve used Git Cola on Linux and Github Desktop on Windows. Both free.
评论 #42153658 未加载
ris6 months ago
Further to this, don&#x27;t underestimate how powerful git diff | sed | git apply can be for mass edits of files.
impure6 months ago
Yeah, you can do this to make your commits cleaner, but I find it easier to just manually edit the file and then undo after you add the patch.
评论 #42128666 未加载
评论 #42129424 未加载
rapidlua6 months ago
Is it just me, or the piece doesn’t explain how to make edits without messing up the hunk?
评论 #42128693 未加载
评论 #42129461 未加载
Optimal_Persona6 months ago
I honestly thought this would be about retouching photos of buff men!
评论 #42128679 未加载
评论 #42128958 未加载