Fossil SCM
New setting "large-file-size" is a 64-bit integer. If any file of a check-in is larger than this amount, a warning is issues that the users has to confirm before continuing. Warnings can be bypassed using --ignore-oversize or --no-warnings. Use "fossil set large-file-size 0" to permanently disable this warning. Default value is 20,000,000.
Commit
3ffe893f88a4b65b6a1ac6e9d5f2039a1d4d7f390d83a2697a380a03fe0eeeef
Parent
96a66d75f8da2f8…
2 files changed
+50
-26
+11
+50
-26
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -1847,10 +1847,11 @@ | ||
| 1847 | 1847 | static int commit_warning( |
| 1848 | 1848 | Blob *pContent, /* The content of the file being committed. */ |
| 1849 | 1849 | int crlfOk, /* Non-zero if CR/LF warnings should be disabled. */ |
| 1850 | 1850 | int binOk, /* Non-zero if binary warnings should be disabled. */ |
| 1851 | 1851 | int encodingOk, /* Non-zero if encoding warnings should be disabled. */ |
| 1852 | + int sizeOk, /* Non-zero if oversize warnings are disabled */ | |
| 1852 | 1853 | int noPrompt, /* 0 to always prompt, 1 for 'N', 2 for 'Y'. */ |
| 1853 | 1854 | const char *zFilename, /* The full name of the file being committed. */ |
| 1854 | 1855 | Blob *pReason /* Reason for warning, if any (non-fatal only). */ |
| 1855 | 1856 | ){ |
| 1856 | 1857 | int bReverse; /* UTF-16 byte order is reversed? */ |
| @@ -1864,27 +1865,32 @@ | ||
| 1864 | 1865 | char *zMsg; /* Warning message */ |
| 1865 | 1866 | Blob fname; /* Relative pathname of the file */ |
| 1866 | 1867 | static int allOk = 0; /* Set to true to disable this routine */ |
| 1867 | 1868 | |
| 1868 | 1869 | if( allOk ) return 0; |
| 1869 | - fUnicode = could_be_utf16(pContent, &bReverse); | |
| 1870 | - if( fUnicode ){ | |
| 1871 | - lookFlags = looks_like_utf16(pContent, bReverse, LOOK_NUL); | |
| 1870 | + if( sizeOk ){ | |
| 1871 | + fUnicode = could_be_utf16(pContent, &bReverse); | |
| 1872 | + if( fUnicode ){ | |
| 1873 | + lookFlags = looks_like_utf16(pContent, bReverse, LOOK_NUL); | |
| 1874 | + }else{ | |
| 1875 | + lookFlags = looks_like_utf8(pContent, LOOK_NUL); | |
| 1876 | + if( !(lookFlags & LOOK_BINARY) && invalid_utf8(pContent) ){ | |
| 1877 | + fHasInvalidUtf8 = 1; | |
| 1878 | + } | |
| 1879 | + } | |
| 1880 | + fHasAnyCr = (lookFlags & LOOK_CR); | |
| 1881 | + fBinary = (lookFlags & LOOK_BINARY); | |
| 1882 | + fHasLoneCrOnly = ((lookFlags & LOOK_EOL) == LOOK_LONE_CR); | |
| 1883 | + fHasCrLfOnly = ((lookFlags & LOOK_EOL) == LOOK_CRLF); | |
| 1872 | 1884 | }else{ |
| 1873 | - lookFlags = looks_like_utf8(pContent, LOOK_NUL); | |
| 1874 | - if( !(lookFlags & LOOK_BINARY) && invalid_utf8(pContent) ){ | |
| 1875 | - fHasInvalidUtf8 = 1; | |
| 1876 | - } | |
| 1877 | - } | |
| 1878 | - fHasAnyCr = (lookFlags & LOOK_CR); | |
| 1879 | - fBinary = (lookFlags & LOOK_BINARY); | |
| 1880 | - fHasLoneCrOnly = ((lookFlags & LOOK_EOL) == LOOK_LONE_CR); | |
| 1881 | - fHasCrLfOnly = ((lookFlags & LOOK_EOL) == LOOK_CRLF); | |
| 1882 | - if( fUnicode || fHasAnyCr || fBinary || fHasInvalidUtf8 ){ | |
| 1883 | - const char *zWarning; | |
| 1884 | - const char *zDisable; | |
| 1885 | + fUnicode = fHasAnyCr = fBinary = fHasInvalidUtf8 = 0; | |
| 1886 | + } | |
| 1887 | + if( !sizeOk || fUnicode || fHasAnyCr || fBinary || fHasInvalidUtf8 ){ | |
| 1888 | + const char *zWarning = 0; | |
| 1889 | + const char *zDisable = 0; | |
| 1885 | 1890 | const char *zConvert = "c=convert/"; |
| 1891 | + const char *zIn = "in"; | |
| 1886 | 1892 | Blob ans; |
| 1887 | 1893 | char cReply; |
| 1888 | 1894 | |
| 1889 | 1895 | if( fBinary ){ |
| 1890 | 1896 | int fHasNul = (lookFlags & LOOK_NUL); /* contains NUL chars? */ |
| @@ -1928,23 +1934,33 @@ | ||
| 1928 | 1934 | zWarning = "CR/LF line endings"; |
| 1929 | 1935 | }else{ |
| 1930 | 1936 | zWarning = "mixed line endings"; |
| 1931 | 1937 | } |
| 1932 | 1938 | zDisable = "\"crlf-glob\" setting"; |
| 1939 | + }else if( !sizeOk ){ | |
| 1940 | + zWarning = "oversize"; | |
| 1941 | + zIn = "file"; | |
| 1933 | 1942 | }else{ |
| 1934 | 1943 | if( encodingOk ){ |
| 1935 | 1944 | return 0; /* We don't want encoding warnings for this file. */ |
| 1936 | 1945 | } |
| 1937 | 1946 | zWarning = "Unicode"; |
| 1938 | 1947 | zDisable = "\"encoding-glob\" setting"; |
| 1939 | 1948 | } |
| 1940 | 1949 | file_relative_name(zFilename, &fname, 0); |
| 1941 | - zMsg = mprintf( | |
| 1942 | - "%s contains %s. Use --no-warnings or the %s to" | |
| 1943 | - " disable this warning.\n" | |
| 1944 | - "Commit anyhow (a=all/%sy/N)? ", | |
| 1945 | - blob_str(&fname), zWarning, zDisable, zConvert); | |
| 1950 | + if( !sizeOk ){ | |
| 1951 | + zMsg = mprintf( | |
| 1952 | + "%s is more than %,lld bytes in size.\n" | |
| 1953 | + "Commit anyhow (a=all/y/N)? ", | |
| 1954 | + blob_str(&fname), db_large_file_size()); | |
| 1955 | + }else{ | |
| 1956 | + zMsg = mprintf( | |
| 1957 | + "%s contains %s. Use --no-warnings or the %s to" | |
| 1958 | + " disable this warning.\n" | |
| 1959 | + "Commit anyhow (a=all/%sy/N)? ", | |
| 1960 | + blob_str(&fname), zWarning, zDisable, zConvert); | |
| 1961 | + } | |
| 1946 | 1962 | if( noPrompt==0 ){ |
| 1947 | 1963 | prompt_user(zMsg, &ans); |
| 1948 | 1964 | cReply = blob_str(&ans)[0]; |
| 1949 | 1965 | blob_reset(&ans); |
| 1950 | 1966 | }else if( noPrompt==2 ){ |
| @@ -1978,12 +1994,12 @@ | ||
| 1978 | 1994 | fwrite(blob_buffer(pContent), 1, blob_size(pContent), f); |
| 1979 | 1995 | fclose(f); |
| 1980 | 1996 | } |
| 1981 | 1997 | return 1; |
| 1982 | 1998 | }else if( cReply!='y' && cReply!='Y' ){ |
| 1983 | - fossil_fatal("Abandoning commit due to %s in %s", | |
| 1984 | - zWarning, blob_str(&fname)); | |
| 1999 | + fossil_fatal("Abandoning commit due to %s %s %s", | |
| 2000 | + zWarning, zIn, blob_str(&fname)); | |
| 1985 | 2001 | }else if( noPrompt==2 ){ |
| 1986 | 2002 | if( pReason ){ |
| 1987 | 2003 | blob_append(pReason, zWarning, -1); |
| 1988 | 2004 | } |
| 1989 | 2005 | return 1; |
| @@ -2009,15 +2025,17 @@ | ||
| 2009 | 2025 | */ |
| 2010 | 2026 | void test_commit_warning(void){ |
| 2011 | 2027 | int rc = 0; |
| 2012 | 2028 | int noSettings; |
| 2013 | 2029 | int verboseFlag; |
| 2030 | + i64 mxSize; | |
| 2014 | 2031 | Stmt q; |
| 2015 | 2032 | noSettings = find_option("no-settings",0,0)!=0; |
| 2016 | 2033 | verboseFlag = find_option("verbose","v",0)!=0; |
| 2017 | 2034 | verify_all_options(); |
| 2018 | 2035 | db_must_be_within_tree(); |
| 2036 | + mxSize = db_large_file_size(); | |
| 2019 | 2037 | db_prepare(&q, |
| 2020 | 2038 | "SELECT %Q || pathname, pathname, %s, %s, %s FROM vfile" |
| 2021 | 2039 | " WHERE NOT deleted", |
| 2022 | 2040 | g.zLocalRoot, |
| 2023 | 2041 | glob_expr("pathname", noSettings ? 0 : db_get("crlf-glob", |
| @@ -2028,22 +2046,23 @@ | ||
| 2028 | 2046 | while( db_step(&q)==SQLITE_ROW ){ |
| 2029 | 2047 | const char *zFullname; |
| 2030 | 2048 | const char *zName; |
| 2031 | 2049 | Blob content; |
| 2032 | 2050 | Blob reason; |
| 2033 | - int crlfOk, binOk, encodingOk; | |
| 2051 | + int crlfOk, binOk, encodingOk, sizeOk; | |
| 2034 | 2052 | int fileRc; |
| 2035 | 2053 | |
| 2036 | 2054 | zFullname = db_column_text(&q, 0); |
| 2037 | 2055 | zName = db_column_text(&q, 1); |
| 2038 | 2056 | crlfOk = db_column_int(&q, 2); |
| 2039 | 2057 | binOk = db_column_int(&q, 3); |
| 2040 | 2058 | encodingOk = db_column_int(&q, 4); |
| 2059 | + sizeOk = mxSize<=0 || file_size(zFullname, ExtFILE)<=mxSize; | |
| 2041 | 2060 | blob_zero(&content); |
| 2042 | 2061 | blob_read_from_file(&content, zFullname, RepoFILE); |
| 2043 | 2062 | blob_zero(&reason); |
| 2044 | - fileRc = commit_warning(&content, crlfOk, binOk, encodingOk, 2, | |
| 2063 | + fileRc = commit_warning(&content, crlfOk, binOk, encodingOk, sizeOk, 2, | |
| 2045 | 2064 | zFullname, &reason); |
| 2046 | 2065 | if( fileRc || verboseFlag ){ |
| 2047 | 2066 | fossil_print("%d\t%s\t%s\n", fileRc, zName, blob_str(&reason)); |
| 2048 | 2067 | } |
| 2049 | 2068 | blob_reset(&reason); |
| @@ -2138,10 +2157,11 @@ | ||
| 2138 | 2157 | ** than relying on file mtimes |
| 2139 | 2158 | ** --ignore-clock-skew If a clock skew is detected, ignore it and |
| 2140 | 2159 | ** behave as if the user had entered 'yes' to |
| 2141 | 2160 | ** the question of whether to proceed despite |
| 2142 | 2161 | ** the skew. |
| 2162 | +** --ignore-oversize Do not warning the user about oversized files | |
| 2143 | 2163 | ** --integrate close all merged-in branches |
| 2144 | 2164 | ** -m|--comment COMMENT-TEXT use COMMENT-TEXT as commit comment |
| 2145 | 2165 | ** -M|--message-file FILE read the commit comment from given file |
| 2146 | 2166 | ** --mimetype MIMETYPE mimetype of check-in comment |
| 2147 | 2167 | ** -n|--dry-run If given, display instead of run actions |
| @@ -2212,10 +2232,11 @@ | ||
| 2212 | 2232 | Blob ans; /* Answer to continuation prompts */ |
| 2213 | 2233 | char cReply; /* First character of ans */ |
| 2214 | 2234 | int bRecheck = 0; /* Repeat fork and closed-branch checks*/ |
| 2215 | 2235 | int bAutoBrClr = 0; /* Value of "--branchcolor" is "auto" */ |
| 2216 | 2236 | int bIgnoreSkew = 0; /* --ignore-clock-skew flag */ |
| 2237 | + int mxSize; | |
| 2217 | 2238 | |
| 2218 | 2239 | memset(&sCiInfo, 0, sizeof(sCiInfo)); |
| 2219 | 2240 | url_proxy_options(); |
| 2220 | 2241 | /* --sha1sum is an undocumented alias for --hash for backwards compatiblity */ |
| 2221 | 2242 | useHash = find_option("hash",0,0)!=0 || find_option("sha1sum",0,0)!=0; |
| @@ -2271,10 +2292,12 @@ | ||
| 2271 | 2292 | noSign = db_get_boolean("omitsign", 0)|noSign; |
| 2272 | 2293 | if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; } |
| 2273 | 2294 | useCksum = db_get_boolean("repo-cksum", 1); |
| 2274 | 2295 | bIgnoreSkew = find_option("ignore-clock-skew",0,0)!=0; |
| 2275 | 2296 | outputManifest = db_get_manifest_setting(); |
| 2297 | + mxSize = db_large_file_size(); | |
| 2298 | + if( find_option("ignore-oversize",0,0)!=0 ) mxSize = 0; | |
| 2276 | 2299 | verify_all_options(); |
| 2277 | 2300 | |
| 2278 | 2301 | /* Get the ID of the parent manifest artifact */ |
| 2279 | 2302 | vid = db_lget_int("checkout", 0); |
| 2280 | 2303 | if( vid==0 ){ |
| @@ -2592,25 +2615,26 @@ | ||
| 2592 | 2615 | ); |
| 2593 | 2616 | while( db_step(&q)==SQLITE_ROW ){ |
| 2594 | 2617 | int id, rid; |
| 2595 | 2618 | const char *zFullname; |
| 2596 | 2619 | Blob content; |
| 2597 | - int crlfOk, binOk, encodingOk; | |
| 2620 | + int crlfOk, binOk, encodingOk, sizeOk; | |
| 2598 | 2621 | |
| 2599 | 2622 | id = db_column_int(&q, 0); |
| 2600 | 2623 | zFullname = db_column_text(&q, 1); |
| 2601 | 2624 | rid = db_column_int(&q, 2); |
| 2602 | 2625 | crlfOk = db_column_int(&q, 3); |
| 2603 | 2626 | binOk = db_column_int(&q, 4); |
| 2604 | 2627 | encodingOk = db_column_int(&q, 5); |
| 2628 | + sizeOk = mxSize<=0 || file_size(zFullname, ExtFILE)<=mxSize; | |
| 2605 | 2629 | |
| 2606 | 2630 | blob_zero(&content); |
| 2607 | 2631 | blob_read_from_file(&content, zFullname, RepoFILE); |
| 2608 | 2632 | /* Do not emit any warnings when they are disabled. */ |
| 2609 | 2633 | if( !noWarningFlag ){ |
| 2610 | 2634 | abortCommit |= commit_warning(&content, crlfOk, binOk, |
| 2611 | - encodingOk, noPrompt, | |
| 2635 | + encodingOk, sizeOk, noPrompt, | |
| 2612 | 2636 | zFullname, 0); |
| 2613 | 2637 | } |
| 2614 | 2638 | if( contains_merge_marker(&content) ){ |
| 2615 | 2639 | Blob fname; /* Relative pathname of the file */ |
| 2616 | 2640 | |
| 2617 | 2641 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -1847,10 +1847,11 @@ | |
| 1847 | static int commit_warning( |
| 1848 | Blob *pContent, /* The content of the file being committed. */ |
| 1849 | int crlfOk, /* Non-zero if CR/LF warnings should be disabled. */ |
| 1850 | int binOk, /* Non-zero if binary warnings should be disabled. */ |
| 1851 | int encodingOk, /* Non-zero if encoding warnings should be disabled. */ |
| 1852 | int noPrompt, /* 0 to always prompt, 1 for 'N', 2 for 'Y'. */ |
| 1853 | const char *zFilename, /* The full name of the file being committed. */ |
| 1854 | Blob *pReason /* Reason for warning, if any (non-fatal only). */ |
| 1855 | ){ |
| 1856 | int bReverse; /* UTF-16 byte order is reversed? */ |
| @@ -1864,27 +1865,32 @@ | |
| 1864 | char *zMsg; /* Warning message */ |
| 1865 | Blob fname; /* Relative pathname of the file */ |
| 1866 | static int allOk = 0; /* Set to true to disable this routine */ |
| 1867 | |
| 1868 | if( allOk ) return 0; |
| 1869 | fUnicode = could_be_utf16(pContent, &bReverse); |
| 1870 | if( fUnicode ){ |
| 1871 | lookFlags = looks_like_utf16(pContent, bReverse, LOOK_NUL); |
| 1872 | }else{ |
| 1873 | lookFlags = looks_like_utf8(pContent, LOOK_NUL); |
| 1874 | if( !(lookFlags & LOOK_BINARY) && invalid_utf8(pContent) ){ |
| 1875 | fHasInvalidUtf8 = 1; |
| 1876 | } |
| 1877 | } |
| 1878 | fHasAnyCr = (lookFlags & LOOK_CR); |
| 1879 | fBinary = (lookFlags & LOOK_BINARY); |
| 1880 | fHasLoneCrOnly = ((lookFlags & LOOK_EOL) == LOOK_LONE_CR); |
| 1881 | fHasCrLfOnly = ((lookFlags & LOOK_EOL) == LOOK_CRLF); |
| 1882 | if( fUnicode || fHasAnyCr || fBinary || fHasInvalidUtf8 ){ |
| 1883 | const char *zWarning; |
| 1884 | const char *zDisable; |
| 1885 | const char *zConvert = "c=convert/"; |
| 1886 | Blob ans; |
| 1887 | char cReply; |
| 1888 | |
| 1889 | if( fBinary ){ |
| 1890 | int fHasNul = (lookFlags & LOOK_NUL); /* contains NUL chars? */ |
| @@ -1928,23 +1934,33 @@ | |
| 1928 | zWarning = "CR/LF line endings"; |
| 1929 | }else{ |
| 1930 | zWarning = "mixed line endings"; |
| 1931 | } |
| 1932 | zDisable = "\"crlf-glob\" setting"; |
| 1933 | }else{ |
| 1934 | if( encodingOk ){ |
| 1935 | return 0; /* We don't want encoding warnings for this file. */ |
| 1936 | } |
| 1937 | zWarning = "Unicode"; |
| 1938 | zDisable = "\"encoding-glob\" setting"; |
| 1939 | } |
| 1940 | file_relative_name(zFilename, &fname, 0); |
| 1941 | zMsg = mprintf( |
| 1942 | "%s contains %s. Use --no-warnings or the %s to" |
| 1943 | " disable this warning.\n" |
| 1944 | "Commit anyhow (a=all/%sy/N)? ", |
| 1945 | blob_str(&fname), zWarning, zDisable, zConvert); |
| 1946 | if( noPrompt==0 ){ |
| 1947 | prompt_user(zMsg, &ans); |
| 1948 | cReply = blob_str(&ans)[0]; |
| 1949 | blob_reset(&ans); |
| 1950 | }else if( noPrompt==2 ){ |
| @@ -1978,12 +1994,12 @@ | |
| 1978 | fwrite(blob_buffer(pContent), 1, blob_size(pContent), f); |
| 1979 | fclose(f); |
| 1980 | } |
| 1981 | return 1; |
| 1982 | }else if( cReply!='y' && cReply!='Y' ){ |
| 1983 | fossil_fatal("Abandoning commit due to %s in %s", |
| 1984 | zWarning, blob_str(&fname)); |
| 1985 | }else if( noPrompt==2 ){ |
| 1986 | if( pReason ){ |
| 1987 | blob_append(pReason, zWarning, -1); |
| 1988 | } |
| 1989 | return 1; |
| @@ -2009,15 +2025,17 @@ | |
| 2009 | */ |
| 2010 | void test_commit_warning(void){ |
| 2011 | int rc = 0; |
| 2012 | int noSettings; |
| 2013 | int verboseFlag; |
| 2014 | Stmt q; |
| 2015 | noSettings = find_option("no-settings",0,0)!=0; |
| 2016 | verboseFlag = find_option("verbose","v",0)!=0; |
| 2017 | verify_all_options(); |
| 2018 | db_must_be_within_tree(); |
| 2019 | db_prepare(&q, |
| 2020 | "SELECT %Q || pathname, pathname, %s, %s, %s FROM vfile" |
| 2021 | " WHERE NOT deleted", |
| 2022 | g.zLocalRoot, |
| 2023 | glob_expr("pathname", noSettings ? 0 : db_get("crlf-glob", |
| @@ -2028,22 +2046,23 @@ | |
| 2028 | while( db_step(&q)==SQLITE_ROW ){ |
| 2029 | const char *zFullname; |
| 2030 | const char *zName; |
| 2031 | Blob content; |
| 2032 | Blob reason; |
| 2033 | int crlfOk, binOk, encodingOk; |
| 2034 | int fileRc; |
| 2035 | |
| 2036 | zFullname = db_column_text(&q, 0); |
| 2037 | zName = db_column_text(&q, 1); |
| 2038 | crlfOk = db_column_int(&q, 2); |
| 2039 | binOk = db_column_int(&q, 3); |
| 2040 | encodingOk = db_column_int(&q, 4); |
| 2041 | blob_zero(&content); |
| 2042 | blob_read_from_file(&content, zFullname, RepoFILE); |
| 2043 | blob_zero(&reason); |
| 2044 | fileRc = commit_warning(&content, crlfOk, binOk, encodingOk, 2, |
| 2045 | zFullname, &reason); |
| 2046 | if( fileRc || verboseFlag ){ |
| 2047 | fossil_print("%d\t%s\t%s\n", fileRc, zName, blob_str(&reason)); |
| 2048 | } |
| 2049 | blob_reset(&reason); |
| @@ -2138,10 +2157,11 @@ | |
| 2138 | ** than relying on file mtimes |
| 2139 | ** --ignore-clock-skew If a clock skew is detected, ignore it and |
| 2140 | ** behave as if the user had entered 'yes' to |
| 2141 | ** the question of whether to proceed despite |
| 2142 | ** the skew. |
| 2143 | ** --integrate close all merged-in branches |
| 2144 | ** -m|--comment COMMENT-TEXT use COMMENT-TEXT as commit comment |
| 2145 | ** -M|--message-file FILE read the commit comment from given file |
| 2146 | ** --mimetype MIMETYPE mimetype of check-in comment |
| 2147 | ** -n|--dry-run If given, display instead of run actions |
| @@ -2212,10 +2232,11 @@ | |
| 2212 | Blob ans; /* Answer to continuation prompts */ |
| 2213 | char cReply; /* First character of ans */ |
| 2214 | int bRecheck = 0; /* Repeat fork and closed-branch checks*/ |
| 2215 | int bAutoBrClr = 0; /* Value of "--branchcolor" is "auto" */ |
| 2216 | int bIgnoreSkew = 0; /* --ignore-clock-skew flag */ |
| 2217 | |
| 2218 | memset(&sCiInfo, 0, sizeof(sCiInfo)); |
| 2219 | url_proxy_options(); |
| 2220 | /* --sha1sum is an undocumented alias for --hash for backwards compatiblity */ |
| 2221 | useHash = find_option("hash",0,0)!=0 || find_option("sha1sum",0,0)!=0; |
| @@ -2271,10 +2292,12 @@ | |
| 2271 | noSign = db_get_boolean("omitsign", 0)|noSign; |
| 2272 | if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; } |
| 2273 | useCksum = db_get_boolean("repo-cksum", 1); |
| 2274 | bIgnoreSkew = find_option("ignore-clock-skew",0,0)!=0; |
| 2275 | outputManifest = db_get_manifest_setting(); |
| 2276 | verify_all_options(); |
| 2277 | |
| 2278 | /* Get the ID of the parent manifest artifact */ |
| 2279 | vid = db_lget_int("checkout", 0); |
| 2280 | if( vid==0 ){ |
| @@ -2592,25 +2615,26 @@ | |
| 2592 | ); |
| 2593 | while( db_step(&q)==SQLITE_ROW ){ |
| 2594 | int id, rid; |
| 2595 | const char *zFullname; |
| 2596 | Blob content; |
| 2597 | int crlfOk, binOk, encodingOk; |
| 2598 | |
| 2599 | id = db_column_int(&q, 0); |
| 2600 | zFullname = db_column_text(&q, 1); |
| 2601 | rid = db_column_int(&q, 2); |
| 2602 | crlfOk = db_column_int(&q, 3); |
| 2603 | binOk = db_column_int(&q, 4); |
| 2604 | encodingOk = db_column_int(&q, 5); |
| 2605 | |
| 2606 | blob_zero(&content); |
| 2607 | blob_read_from_file(&content, zFullname, RepoFILE); |
| 2608 | /* Do not emit any warnings when they are disabled. */ |
| 2609 | if( !noWarningFlag ){ |
| 2610 | abortCommit |= commit_warning(&content, crlfOk, binOk, |
| 2611 | encodingOk, noPrompt, |
| 2612 | zFullname, 0); |
| 2613 | } |
| 2614 | if( contains_merge_marker(&content) ){ |
| 2615 | Blob fname; /* Relative pathname of the file */ |
| 2616 | |
| 2617 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -1847,10 +1847,11 @@ | |
| 1847 | static int commit_warning( |
| 1848 | Blob *pContent, /* The content of the file being committed. */ |
| 1849 | int crlfOk, /* Non-zero if CR/LF warnings should be disabled. */ |
| 1850 | int binOk, /* Non-zero if binary warnings should be disabled. */ |
| 1851 | int encodingOk, /* Non-zero if encoding warnings should be disabled. */ |
| 1852 | int sizeOk, /* Non-zero if oversize warnings are disabled */ |
| 1853 | int noPrompt, /* 0 to always prompt, 1 for 'N', 2 for 'Y'. */ |
| 1854 | const char *zFilename, /* The full name of the file being committed. */ |
| 1855 | Blob *pReason /* Reason for warning, if any (non-fatal only). */ |
| 1856 | ){ |
| 1857 | int bReverse; /* UTF-16 byte order is reversed? */ |
| @@ -1864,27 +1865,32 @@ | |
| 1865 | char *zMsg; /* Warning message */ |
| 1866 | Blob fname; /* Relative pathname of the file */ |
| 1867 | static int allOk = 0; /* Set to true to disable this routine */ |
| 1868 | |
| 1869 | if( allOk ) return 0; |
| 1870 | if( sizeOk ){ |
| 1871 | fUnicode = could_be_utf16(pContent, &bReverse); |
| 1872 | if( fUnicode ){ |
| 1873 | lookFlags = looks_like_utf16(pContent, bReverse, LOOK_NUL); |
| 1874 | }else{ |
| 1875 | lookFlags = looks_like_utf8(pContent, LOOK_NUL); |
| 1876 | if( !(lookFlags & LOOK_BINARY) && invalid_utf8(pContent) ){ |
| 1877 | fHasInvalidUtf8 = 1; |
| 1878 | } |
| 1879 | } |
| 1880 | fHasAnyCr = (lookFlags & LOOK_CR); |
| 1881 | fBinary = (lookFlags & LOOK_BINARY); |
| 1882 | fHasLoneCrOnly = ((lookFlags & LOOK_EOL) == LOOK_LONE_CR); |
| 1883 | fHasCrLfOnly = ((lookFlags & LOOK_EOL) == LOOK_CRLF); |
| 1884 | }else{ |
| 1885 | fUnicode = fHasAnyCr = fBinary = fHasInvalidUtf8 = 0; |
| 1886 | } |
| 1887 | if( !sizeOk || fUnicode || fHasAnyCr || fBinary || fHasInvalidUtf8 ){ |
| 1888 | const char *zWarning = 0; |
| 1889 | const char *zDisable = 0; |
| 1890 | const char *zConvert = "c=convert/"; |
| 1891 | const char *zIn = "in"; |
| 1892 | Blob ans; |
| 1893 | char cReply; |
| 1894 | |
| 1895 | if( fBinary ){ |
| 1896 | int fHasNul = (lookFlags & LOOK_NUL); /* contains NUL chars? */ |
| @@ -1928,23 +1934,33 @@ | |
| 1934 | zWarning = "CR/LF line endings"; |
| 1935 | }else{ |
| 1936 | zWarning = "mixed line endings"; |
| 1937 | } |
| 1938 | zDisable = "\"crlf-glob\" setting"; |
| 1939 | }else if( !sizeOk ){ |
| 1940 | zWarning = "oversize"; |
| 1941 | zIn = "file"; |
| 1942 | }else{ |
| 1943 | if( encodingOk ){ |
| 1944 | return 0; /* We don't want encoding warnings for this file. */ |
| 1945 | } |
| 1946 | zWarning = "Unicode"; |
| 1947 | zDisable = "\"encoding-glob\" setting"; |
| 1948 | } |
| 1949 | file_relative_name(zFilename, &fname, 0); |
| 1950 | if( !sizeOk ){ |
| 1951 | zMsg = mprintf( |
| 1952 | "%s is more than %,lld bytes in size.\n" |
| 1953 | "Commit anyhow (a=all/y/N)? ", |
| 1954 | blob_str(&fname), db_large_file_size()); |
| 1955 | }else{ |
| 1956 | zMsg = mprintf( |
| 1957 | "%s contains %s. Use --no-warnings or the %s to" |
| 1958 | " disable this warning.\n" |
| 1959 | "Commit anyhow (a=all/%sy/N)? ", |
| 1960 | blob_str(&fname), zWarning, zDisable, zConvert); |
| 1961 | } |
| 1962 | if( noPrompt==0 ){ |
| 1963 | prompt_user(zMsg, &ans); |
| 1964 | cReply = blob_str(&ans)[0]; |
| 1965 | blob_reset(&ans); |
| 1966 | }else if( noPrompt==2 ){ |
| @@ -1978,12 +1994,12 @@ | |
| 1994 | fwrite(blob_buffer(pContent), 1, blob_size(pContent), f); |
| 1995 | fclose(f); |
| 1996 | } |
| 1997 | return 1; |
| 1998 | }else if( cReply!='y' && cReply!='Y' ){ |
| 1999 | fossil_fatal("Abandoning commit due to %s %s %s", |
| 2000 | zWarning, zIn, blob_str(&fname)); |
| 2001 | }else if( noPrompt==2 ){ |
| 2002 | if( pReason ){ |
| 2003 | blob_append(pReason, zWarning, -1); |
| 2004 | } |
| 2005 | return 1; |
| @@ -2009,15 +2025,17 @@ | |
| 2025 | */ |
| 2026 | void test_commit_warning(void){ |
| 2027 | int rc = 0; |
| 2028 | int noSettings; |
| 2029 | int verboseFlag; |
| 2030 | i64 mxSize; |
| 2031 | Stmt q; |
| 2032 | noSettings = find_option("no-settings",0,0)!=0; |
| 2033 | verboseFlag = find_option("verbose","v",0)!=0; |
| 2034 | verify_all_options(); |
| 2035 | db_must_be_within_tree(); |
| 2036 | mxSize = db_large_file_size(); |
| 2037 | db_prepare(&q, |
| 2038 | "SELECT %Q || pathname, pathname, %s, %s, %s FROM vfile" |
| 2039 | " WHERE NOT deleted", |
| 2040 | g.zLocalRoot, |
| 2041 | glob_expr("pathname", noSettings ? 0 : db_get("crlf-glob", |
| @@ -2028,22 +2046,23 @@ | |
| 2046 | while( db_step(&q)==SQLITE_ROW ){ |
| 2047 | const char *zFullname; |
| 2048 | const char *zName; |
| 2049 | Blob content; |
| 2050 | Blob reason; |
| 2051 | int crlfOk, binOk, encodingOk, sizeOk; |
| 2052 | int fileRc; |
| 2053 | |
| 2054 | zFullname = db_column_text(&q, 0); |
| 2055 | zName = db_column_text(&q, 1); |
| 2056 | crlfOk = db_column_int(&q, 2); |
| 2057 | binOk = db_column_int(&q, 3); |
| 2058 | encodingOk = db_column_int(&q, 4); |
| 2059 | sizeOk = mxSize<=0 || file_size(zFullname, ExtFILE)<=mxSize; |
| 2060 | blob_zero(&content); |
| 2061 | blob_read_from_file(&content, zFullname, RepoFILE); |
| 2062 | blob_zero(&reason); |
| 2063 | fileRc = commit_warning(&content, crlfOk, binOk, encodingOk, sizeOk, 2, |
| 2064 | zFullname, &reason); |
| 2065 | if( fileRc || verboseFlag ){ |
| 2066 | fossil_print("%d\t%s\t%s\n", fileRc, zName, blob_str(&reason)); |
| 2067 | } |
| 2068 | blob_reset(&reason); |
| @@ -2138,10 +2157,11 @@ | |
| 2157 | ** than relying on file mtimes |
| 2158 | ** --ignore-clock-skew If a clock skew is detected, ignore it and |
| 2159 | ** behave as if the user had entered 'yes' to |
| 2160 | ** the question of whether to proceed despite |
| 2161 | ** the skew. |
| 2162 | ** --ignore-oversize Do not warning the user about oversized files |
| 2163 | ** --integrate close all merged-in branches |
| 2164 | ** -m|--comment COMMENT-TEXT use COMMENT-TEXT as commit comment |
| 2165 | ** -M|--message-file FILE read the commit comment from given file |
| 2166 | ** --mimetype MIMETYPE mimetype of check-in comment |
| 2167 | ** -n|--dry-run If given, display instead of run actions |
| @@ -2212,10 +2232,11 @@ | |
| 2232 | Blob ans; /* Answer to continuation prompts */ |
| 2233 | char cReply; /* First character of ans */ |
| 2234 | int bRecheck = 0; /* Repeat fork and closed-branch checks*/ |
| 2235 | int bAutoBrClr = 0; /* Value of "--branchcolor" is "auto" */ |
| 2236 | int bIgnoreSkew = 0; /* --ignore-clock-skew flag */ |
| 2237 | int mxSize; |
| 2238 | |
| 2239 | memset(&sCiInfo, 0, sizeof(sCiInfo)); |
| 2240 | url_proxy_options(); |
| 2241 | /* --sha1sum is an undocumented alias for --hash for backwards compatiblity */ |
| 2242 | useHash = find_option("hash",0,0)!=0 || find_option("sha1sum",0,0)!=0; |
| @@ -2271,10 +2292,12 @@ | |
| 2292 | noSign = db_get_boolean("omitsign", 0)|noSign; |
| 2293 | if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; } |
| 2294 | useCksum = db_get_boolean("repo-cksum", 1); |
| 2295 | bIgnoreSkew = find_option("ignore-clock-skew",0,0)!=0; |
| 2296 | outputManifest = db_get_manifest_setting(); |
| 2297 | mxSize = db_large_file_size(); |
| 2298 | if( find_option("ignore-oversize",0,0)!=0 ) mxSize = 0; |
| 2299 | verify_all_options(); |
| 2300 | |
| 2301 | /* Get the ID of the parent manifest artifact */ |
| 2302 | vid = db_lget_int("checkout", 0); |
| 2303 | if( vid==0 ){ |
| @@ -2592,25 +2615,26 @@ | |
| 2615 | ); |
| 2616 | while( db_step(&q)==SQLITE_ROW ){ |
| 2617 | int id, rid; |
| 2618 | const char *zFullname; |
| 2619 | Blob content; |
| 2620 | int crlfOk, binOk, encodingOk, sizeOk; |
| 2621 | |
| 2622 | id = db_column_int(&q, 0); |
| 2623 | zFullname = db_column_text(&q, 1); |
| 2624 | rid = db_column_int(&q, 2); |
| 2625 | crlfOk = db_column_int(&q, 3); |
| 2626 | binOk = db_column_int(&q, 4); |
| 2627 | encodingOk = db_column_int(&q, 5); |
| 2628 | sizeOk = mxSize<=0 || file_size(zFullname, ExtFILE)<=mxSize; |
| 2629 | |
| 2630 | blob_zero(&content); |
| 2631 | blob_read_from_file(&content, zFullname, RepoFILE); |
| 2632 | /* Do not emit any warnings when they are disabled. */ |
| 2633 | if( !noWarningFlag ){ |
| 2634 | abortCommit |= commit_warning(&content, crlfOk, binOk, |
| 2635 | encodingOk, sizeOk, noPrompt, |
| 2636 | zFullname, 0); |
| 2637 | } |
| 2638 | if( contains_merge_marker(&content) ){ |
| 2639 | Blob fname; /* Relative pathname of the file */ |
| 2640 | |
| 2641 |
M
src/db.c
+11
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -3324,10 +3324,14 @@ | ||
| 3324 | 3324 | } |
| 3325 | 3325 | db_reset(&q2); |
| 3326 | 3326 | } |
| 3327 | 3327 | return v; |
| 3328 | 3328 | } |
| 3329 | +i64 db_large_file_size(void){ | |
| 3330 | + /* Return size of the largest file that is not considered oversized */ | |
| 3331 | + return strtoll(db_get("large-file-size","20000000"),0,0); | |
| 3332 | +} | |
| 3329 | 3333 | void db_set_int(const char *zName, int value, int globalFlag){ |
| 3330 | 3334 | db_assert_protection_off_or_not_sensitive(zName); |
| 3331 | 3335 | db_unprotect(PROTECT_CONFIG); |
| 3332 | 3336 | if( globalFlag ){ |
| 3333 | 3337 | db_swap_connections(); |
| @@ -4395,10 +4399,17 @@ | ||
| 4395 | 4399 | ** A shell command used to launch your preferred |
| 4396 | 4400 | ** web browser when given a URL as an argument. |
| 4397 | 4401 | ** Defaults to "start" on windows, "open" on Mac, |
| 4398 | 4402 | ** and "firefox" on Unix. |
| 4399 | 4403 | */ |
| 4404 | +/* | |
| 4405 | +** SETTING: large-file-size width=10 default=200000000 | |
| 4406 | +** Fossil considers any file whose size is greater than this value | |
| 4407 | +** to be a "large file". Fossil might issue warnings if you try to | |
| 4408 | +** "add" or "commit" a "large file". Set this value to 0 or less | |
| 4409 | +** to disable all such warnings. | |
| 4410 | +*/ | |
| 4400 | 4411 | |
| 4401 | 4412 | /* |
| 4402 | 4413 | ** Look up a control setting by its name. Return a pointer to the Setting |
| 4403 | 4414 | ** object, or NULL if there is no such setting. |
| 4404 | 4415 | ** |
| 4405 | 4416 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -3324,10 +3324,14 @@ | |
| 3324 | } |
| 3325 | db_reset(&q2); |
| 3326 | } |
| 3327 | return v; |
| 3328 | } |
| 3329 | void db_set_int(const char *zName, int value, int globalFlag){ |
| 3330 | db_assert_protection_off_or_not_sensitive(zName); |
| 3331 | db_unprotect(PROTECT_CONFIG); |
| 3332 | if( globalFlag ){ |
| 3333 | db_swap_connections(); |
| @@ -4395,10 +4399,17 @@ | |
| 4395 | ** A shell command used to launch your preferred |
| 4396 | ** web browser when given a URL as an argument. |
| 4397 | ** Defaults to "start" on windows, "open" on Mac, |
| 4398 | ** and "firefox" on Unix. |
| 4399 | */ |
| 4400 | |
| 4401 | /* |
| 4402 | ** Look up a control setting by its name. Return a pointer to the Setting |
| 4403 | ** object, or NULL if there is no such setting. |
| 4404 | ** |
| 4405 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -3324,10 +3324,14 @@ | |
| 3324 | } |
| 3325 | db_reset(&q2); |
| 3326 | } |
| 3327 | return v; |
| 3328 | } |
| 3329 | i64 db_large_file_size(void){ |
| 3330 | /* Return size of the largest file that is not considered oversized */ |
| 3331 | return strtoll(db_get("large-file-size","20000000"),0,0); |
| 3332 | } |
| 3333 | void db_set_int(const char *zName, int value, int globalFlag){ |
| 3334 | db_assert_protection_off_or_not_sensitive(zName); |
| 3335 | db_unprotect(PROTECT_CONFIG); |
| 3336 | if( globalFlag ){ |
| 3337 | db_swap_connections(); |
| @@ -4395,10 +4399,17 @@ | |
| 4399 | ** A shell command used to launch your preferred |
| 4400 | ** web browser when given a URL as an argument. |
| 4401 | ** Defaults to "start" on windows, "open" on Mac, |
| 4402 | ** and "firefox" on Unix. |
| 4403 | */ |
| 4404 | /* |
| 4405 | ** SETTING: large-file-size width=10 default=200000000 |
| 4406 | ** Fossil considers any file whose size is greater than this value |
| 4407 | ** to be a "large file". Fossil might issue warnings if you try to |
| 4408 | ** "add" or "commit" a "large file". Set this value to 0 or less |
| 4409 | ** to disable all such warnings. |
| 4410 | */ |
| 4411 | |
| 4412 | /* |
| 4413 | ** Look up a control setting by its name. Return a pointer to the Setting |
| 4414 | ** object, or NULL if there is no such setting. |
| 4415 | ** |
| 4416 |