(长话短说...)
我正在将一个巨大的PHP应用程序更新到现代化时代...;-)...而其他团队则继续维护其现有版本。
到目前为止,这已经导致了大约275个补丁。问题是,我们所做的更改之一是将<?
标记转换为<?php
,并在代码中进行了几个类似的更改。所有这些当然都会防止应用补丁,因为源代码确实不匹配。
因此,我想编写一个小脚本来编辑补丁文件:更改补丁中的标记。
然而,我得到的是corrupt patch
。
那么,我想知道的是:是什么导致了这个消息?也就是说,当Git出现这个消息时,它寻找什么样的错误?我需要“调整我的调整器”...咳咳...以便编辑后的补丁能够正常工作。(注意:在我对其进行调整之前,原始的补丁文件并不“损坏”,因此必须是我做的某些事情。)
我的脚本试图更改前述的PHP标记和<?php echo
和一个函数名。仅仅是一次全局preg-replace。我并不容易看出我可能会搞砸的内容与Git相关的“结构性问题”,但显然,有些东西确实存在。
示例补丁:corrupt patch at line 37
...
From 342c5939da8cf4cbe495be7d635cd627bd2a44ed Mon Sep 17 00:00:00 2001
From: xxx <xxx@yyy.com>
Date: Wed, 17 Feb 2016 03:45:31 +0000
Subject: [PATCH 001/275] Make it all work
---
catalog/includes/modules/shipping/upsFreeGround.php | 2 +-
catalog/product_info_v3.php | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/catalog/includes/modules/shipping/upsFreeGround.php b/catalog/includes/modules/shipping/upsFreeGround.php
index 45a6da4..55ccecb 100755
--- a/catalog/includes/modules/shipping/upsFreeGround.php
+++ b/catalog/includes/modules/shipping/upsFreeGround.php
@@ -194,7 +194,7 @@ function quote($method = '') {
// Can probably combine this with the above, eventually
$allFreeBW2016Plaques = false;
- if (STORES_ID == 10) {
+ if ((STORES_ID == 10) || (STORES_ID == 26)) {
$allFreeBW2016Plaques = true;
foreach ($order->products as $aProduct) {
$thisNote = $aProduct['product_specific_notes'];
diff --git a/catalog/product_info_v3.php b/catalog/product_info_v3.php
index 09d88de..10d9b76 100644
--- a/catalog/product_info_v3.php
+++ b/catalog/product_info_v3.php
@@ -186,7 +186,7 @@ function doRequestComplete() {
}
}
<?php -if ((STORES_ID == 10) && (in_array($products_id, $bwFreePlaqueIDList2016))) { ?>
+if (((STORES_ID == 10) || (STORES_ID == 26)) && (in_array($products_id, $bwFreePlaqueIDList2016))) { ?>
function doCheckBW2016PlaqueProperty() {
thePropertyNumber = document.getElementById('propertyToCheck');
if (thePropertyNumber.value == "") {
@@ -1426,7 +1426,7 @@ if($combo_count>0) { ?>
?>
</div> <!-- div_add_to_cart -->
</div> <!-- cart_info_row2 -->
- <?php if ((STORES_ID == 10) && (in_array( $products_id, $bwFreePlaqueIDList2016))) {
+ <?php if (((STORES_ID == 10) || (STORES_ID == 26)) && (in_array( $products_id, $bwFreePlaqueIDList2016))) {
// First, let's see if we are "sold out"
$query = "select bw_plaque_2016_id from bw_plaque_2016 where first_one_free='1' limit 1";
$bwpRes = tep_db_query( $query);
@@ -1629,7 +1629,7 @@ DIVCONTAINER;
</table> <!--pageTable for sure -->
<script type='text/javascript'>
- <?php if ((STORES_ID == 10) && (in_array( $products_id, $bwFreePlaqueIDList2016))) { ?>
+ <?php if (((STORES_ID == 10) || (STORES_ID == 26)) && (in_array( $products_id, $bwFreePlaqueIDList2016))) { ?>
function doFreePlaquePriceChange() {
// Change the quantity to 1
$('quantityToAdd').setValue('1');
--
2.6.4 (Apple Git-63)
git apply --check -v --directory=foobar
。我原本希望-v
选项能告诉我更多关于损坏的信息,但它并没有。 - Mike Robinson@@ -1426,7 +1426,7 @@ if($combo_count>0) { ?>
。 - Mike Robinson+
和-
为前缀的行显然必须具有前导空格,即使它们是空白的)。 它还在最后缺少了一个换行符。 GitHub 删除了这些空格(我从评论中复制了差异并将其粘贴到文本文件中)。 - CodeManX