有没有办法比较两个差异或补丁? [英] Is there a way to compare two diffs or patches?

查看:107
本文介绍了有没有办法比较两个差异或补丁?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有方法可以测试两个diff或patch是否相等?

假设您有以下git commit历史记录,其中功能F和G可以干净地变ase到E:

  G 
/
A - B - C - D - E


由于我们当前部署中的限制进程,我们有以下几个相关的图表(它不受版本控制)

  G'
/
------------ E'
\
F'



F'和G'最终将被应用到头部E',在一些被确定的顺序中,所以它最终会像


  ------------ E' -  G' -  F'

有没有一种方法可以测试从E'到G'的差异与由G的git commit从B产生的补丁相同?



我完全意识到在一个理想的世界,修正控制可以解决这个问题,而且我们已经到了那里,但那不是我们现在所在的地方。



您可以在单独的结帐时播放这两个补丁,并比较产出,但似乎有点笨重。比较差异本身,我假设,行不通,因为行号可能会改变。即使G'和F'被重新定位为E',F'的补丁最终也会应用到G',从而使得补丁的diff背景不同。

解决方案

  diff<(git show COMMIT1SHA)<(git show COMMIT2SHA)


Is there a way to test if two diffs or patches are equivalent?

Let's say you have the following git commit history, where features F and G are cleanly rebaseable to E:

     G
    /
A--B--C--D--E
 \
  F

Due to limitations in our current deployment process, we have the following, somewhat related graph (it's not version controlled)

              G'
             /
------------E'
             \
              F'

F' and G' will ultimately be applied to the head E', in some to be determined order, so it would end up like

------------E'--G'--F'

Is there a way to test that the diff from E' to G' is the same as the patch produced by the git commit of G from B?

I fully realize that in an ideal world, revision control would solve this, and we're getting there, but that's not where we are currently.

You could essentially play both patches on separate checkouts and compare the outputs, but that seems kind of clunky. And comparing the diffs themselves, I'm assuming, wouldn't work because line numbers could change. Even if G' and F' were rebased to E', the patch for F' would ultimately be applied to G', making the diff context of the patch different.

解决方案

diff <(git show COMMIT1SHA) <(git show COMMIT2SHA)

这篇关于有没有办法比较两个差异或补丁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆