Fossil

Diff
Login

Diff

Differences From Artifact [6ace47dfc6]:

To Artifact [1c724aec23]:


878
879
880
881
882
883
884
885

886
887
888

889
890
891
892
893
894
895
896

897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912

913
914
915
916
917


918
919
920
921
922


923
924
925
926
927
928
929
930


931
932
933
934
935
936
937
878
879
880
881
882
883
884

885
886
887

888




889
890
891
892
893
894
895














896





897
898
899
900
901


902
903
904
905
906
907
908
909


910
911
912
913
914
915
916
917
918







-
+


-
+
-
-
-
-




+


-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
+
+



-
-
+
+






-
-
+
+







  md5sum_blob(pOut, &mcksum);
  blob_appendf(pOut, "Z %b\n", &mcksum);
  if( pnFBcard ) *pnFBcard = nFBcard;
}

/*
** Issue a warning and give the user an opportunity to abandon out
** if a \r\n line ending is seen in a text file.
** if unicode or a \r\n line ending is seen in a text file.
*/
static void cr_warning(const Blob *p, const char *zFilename){
  int nCrNl = 0;          /* Number of \r\n line endings seen */
  int looksLike;          /* return value of looks_like_text() */
  const unsigned char *z; /* File text */
  int n;                  /* Size of the file in bytes */
  int lastNl = 0;         /* Characters since last \n */
  int i;                  /* Loop counter */
  char *zMsg;             /* Warning message */
  Blob fname;             /* Relative pathname of the file */
  Blob ans;               /* Answer to continue prompt */
  static int allOk = 0;   /* Set to true to disable this routine */
  char c;

  if( allOk ) return;
  z = (unsigned char*)blob_buffer(p);
  n = blob_size(p);
  for(i=0; i<n-1; i++){
    unsigned char c = z[i];
    if( c==0 ) return;   /* It's binary */
    if( c=='\n' ){
      if( i>0 && z[i-1]=='\r' ){
        nCrNl = 1;
        if( i>8191 ) break;
      }
      lastNl = 0;
    }else{
      lastNl++;
      /* Binary if any line longer than 8191, see looks_like_binary() */
  looksLike = looks_like_text(p);
      if( lastNl>8191 ) return;
    }
  }
  if( nCrNl ){
    char c;
  if( looksLike<0 ){
    const char *type = (looksLike&1)?"CR/NL line endings":"unicode";
    file_relative_name(zFilename, &fname, 0);
    blob_zero(&ans);
    zMsg = mprintf(
         "%s contains CR/NL line endings; commit anyhow (yes/no/all)?", 
         blob_str(&fname));
         "%s contains %s; commit anyhow (yes/no/all)?",
         blob_str(&fname), type);
    prompt_user(zMsg, &ans);
    fossil_free(zMsg);
    c = blob_str(&ans)[0];
    if( c=='a' ){
      allOk = 1;
    }else if( c!='y' ){
      fossil_fatal("Abandoning commit due to CR+NL line endings in %s",
                   blob_str(&fname));
      fossil_fatal("Abandoning commit due to %s in %s",
                   type, blob_str(&fname));
    }
    blob_reset(&ans);
    blob_reset(&fname);
  }
}

/*