Fossil SCM
Improvements to the "You Can Clone This Repository" section at the bottom of the /download page.
Commit
54e1d7dcfa18008fb754314ebf16d6cc0e13068fe363358bc4b4b4ecacf1b3c9
Parent
df4f6c189af8dc6…
1 file changed
+26
-17
+26
-17
| --- src/tar.c | ||
| +++ src/tar.c | ||
| @@ -30,10 +30,27 @@ | ||
| 30 | 30 | char *zSpaces; /* Spaces for padding */ |
| 31 | 31 | char *zPrevDir; /* Name of directory for previous entry */ |
| 32 | 32 | int nPrevDirAlloc; /* size of zPrevDir */ |
| 33 | 33 | Blob pax; /* PAX data */ |
| 34 | 34 | } tball; |
| 35 | + | |
| 36 | +/* | |
| 37 | +** Convert a string so that it contains only lower-case ASCII, digits, | |
| 38 | +** "_" and "-". Changes are made in-place. | |
| 39 | +*/ | |
| 40 | +static void sanitize_name(char *zName){ | |
| 41 | + int i; | |
| 42 | + char c; | |
| 43 | + for(i=0; (c = zName[i])!=0; i++){ | |
| 44 | + if( fossil_isupper(c) ){ | |
| 45 | + zName[i] = fossil_tolower(c); | |
| 46 | + }else if( !fossil_isalnum(c) && c!='_' && c!='-' ){ | |
| 47 | + /* 123456789 123456789 123456 */ | |
| 48 | + zName[i] = "abcdefghijklmnopqrstuvwxyz"[(unsigned)c%26]; | |
| 49 | + } | |
| 50 | + } | |
| 51 | +} | |
| 35 | 52 | |
| 36 | 53 | /* |
| 37 | 54 | ** Compute a sensible base-name for an archive file (tarball, ZIP, or SQLAR) |
| 38 | 55 | ** based on the rid of the check-in contained in that file. |
| 39 | 56 | ** |
| @@ -47,29 +64,20 @@ | ||
| 47 | 64 | ** The value returned is obtained from mprintf() or fossil_strdup() and should |
| 48 | 65 | ** be released by the caller using fossil_free(). |
| 49 | 66 | */ |
| 50 | 67 | char *archive_base_name(int rid){ |
| 51 | 68 | char *zName; |
| 52 | - int i; | |
| 53 | - char c; | |
| 54 | 69 | zName = db_text(0, |
| 55 | 70 | "SELECT coalesce(config.value,'unnamed')||" |
| 56 | 71 | " strftime('-%%Y%%m%%d%%H%%M%%S-',event.mtime)||" |
| 57 | 72 | " substr(blob.uuid,1,10)" |
| 58 | 73 | " FROM blob, event LEFT JOIN config" |
| 59 | 74 | " WHERE blob.rid=%d" |
| 60 | 75 | " AND event.objid=%d" |
| 61 | 76 | " AND config.name='project-name'", |
| 62 | 77 | rid, rid); |
| 63 | - for(i=0; (c = zName[i])!=0; i++){ | |
| 64 | - if( fossil_isupper(c) ){ | |
| 65 | - zName[i] = fossil_tolower(c); | |
| 66 | - }else if( !fossil_isalnum(c) && c!='_' && c!='-' ){ | |
| 67 | - /* 123456789 123456789 123456 */ | |
| 68 | - zName[i] = "abcdefghijklmnopqrstuvwxyz"[(unsigned)c%26]; | |
| 69 | - } | |
| 70 | - } | |
| 78 | + sanitize_name(zName); | |
| 71 | 79 | return zName; |
| 72 | 80 | } |
| 73 | 81 | |
| 74 | 82 | |
| 75 | 83 | |
| @@ -1241,25 +1249,26 @@ | ||
| 1241 | 1249 | | TIMELINE_BRCOLOR; |
| 1242 | 1250 | www_print_timeline(&q, tmFlags, 0, 0, 0, 0, 0, download_extra); |
| 1243 | 1251 | db_finalize(&q); |
| 1244 | 1252 | } |
| 1245 | 1253 | if( g.perm.Clone ){ |
| 1246 | - const char *zNm = db_get("short-project-name","clone"); | |
| 1254 | + char *zNm = fossil_strdup(db_get("project-name","clone")); | |
| 1255 | + sanitize_name(zNm); | |
| 1247 | 1256 | @ <hr> |
| 1248 | 1257 | @ <h2>You Can Clone This Repository</h2> |
| 1249 | - @ <p>A clone gives you local access to all historical content. | |
| 1250 | - @ Cloning is a bandwidth- and CPU-efficient alternative to extracting | |
| 1251 | - @ multiple tarballs and ZIP archives for users who need access to many | |
| 1252 | - @ different check-ins. | |
| 1253 | 1258 | @ |
| 1254 | - @ <p>Clone this repository by running a command like the following: | |
| 1259 | + @ <p>Clone this repository by running a command similar to the following: | |
| 1255 | 1260 | @ <blockquote><pre> |
| 1256 | 1261 | @ fossil clone %s(g.zBaseURL) %h(zNm).fossil |
| 1257 | 1262 | @ </pre></blockquote> |
| 1258 | - @ <p>Do a web search for "fossil clone" or similar to find additional | |
| 1263 | + @ <p>A clone gives you local access to all historical content. | |
| 1264 | + @ Cloning is a bandwidth- and CPU-efficient alternative to extracting | |
| 1265 | + @ multiple tarballs and ZIPs. | |
| 1266 | + @ Do a web search for "fossil clone" or similar to find additional | |
| 1259 | 1267 | @ information about using a cloned Fossil repository. Or ask your |
| 1260 | 1268 | @ favorite AI how to extract content from a Fossil clone. |
| 1269 | + fossil_free(zNm); | |
| 1261 | 1270 | } |
| 1262 | 1271 | |
| 1263 | 1272 | style_finish_page(); |
| 1264 | 1273 | } |
| 1265 | 1274 | |
| 1266 | 1275 |
| --- src/tar.c | |
| +++ src/tar.c | |
| @@ -30,10 +30,27 @@ | |
| 30 | char *zSpaces; /* Spaces for padding */ |
| 31 | char *zPrevDir; /* Name of directory for previous entry */ |
| 32 | int nPrevDirAlloc; /* size of zPrevDir */ |
| 33 | Blob pax; /* PAX data */ |
| 34 | } tball; |
| 35 | |
| 36 | /* |
| 37 | ** Compute a sensible base-name for an archive file (tarball, ZIP, or SQLAR) |
| 38 | ** based on the rid of the check-in contained in that file. |
| 39 | ** |
| @@ -47,29 +64,20 @@ | |
| 47 | ** The value returned is obtained from mprintf() or fossil_strdup() and should |
| 48 | ** be released by the caller using fossil_free(). |
| 49 | */ |
| 50 | char *archive_base_name(int rid){ |
| 51 | char *zName; |
| 52 | int i; |
| 53 | char c; |
| 54 | zName = db_text(0, |
| 55 | "SELECT coalesce(config.value,'unnamed')||" |
| 56 | " strftime('-%%Y%%m%%d%%H%%M%%S-',event.mtime)||" |
| 57 | " substr(blob.uuid,1,10)" |
| 58 | " FROM blob, event LEFT JOIN config" |
| 59 | " WHERE blob.rid=%d" |
| 60 | " AND event.objid=%d" |
| 61 | " AND config.name='project-name'", |
| 62 | rid, rid); |
| 63 | for(i=0; (c = zName[i])!=0; i++){ |
| 64 | if( fossil_isupper(c) ){ |
| 65 | zName[i] = fossil_tolower(c); |
| 66 | }else if( !fossil_isalnum(c) && c!='_' && c!='-' ){ |
| 67 | /* 123456789 123456789 123456 */ |
| 68 | zName[i] = "abcdefghijklmnopqrstuvwxyz"[(unsigned)c%26]; |
| 69 | } |
| 70 | } |
| 71 | return zName; |
| 72 | } |
| 73 | |
| 74 | |
| 75 | |
| @@ -1241,25 +1249,26 @@ | |
| 1241 | | TIMELINE_BRCOLOR; |
| 1242 | www_print_timeline(&q, tmFlags, 0, 0, 0, 0, 0, download_extra); |
| 1243 | db_finalize(&q); |
| 1244 | } |
| 1245 | if( g.perm.Clone ){ |
| 1246 | const char *zNm = db_get("short-project-name","clone"); |
| 1247 | @ <hr> |
| 1248 | @ <h2>You Can Clone This Repository</h2> |
| 1249 | @ <p>A clone gives you local access to all historical content. |
| 1250 | @ Cloning is a bandwidth- and CPU-efficient alternative to extracting |
| 1251 | @ multiple tarballs and ZIP archives for users who need access to many |
| 1252 | @ different check-ins. |
| 1253 | @ |
| 1254 | @ <p>Clone this repository by running a command like the following: |
| 1255 | @ <blockquote><pre> |
| 1256 | @ fossil clone %s(g.zBaseURL) %h(zNm).fossil |
| 1257 | @ </pre></blockquote> |
| 1258 | @ <p>Do a web search for "fossil clone" or similar to find additional |
| 1259 | @ information about using a cloned Fossil repository. Or ask your |
| 1260 | @ favorite AI how to extract content from a Fossil clone. |
| 1261 | } |
| 1262 | |
| 1263 | style_finish_page(); |
| 1264 | } |
| 1265 | |
| 1266 |
| --- src/tar.c | |
| +++ src/tar.c | |
| @@ -30,10 +30,27 @@ | |
| 30 | char *zSpaces; /* Spaces for padding */ |
| 31 | char *zPrevDir; /* Name of directory for previous entry */ |
| 32 | int nPrevDirAlloc; /* size of zPrevDir */ |
| 33 | Blob pax; /* PAX data */ |
| 34 | } tball; |
| 35 | |
| 36 | /* |
| 37 | ** Convert a string so that it contains only lower-case ASCII, digits, |
| 38 | ** "_" and "-". Changes are made in-place. |
| 39 | */ |
| 40 | static void sanitize_name(char *zName){ |
| 41 | int i; |
| 42 | char c; |
| 43 | for(i=0; (c = zName[i])!=0; i++){ |
| 44 | if( fossil_isupper(c) ){ |
| 45 | zName[i] = fossil_tolower(c); |
| 46 | }else if( !fossil_isalnum(c) && c!='_' && c!='-' ){ |
| 47 | /* 123456789 123456789 123456 */ |
| 48 | zName[i] = "abcdefghijklmnopqrstuvwxyz"[(unsigned)c%26]; |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | /* |
| 54 | ** Compute a sensible base-name for an archive file (tarball, ZIP, or SQLAR) |
| 55 | ** based on the rid of the check-in contained in that file. |
| 56 | ** |
| @@ -47,29 +64,20 @@ | |
| 64 | ** The value returned is obtained from mprintf() or fossil_strdup() and should |
| 65 | ** be released by the caller using fossil_free(). |
| 66 | */ |
| 67 | char *archive_base_name(int rid){ |
| 68 | char *zName; |
| 69 | zName = db_text(0, |
| 70 | "SELECT coalesce(config.value,'unnamed')||" |
| 71 | " strftime('-%%Y%%m%%d%%H%%M%%S-',event.mtime)||" |
| 72 | " substr(blob.uuid,1,10)" |
| 73 | " FROM blob, event LEFT JOIN config" |
| 74 | " WHERE blob.rid=%d" |
| 75 | " AND event.objid=%d" |
| 76 | " AND config.name='project-name'", |
| 77 | rid, rid); |
| 78 | sanitize_name(zName); |
| 79 | return zName; |
| 80 | } |
| 81 | |
| 82 | |
| 83 | |
| @@ -1241,25 +1249,26 @@ | |
| 1249 | | TIMELINE_BRCOLOR; |
| 1250 | www_print_timeline(&q, tmFlags, 0, 0, 0, 0, 0, download_extra); |
| 1251 | db_finalize(&q); |
| 1252 | } |
| 1253 | if( g.perm.Clone ){ |
| 1254 | char *zNm = fossil_strdup(db_get("project-name","clone")); |
| 1255 | sanitize_name(zNm); |
| 1256 | @ <hr> |
| 1257 | @ <h2>You Can Clone This Repository</h2> |
| 1258 | @ |
| 1259 | @ <p>Clone this repository by running a command similar to the following: |
| 1260 | @ <blockquote><pre> |
| 1261 | @ fossil clone %s(g.zBaseURL) %h(zNm).fossil |
| 1262 | @ </pre></blockquote> |
| 1263 | @ <p>A clone gives you local access to all historical content. |
| 1264 | @ Cloning is a bandwidth- and CPU-efficient alternative to extracting |
| 1265 | @ multiple tarballs and ZIPs. |
| 1266 | @ Do a web search for "fossil clone" or similar to find additional |
| 1267 | @ information about using a cloned Fossil repository. Or ask your |
| 1268 | @ favorite AI how to extract content from a Fossil clone. |
| 1269 | fossil_free(zNm); |
| 1270 | } |
| 1271 | |
| 1272 | style_finish_page(); |
| 1273 | } |
| 1274 | |
| 1275 |