Is it standard practice to edit a .patch
using an editor?
Scenario
I use .patch
in Yocto Applications where I want to adapt a few small changes to the repository which I wish to port to my embedded device.
One of the patches is as following (some details removed for brewity):
From 85987c659762939241e4bdd4223e63eb5997b181 Mon Sep 17 00:00:00 2001
OE ships php5 as php
---
airmar/airmar.php | 2 +-
n2kd/n2kd_monitor | 2 +-
send-message/format-message | 2 +-
util/list-product-information | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/airmar/airmar.php b/airmar/airmar.php
index ccd4b4d..46ed49d 100755
--- a/airmar/airmar.php
+++ b/airmar/airmar.php
@@ -1,4 +1,4 @@
-#!/usr/bin/php5
+#!/usr/bin/env php
<?php
if (!is_array($argv))
{
diff --git a/n2kd/n2kd_monitor b/n2kd/n2kd_monitor
index f8cfd42..4cb4766 100755
--- a/n2kd/n2kd_monitor
+++ b/n2kd/n2kd_monitor
@@ -233,7 +233,7 @@ for (;;)
open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
open STDOUT, '>>', $MONITOR_LOGFILE or die "Can't write to $MONITOR_LOGFILE $!";
open STDERR, '>&STDOUT' or die "Can't dup stdout: $!";
- exec 'php5', '/usr/local/bin/n2k.php', '-monitor';
+ exec 'php', '/usr/bin/n2k.php', '-monitor';
}
if (!$monitor)
{
diff --git a/send-message/format-message b/send-message/format-message
index 590a815..2d91185 100755
--- a/send-message/format-message
+++ b/send-message/format-message
@@ -1,4 +1,4 @@
-#!/usr/bin/php5
+#!/usr/bin/env php
<?
#
# Format a particular N2K command
diff --git a/util/list-product-information b/util/list-product-information
index d958ae4..a54a0f2 100755
--- a/util/list-product-information
+++ b/util/list-product-information
@@ -1,4 +1,4 @@
-#!/usr/bin/php5
+#!/usr/bin/env php
<?php
#
# A very limited script engine that sends and receives CAN messages.
--
2.17.0
This patch simply replaces php5
with env php
whereever it occurs.
However, the main code repository changed one of its file where previously there was a shebang for php as follows:
#!/usr/bin/php5
And now after a few commits it doesn't.
From my understanding, the current patch won't work as it will seek to first find the line number and the content to remove but will through errors since it won't be able to find the above mentioned shebang in the file anymore. (already tried it out)
Possible Way
- A clear way is to clone the repository with the updated code and add the needed shebang (
env php
and notphp5
) to the code and usegit format-patch -1
to obtain a new patch to be restored.
However this puts a lot of effort and when there are more than a certain number of files changed then this procedure seems to be tedious.
Is it reasonable to edit the patch using an editor (I am quite sure it isn't)? Or are there some git
features that help modify the patch directly and not the corresponding file?