I inherited from somebody else the maintenance of two versions of a set of html files, one larger with translation, another one shorter without translation. The body of the short files and of the long file differ only on the lines containing the translation. But there is also some specific content which is not common somewhere in these files that has to be maintained untouched.
short.html
Salve<br/>
Quomodo te habes?<br/>
Some lines specific to short.html
long.html
Salve<br/>
Hello!<br/>
Quomodo te habes?<br/>
How do you do?<br/>
Some other lines specific to long.html
I use to edit the shorter one, and for not repeating that work twice, I look to the differences with GNU diff
to create a patch file in order to apply the same corrections to the larger file.
diff short.html.orig short.html > short.diff
patch -z .orig long.html short.diff
This worked as a charm, because patch
is smart enough to jump over garbage for finding where to patch, until I had to correct adjacent lines in the short files.
In that case, the output of the diff
command looks like:
1,2c1,2
< Salve<br/>
< Quomodo te habes?<br/>
---
> Salvete<br/>
> Quomodo vos habetis?<br/>
and the patch is rejected because, I assume, patch
doesn't find any block of two lines containing Salve...
and Quomodo...
for being replaced in long.html since the two lines are no longer adjacent in the longer version where a translation is inserted after each line. As long as the patches are applied line by line, it works great, but when the patches are grouped into a block (they call a hunk), it no longer works.
My question is: how do I prevent diff
from grouping the lines to be patched into hunks so that patches are applied line by line?
With no more words, I wish to change the output of the diff
command above into this:
1c1
< Salve<br/>
---
> Salvete<br/>
2c2
< Quomodo te habes?<br/>
---
> Quomodo vos habetis?<br/>