Fossil SCM

EOL conversion: had neglected to pass that option on in the ajax request. Fixed a bug which caused duplicate CRs to get injected into force-to-windows-EOL conversions.

stephan 2020-05-14 23:34 fileedit-ajaxify
Commit 439f446df68406a52a676f1e27ad90f36ee5c0a802f011057db1bf34f1138094
--- src/default_css.txt
+++ src/default_css.txt
@@ -948,10 +948,11 @@
948948
// Styles for /fileedit:
949949
body.fileedit textarea {
950950
font-family: monospace;
951951
width: 100%;
952952
flex: 10 1 auto;
953
+ height: initial;
953954
}
954955
body.fileedit fieldset {
955956
margin: 0.5em 0 0.5em 0;
956957
padding: 0.25em 0;
957958
border-radius: 0.5em;
958959
--- src/default_css.txt
+++ src/default_css.txt
@@ -948,10 +948,11 @@
948 // Styles for /fileedit:
949 body.fileedit textarea {
950 font-family: monospace;
951 width: 100%;
952 flex: 10 1 auto;
 
953 }
954 body.fileedit fieldset {
955 margin: 0.5em 0 0.5em 0;
956 padding: 0.25em 0;
957 border-radius: 0.5em;
958
--- src/default_css.txt
+++ src/default_css.txt
@@ -948,10 +948,11 @@
948 // Styles for /fileedit:
949 body.fileedit textarea {
950 font-family: monospace;
951 width: 100%;
952 flex: 10 1 auto;
953 height: initial;
954 }
955 body.fileedit fieldset {
956 margin: 0.5em 0 0.5em 0;
957 padding: 0.25em 0;
958 border-radius: 0.5em;
959
+20 -8
--- src/fileedit.c
+++ src/fileedit.c
@@ -583,21 +583,23 @@
583583
** form-submitted TEXTAREA content gets normalized to CRLF-style:
584584
**
585585
** https://html.spec.whatwg.org/multipage/form-elements.html#the-textarea-element
586586
*/
587587
const int pseudoBinary = LOOK_LONG | LOOK_NUL;
588
- const int lookFlags = LOOK_CRLF | pseudoBinary;
588
+ const int lookFlags = LOOK_CRLF | LOOK_LONE_LF | pseudoBinary;
589589
const int lookNew = looks_like_utf8( &pCI->fileContent, lookFlags );
590590
if(!(pseudoBinary & lookNew)){
591591
int rehash = 0;
592
+ /*fossil_print("lookNew=%08x\n",lookNew);*/
592593
if(CIMINI_CONVERT_EOL_INHERIT & pCI->flags){
593594
Blob contentPrev = empty_blob;
594595
int lookOrig, nOrig;
595596
content_get(prevFRid, &contentPrev);
596597
lookOrig = looks_like_utf8(&contentPrev, lookFlags);
597598
nOrig = blob_size(&contentPrev);
598599
blob_reset(&contentPrev);
600
+ /*fossil_print("lookOrig=%08x\n",lookOrig);*/
599601
if(nOrig>0 && lookOrig!=lookNew){
600602
/* If there is a newline-style mismatch, adjust the new
601603
** content version to the previous style, then re-hash the
602604
** content. Note that this means that what we insert is NOT
603605
** what's in the filesystem.
@@ -613,14 +615,18 @@
613615
}
614616
}
615617
}else{
616618
const int oldSize = blob_size(&pCI->fileContent);
617619
if(CIMINI_CONVERT_EOL_UNIX & pCI->flags){
618
- blob_to_lf_only(&pCI->fileContent);
620
+ if(LOOK_CRLF & lookNew){
621
+ blob_to_lf_only(&pCI->fileContent);
622
+ }
619623
}else{
620624
assert(CIMINI_CONVERT_EOL_WINDOWS & pCI->flags);
621
- blob_add_cr(&pCI->fileContent);
625
+ if(!(LOOK_CRLF & lookNew)){
626
+ blob_add_cr(&pCI->fileContent);
627
+ }
622628
}
623629
if(blob_size(&pCI->fileContent)!=oldSize){
624630
rehash = 1;
625631
}
626632
}
@@ -719,14 +725,16 @@
719725
** --user-override USER USER to use instead of the current
720726
** default.
721727
** --date-override DATETIME DATE to use instead of 'now'.
722728
** --allow-older Allow a commit to be older than its
723729
** ancestor.
724
-** --convert-eol Convert EOL style of the checkin to match
725
-** the previous version's content. Does not
726
-** modify the input file, only the checked-in
727
-** content.
730
+** --convert-eol-inherit Convert EOL style of the checkin to match
731
+** the previous version's content.
732
+** --convert-eol-unix Convert the EOL style to Unix.
733
+** --convert-eol-windows Convert the EOL style to Windows.
734
+** (only one of the --convert-eol-X options may be used and they only
735
+** modified the saved blob, not the input file.)
728736
** --delta Prefer to generate a delta manifest, if
729737
** able. The forbid-delta-manifests repo
730738
** config option trumps this, as do certain
731739
** heuristics.
732740
** --allow-new-file Allow addition of a new file this way.
@@ -784,12 +792,16 @@
784792
cimi.flags |= CIMINI_ALLOW_MERGE_MARKER;
785793
}
786794
if(find_option("allow-older",0,0)!=0){
787795
cimi.flags |= CIMINI_ALLOW_OLDER;
788796
}
789
- if(find_option("convert-eol-prev",0,0)!=0){
797
+ if(find_option("convert-eol-inherit",0,0)!=0){
790798
cimi.flags |= CIMINI_CONVERT_EOL_INHERIT;
799
+ }else if(find_option("convert-eol-unix",0,0)!=0){
800
+ cimi.flags |= CIMINI_CONVERT_EOL_UNIX;
801
+ }else if(find_option("convert-eol-windows",0,0)!=0){
802
+ cimi.flags |= CIMINI_CONVERT_EOL_WINDOWS;
791803
}
792804
if(find_option("delta",0,0)!=0){
793805
cimi.flags |= CIMINI_PREFER_DELTA;
794806
}
795807
if(find_option("delta2",0,0)!=0){
796808
--- src/fileedit.c
+++ src/fileedit.c
@@ -583,21 +583,23 @@
583 ** form-submitted TEXTAREA content gets normalized to CRLF-style:
584 **
585 ** https://html.spec.whatwg.org/multipage/form-elements.html#the-textarea-element
586 */
587 const int pseudoBinary = LOOK_LONG | LOOK_NUL;
588 const int lookFlags = LOOK_CRLF | pseudoBinary;
589 const int lookNew = looks_like_utf8( &pCI->fileContent, lookFlags );
590 if(!(pseudoBinary & lookNew)){
591 int rehash = 0;
 
592 if(CIMINI_CONVERT_EOL_INHERIT & pCI->flags){
593 Blob contentPrev = empty_blob;
594 int lookOrig, nOrig;
595 content_get(prevFRid, &contentPrev);
596 lookOrig = looks_like_utf8(&contentPrev, lookFlags);
597 nOrig = blob_size(&contentPrev);
598 blob_reset(&contentPrev);
 
599 if(nOrig>0 && lookOrig!=lookNew){
600 /* If there is a newline-style mismatch, adjust the new
601 ** content version to the previous style, then re-hash the
602 ** content. Note that this means that what we insert is NOT
603 ** what's in the filesystem.
@@ -613,14 +615,18 @@
613 }
614 }
615 }else{
616 const int oldSize = blob_size(&pCI->fileContent);
617 if(CIMINI_CONVERT_EOL_UNIX & pCI->flags){
618 blob_to_lf_only(&pCI->fileContent);
 
 
619 }else{
620 assert(CIMINI_CONVERT_EOL_WINDOWS & pCI->flags);
621 blob_add_cr(&pCI->fileContent);
 
 
622 }
623 if(blob_size(&pCI->fileContent)!=oldSize){
624 rehash = 1;
625 }
626 }
@@ -719,14 +725,16 @@
719 ** --user-override USER USER to use instead of the current
720 ** default.
721 ** --date-override DATETIME DATE to use instead of 'now'.
722 ** --allow-older Allow a commit to be older than its
723 ** ancestor.
724 ** --convert-eol Convert EOL style of the checkin to match
725 ** the previous version's content. Does not
726 ** modify the input file, only the checked-in
727 ** content.
 
 
728 ** --delta Prefer to generate a delta manifest, if
729 ** able. The forbid-delta-manifests repo
730 ** config option trumps this, as do certain
731 ** heuristics.
732 ** --allow-new-file Allow addition of a new file this way.
@@ -784,12 +792,16 @@
784 cimi.flags |= CIMINI_ALLOW_MERGE_MARKER;
785 }
786 if(find_option("allow-older",0,0)!=0){
787 cimi.flags |= CIMINI_ALLOW_OLDER;
788 }
789 if(find_option("convert-eol-prev",0,0)!=0){
790 cimi.flags |= CIMINI_CONVERT_EOL_INHERIT;
 
 
 
 
791 }
792 if(find_option("delta",0,0)!=0){
793 cimi.flags |= CIMINI_PREFER_DELTA;
794 }
795 if(find_option("delta2",0,0)!=0){
796
--- src/fileedit.c
+++ src/fileedit.c
@@ -583,21 +583,23 @@
583 ** form-submitted TEXTAREA content gets normalized to CRLF-style:
584 **
585 ** https://html.spec.whatwg.org/multipage/form-elements.html#the-textarea-element
586 */
587 const int pseudoBinary = LOOK_LONG | LOOK_NUL;
588 const int lookFlags = LOOK_CRLF | LOOK_LONE_LF | pseudoBinary;
589 const int lookNew = looks_like_utf8( &pCI->fileContent, lookFlags );
590 if(!(pseudoBinary & lookNew)){
591 int rehash = 0;
592 /*fossil_print("lookNew=%08x\n",lookNew);*/
593 if(CIMINI_CONVERT_EOL_INHERIT & pCI->flags){
594 Blob contentPrev = empty_blob;
595 int lookOrig, nOrig;
596 content_get(prevFRid, &contentPrev);
597 lookOrig = looks_like_utf8(&contentPrev, lookFlags);
598 nOrig = blob_size(&contentPrev);
599 blob_reset(&contentPrev);
600 /*fossil_print("lookOrig=%08x\n",lookOrig);*/
601 if(nOrig>0 && lookOrig!=lookNew){
602 /* If there is a newline-style mismatch, adjust the new
603 ** content version to the previous style, then re-hash the
604 ** content. Note that this means that what we insert is NOT
605 ** what's in the filesystem.
@@ -613,14 +615,18 @@
615 }
616 }
617 }else{
618 const int oldSize = blob_size(&pCI->fileContent);
619 if(CIMINI_CONVERT_EOL_UNIX & pCI->flags){
620 if(LOOK_CRLF & lookNew){
621 blob_to_lf_only(&pCI->fileContent);
622 }
623 }else{
624 assert(CIMINI_CONVERT_EOL_WINDOWS & pCI->flags);
625 if(!(LOOK_CRLF & lookNew)){
626 blob_add_cr(&pCI->fileContent);
627 }
628 }
629 if(blob_size(&pCI->fileContent)!=oldSize){
630 rehash = 1;
631 }
632 }
@@ -719,14 +725,16 @@
725 ** --user-override USER USER to use instead of the current
726 ** default.
727 ** --date-override DATETIME DATE to use instead of 'now'.
728 ** --allow-older Allow a commit to be older than its
729 ** ancestor.
730 ** --convert-eol-inherit Convert EOL style of the checkin to match
731 ** the previous version's content.
732 ** --convert-eol-unix Convert the EOL style to Unix.
733 ** --convert-eol-windows Convert the EOL style to Windows.
734 ** (only one of the --convert-eol-X options may be used and they only
735 ** modified the saved blob, not the input file.)
736 ** --delta Prefer to generate a delta manifest, if
737 ** able. The forbid-delta-manifests repo
738 ** config option trumps this, as do certain
739 ** heuristics.
740 ** --allow-new-file Allow addition of a new file this way.
@@ -784,12 +792,16 @@
792 cimi.flags |= CIMINI_ALLOW_MERGE_MARKER;
793 }
794 if(find_option("allow-older",0,0)!=0){
795 cimi.flags |= CIMINI_ALLOW_OLDER;
796 }
797 if(find_option("convert-eol-inherit",0,0)!=0){
798 cimi.flags |= CIMINI_CONVERT_EOL_INHERIT;
799 }else if(find_option("convert-eol-unix",0,0)!=0){
800 cimi.flags |= CIMINI_CONVERT_EOL_UNIX;
801 }else if(find_option("convert-eol-windows",0,0)!=0){
802 cimi.flags |= CIMINI_CONVERT_EOL_WINDOWS;
803 }
804 if(find_option("delta",0,0)!=0){
805 cimi.flags |= CIMINI_PREFER_DELTA;
806 }
807 if(find_option("delta2",0,0)!=0){
808
--- src/fossil.page.fileedit.js
+++ src/fossil.page.fileedit.js
@@ -239,11 +239,12 @@
239239
btnCommit: E("#fileedit-btn-commit"),
240240
btnReload: E("#fileedit-tab-content > .fileedit-options > "
241241
+"button.fileedit-content-reload"),
242242
selectPreviewMode: E('#select-preview-mode select'),
243243
selectHtmlEmsWrap: E('#select-preview-html-ems'),
244
- selectEolWrap: E('#select-preview-html-ems'),
244
+ selectEolWrap: E('#select-eol-style'),
245
+ selectEol: E('#select-eol-style select[name=eol]'),
245246
selectFontSizeWrap: E('#select-font-size'),
246247
cbLineNumbersWrap: E('#cb-line-numbers'),
247248
cbAutoPreview: E('#cb-preview-autoupdate > input[type=checkbox]'),
248249
previewTarget: E('#fileedit-tab-preview-wrapper'),
249250
cbIsExe: E('input[type=checkbox][name=exec_bit]'),
@@ -725,10 +726,11 @@
725726
const fd = new FormData();
726727
fd.append('filename',filename);
727728
fd.append('checkin', this.finfo.checkin);
728729
fd.append('content',content);
729730
fd.append('dry_run',isDryRun ? 1 : 0);
731
+ fd.append('eol', this.e.selectEol.value || 0);
730732
/* Text fields or select lists... */
731733
['comment_mimetype',
732734
'comment'
733735
].forEach(function(name){
734736
var e = E('[name='+name+']');
735737
--- src/fossil.page.fileedit.js
+++ src/fossil.page.fileedit.js
@@ -239,11 +239,12 @@
239 btnCommit: E("#fileedit-btn-commit"),
240 btnReload: E("#fileedit-tab-content > .fileedit-options > "
241 +"button.fileedit-content-reload"),
242 selectPreviewMode: E('#select-preview-mode select'),
243 selectHtmlEmsWrap: E('#select-preview-html-ems'),
244 selectEolWrap: E('#select-preview-html-ems'),
 
245 selectFontSizeWrap: E('#select-font-size'),
246 cbLineNumbersWrap: E('#cb-line-numbers'),
247 cbAutoPreview: E('#cb-preview-autoupdate > input[type=checkbox]'),
248 previewTarget: E('#fileedit-tab-preview-wrapper'),
249 cbIsExe: E('input[type=checkbox][name=exec_bit]'),
@@ -725,10 +726,11 @@
725 const fd = new FormData();
726 fd.append('filename',filename);
727 fd.append('checkin', this.finfo.checkin);
728 fd.append('content',content);
729 fd.append('dry_run',isDryRun ? 1 : 0);
 
730 /* Text fields or select lists... */
731 ['comment_mimetype',
732 'comment'
733 ].forEach(function(name){
734 var e = E('[name='+name+']');
735
--- src/fossil.page.fileedit.js
+++ src/fossil.page.fileedit.js
@@ -239,11 +239,12 @@
239 btnCommit: E("#fileedit-btn-commit"),
240 btnReload: E("#fileedit-tab-content > .fileedit-options > "
241 +"button.fileedit-content-reload"),
242 selectPreviewMode: E('#select-preview-mode select'),
243 selectHtmlEmsWrap: E('#select-preview-html-ems'),
244 selectEolWrap: E('#select-eol-style'),
245 selectEol: E('#select-eol-style select[name=eol]'),
246 selectFontSizeWrap: E('#select-font-size'),
247 cbLineNumbersWrap: E('#cb-line-numbers'),
248 cbAutoPreview: E('#cb-preview-autoupdate > input[type=checkbox]'),
249 previewTarget: E('#fileedit-tab-preview-wrapper'),
250 cbIsExe: E('input[type=checkbox][name=exec_bit]'),
@@ -725,10 +726,11 @@
726 const fd = new FormData();
727 fd.append('filename',filename);
728 fd.append('checkin', this.finfo.checkin);
729 fd.append('content',content);
730 fd.append('dry_run',isDryRun ? 1 : 0);
731 fd.append('eol', this.e.selectEol.value || 0);
732 /* Text fields or select lists... */
733 ['comment_mimetype',
734 'comment'
735 ].forEach(function(name){
736 var e = E('[name='+name+']');
737

Keyboard Shortcuts

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