Fossil SCM

If both files being merged by 'fossil merge' contain a UTF-8 byte order mark (BOM), keep it in the produced merged file.

marciogabe 2020-08-24 22:57 merge-crlf-bom
Commit 91182cd1f369b9c1f4173eb106319dfd485c623e97a8c0acfdb16f6443dd40f9
1 file changed +9
--- src/merge3.c
+++ src/merge3.c
@@ -198,10 +198,19 @@
198198
int limit1, limit2; /* Sizes of aC1[] and aC2[] */
199199
int nConflict = 0; /* Number of merge conflicts seen so far */
200200
201201
blob_zero(pOut); /* Merge results stored in pOut */
202202
203
+ /* If both pV1 and pV2 start with a UTF-8 byte-order-mark (BOM),
204
+ ** keep it in the output. This should be secure enough not to cause
205
+ ** unintended changes to the merged file and consistent with what
206
+ ** users are using in their source files.
207
+ */
208
+ if( starts_with_utf8_bom(pV1, 0) && starts_with_utf8_bom(pV2, 0) ){
209
+ blob_append(pOut, get_utf8_bom(0), -1);
210
+ }
211
+
203212
/* Check once to see if both pV1 and pV2 contains CR/LF endings.
204213
** If true, CR/LF pair will be used later to append the
205214
** boundary markers for merge conflicts.
206215
*/
207216
int useCrLf = 0;
208217
--- src/merge3.c
+++ src/merge3.c
@@ -198,10 +198,19 @@
198 int limit1, limit2; /* Sizes of aC1[] and aC2[] */
199 int nConflict = 0; /* Number of merge conflicts seen so far */
200
201 blob_zero(pOut); /* Merge results stored in pOut */
202
 
 
 
 
 
 
 
 
 
203 /* Check once to see if both pV1 and pV2 contains CR/LF endings.
204 ** If true, CR/LF pair will be used later to append the
205 ** boundary markers for merge conflicts.
206 */
207 int useCrLf = 0;
208
--- src/merge3.c
+++ src/merge3.c
@@ -198,10 +198,19 @@
198 int limit1, limit2; /* Sizes of aC1[] and aC2[] */
199 int nConflict = 0; /* Number of merge conflicts seen so far */
200
201 blob_zero(pOut); /* Merge results stored in pOut */
202
203 /* If both pV1 and pV2 start with a UTF-8 byte-order-mark (BOM),
204 ** keep it in the output. This should be secure enough not to cause
205 ** unintended changes to the merged file and consistent with what
206 ** users are using in their source files.
207 */
208 if( starts_with_utf8_bom(pV1, 0) && starts_with_utf8_bom(pV2, 0) ){
209 blob_append(pOut, get_utf8_bom(0), -1);
210 }
211
212 /* Check once to see if both pV1 and pV2 contains CR/LF endings.
213 ** If true, CR/LF pair will be used later to append the
214 ** boundary markers for merge conflicts.
215 */
216 int useCrLf = 0;
217

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button