TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

The Art of Manually Editing Hunks

25 点作者 alraj7 个月前

6 条评论

qazxcvbnm6 个月前
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 个月前
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 个月前
Further to this, don&#x27;t underestimate how powerful git diff | sed | git apply can be for mass edits of files.
impure6 个月前
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 个月前
Is it just me, or the piece doesn’t explain how to make edits without messing up the hunk?
评论 #42128693 未加载
评论 #42129461 未加载
Optimal_Persona6 个月前
I honestly thought this would be about retouching photos of buff men!
评论 #42128679 未加载
评论 #42128958 未加载