interdiff做什么差异不能?

问题描述 投票:4回答:2

如果我试图找到两个差异之间的差异,为什么我不能只是diff两个差异?

我测试了diff diff1 diff2interdiff diff1 diff2并没有发现输出有任何差异。在什么情况下它们会有所不同?

(我完全清楚interdiff声明的目的是找到两个补丁之间的变化。)

git diff
2个回答
1
投票

为什么使用interdiff而不只是简单地区分两个补丁?

interdiff告诉您第一个补丁中是否添加了第二个补丁中删除的行,同样,第一个补丁中是否删除了第二个补丁中添加的行。简单地区分两个提交不会提供此信息,迫使审阅者查阅原始补丁或当前源以确定是否是这种情况。

来自Drupal's handbook on Creating an interdiff


-2
投票

interdiff - show differences between two diff files

interdiff创建一个统一的格式差异,表示两个差异之间的差异。 差异必须都是相对于相同的文件。 为获得最佳结果,差异必须至少有三行上下文。


interdiff是补丁格式的文本文件,用于描述补丁的两个版本之间的更改。使用interdiffs是一种最佳实践,通过允许他们专注于补丁迭代中引入的更改,可以节省时间并减少审阅者的乏味。

每当您更新问题队列中的重要补丁时,您应该提供一个(Drupal.org Testbots会忽略它,因此请确保您始终上传完整补丁)。

Create interdiff using git

//Always pull the latest changes.
git pull --rebase

//Create a branch for the old patch.
git checkout -b my_first_branch

// Download the old version of the patch you wish 
// to update and apply it to your local git repository.
git apply --index patchname.patch

// Commit the changes from the old patch.
git commit -m "my_first_branch"

// Depending on how you like to work, you now have a choice between
// two options. If you do not yet have a new patch created, you can now
// create a new branch.
git checkout -b my_second_branch

// Otherwise, let's go back to the mainline branch and create a 
// new branch to patch from.
git checkout any_reuired_commit_id
git checkout -b my_second_branch

// Make your changes on the new branch (e.g. apply your new patch), 
// then commit the changes.
git commit -m "my_second_branch"

// Generate the interdiff by comparing the current (new) branch against 
// the old branch.
git diff my_first_branch > interdiff-my_first_branch-[new_comment_number].txt

// You can create the updated patch easily at this point with:
git diff any_reuired_commit_id > my_second_branch.patch
© www.soinside.com 2019 - 2024. All rights reserved.