Fossil SCM
Get the "fossil all ui" command working on windows systems where the global_config table has "repo:" entries that omit the drive letter.
Commit
25758c7b1c8319a91a520e9afe3849e0cee18ca8
Parent
239b4c1362c76db…
1 file changed
+18
-19
+18
-19
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -1201,35 +1201,29 @@ | ||
| 1201 | 1201 | ** return 0. |
| 1202 | 1202 | */ |
| 1203 | 1203 | static int repo_list_page(void){ |
| 1204 | 1204 | Blob base; |
| 1205 | 1205 | int n = 0; |
| 1206 | + int allRepo; | |
| 1206 | 1207 | |
| 1207 | 1208 | assert( g.db==0 ); |
| 1208 | 1209 | if( fossil_strcmp(g.zRepositoryName,"/")==0 && !g.fJail ){ |
| 1209 | 1210 | /* For the special case of the "repository directory" being "/", |
| 1210 | 1211 | ** show all of the repositories named in the ~/.fossil database. |
| 1211 | 1212 | ** |
| 1212 | 1213 | ** On unix systems, then entries are of the form "repo:/home/..." |
| 1213 | - ** and on Windows systems they are like "repo:C:/Users/...". We want | |
| 1214 | - ** to skip the first 6 characters on unix and the first 5 characters | |
| 1215 | - ** on Windows. | |
| 1216 | - */ | |
| 1217 | - db_open_config(1, 0); | |
| 1218 | -#ifdef _WIN32 | |
| 1219 | - db_multi_exec( | |
| 1220 | - "CREATE TEMP VIEW sfile AS" | |
| 1221 | - " SELECT substr(name,6) AS 'pathname' FROM global_config" | |
| 1222 | - " WHERE name GLOB 'repo:*'" | |
| 1223 | - ); | |
| 1224 | -#else | |
| 1225 | - db_multi_exec( | |
| 1226 | - "CREATE TEMP VIEW sfile AS" | |
| 1227 | - " SELECT substr(name,7) AS 'pathname' FROM global_config" | |
| 1228 | - " WHERE name GLOB 'repo:*'" | |
| 1229 | - ); | |
| 1230 | -#endif | |
| 1214 | + ** and on Windows systems they are like on unix, starting with a "/" | |
| 1215 | + ** or they can begin with a drive letter: "repo:C:/Users/...". In either | |
| 1216 | + ** case, we want returned path to omit any initial "/". | |
| 1217 | + */ | |
| 1218 | + db_open_config(1, 0); | |
| 1219 | + db_multi_exec( | |
| 1220 | + "CREATE TEMP VIEW sfile AS" | |
| 1221 | + " SELECT ltrim(substr(name,6),'/') AS 'pathname' FROM global_config" | |
| 1222 | + " WHERE name GLOB 'repo:*'" | |
| 1223 | + ); | |
| 1224 | + allRepo = 1; | |
| 1231 | 1225 | }else{ |
| 1232 | 1226 | /* The default case: All repositories under the g.zRepositoryName |
| 1233 | 1227 | ** directory. |
| 1234 | 1228 | */ |
| 1235 | 1229 | blob_init(&base, g.zRepositoryName, -1); |
| @@ -1236,10 +1230,11 @@ | ||
| 1236 | 1230 | sqlite3_open(":memory:", &g.db); |
| 1237 | 1231 | db_multi_exec("CREATE TABLE sfile(pathname TEXT);"); |
| 1238 | 1232 | db_multi_exec("CREATE TABLE vfile(pathname);"); |
| 1239 | 1233 | vfile_scan(&base, blob_size(&base), 0, 0, 0); |
| 1240 | 1234 | db_multi_exec("DELETE FROM sfile WHERE pathname NOT GLOB '*[^/].fossil'"); |
| 1235 | + allRepo = 0; | |
| 1241 | 1236 | } |
| 1242 | 1237 | @ <html> |
| 1243 | 1238 | @ <head> |
| 1244 | 1239 | @ <base href="%s(g.zBaseURL)/" /> |
| 1245 | 1240 | @ <title>Repository List</title> |
| @@ -1253,11 +1248,15 @@ | ||
| 1253 | 1248 | db_prepare(&q, "SELECT pathname, substr(pathname,-7,-100000)||'/home'" |
| 1254 | 1249 | " FROM sfile ORDER BY pathname COLLATE nocase;"); |
| 1255 | 1250 | while( db_step(&q)==SQLITE_ROW ){ |
| 1256 | 1251 | const char *zName = db_column_text(&q, 0); |
| 1257 | 1252 | const char *zUrl = db_column_text(&q, 1); |
| 1258 | - @ <li><a href="%R/%T(zUrl)" target="_blank">%h(zName)</a></li> | |
| 1253 | + if( allRepo && sqlite3_strglob("[a-zA-Z]:/?*", zName)!=0 ){ | |
| 1254 | + @ <li><a href="%R/%T(zUrl)" target="_blank">/%h(zName)</a></li> | |
| 1255 | + }else{ | |
| 1256 | + @ <li><a href="%R/%T(zUrl)" target="_blank">%h(zName)</a></li> | |
| 1257 | + } | |
| 1259 | 1258 | } |
| 1260 | 1259 | @ </ol> |
| 1261 | 1260 | }else{ |
| 1262 | 1261 | @ <h1>No Repositories Found</h1> |
| 1263 | 1262 | } |
| 1264 | 1263 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -1201,35 +1201,29 @@ | |
| 1201 | ** return 0. |
| 1202 | */ |
| 1203 | static int repo_list_page(void){ |
| 1204 | Blob base; |
| 1205 | int n = 0; |
| 1206 | |
| 1207 | assert( g.db==0 ); |
| 1208 | if( fossil_strcmp(g.zRepositoryName,"/")==0 && !g.fJail ){ |
| 1209 | /* For the special case of the "repository directory" being "/", |
| 1210 | ** show all of the repositories named in the ~/.fossil database. |
| 1211 | ** |
| 1212 | ** On unix systems, then entries are of the form "repo:/home/..." |
| 1213 | ** and on Windows systems they are like "repo:C:/Users/...". We want |
| 1214 | ** to skip the first 6 characters on unix and the first 5 characters |
| 1215 | ** on Windows. |
| 1216 | */ |
| 1217 | db_open_config(1, 0); |
| 1218 | #ifdef _WIN32 |
| 1219 | db_multi_exec( |
| 1220 | "CREATE TEMP VIEW sfile AS" |
| 1221 | " SELECT substr(name,6) AS 'pathname' FROM global_config" |
| 1222 | " WHERE name GLOB 'repo:*'" |
| 1223 | ); |
| 1224 | #else |
| 1225 | db_multi_exec( |
| 1226 | "CREATE TEMP VIEW sfile AS" |
| 1227 | " SELECT substr(name,7) AS 'pathname' FROM global_config" |
| 1228 | " WHERE name GLOB 'repo:*'" |
| 1229 | ); |
| 1230 | #endif |
| 1231 | }else{ |
| 1232 | /* The default case: All repositories under the g.zRepositoryName |
| 1233 | ** directory. |
| 1234 | */ |
| 1235 | blob_init(&base, g.zRepositoryName, -1); |
| @@ -1236,10 +1230,11 @@ | |
| 1236 | sqlite3_open(":memory:", &g.db); |
| 1237 | db_multi_exec("CREATE TABLE sfile(pathname TEXT);"); |
| 1238 | db_multi_exec("CREATE TABLE vfile(pathname);"); |
| 1239 | vfile_scan(&base, blob_size(&base), 0, 0, 0); |
| 1240 | db_multi_exec("DELETE FROM sfile WHERE pathname NOT GLOB '*[^/].fossil'"); |
| 1241 | } |
| 1242 | @ <html> |
| 1243 | @ <head> |
| 1244 | @ <base href="%s(g.zBaseURL)/" /> |
| 1245 | @ <title>Repository List</title> |
| @@ -1253,11 +1248,15 @@ | |
| 1253 | db_prepare(&q, "SELECT pathname, substr(pathname,-7,-100000)||'/home'" |
| 1254 | " FROM sfile ORDER BY pathname COLLATE nocase;"); |
| 1255 | while( db_step(&q)==SQLITE_ROW ){ |
| 1256 | const char *zName = db_column_text(&q, 0); |
| 1257 | const char *zUrl = db_column_text(&q, 1); |
| 1258 | @ <li><a href="%R/%T(zUrl)" target="_blank">%h(zName)</a></li> |
| 1259 | } |
| 1260 | @ </ol> |
| 1261 | }else{ |
| 1262 | @ <h1>No Repositories Found</h1> |
| 1263 | } |
| 1264 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -1201,35 +1201,29 @@ | |
| 1201 | ** return 0. |
| 1202 | */ |
| 1203 | static int repo_list_page(void){ |
| 1204 | Blob base; |
| 1205 | int n = 0; |
| 1206 | int allRepo; |
| 1207 | |
| 1208 | assert( g.db==0 ); |
| 1209 | if( fossil_strcmp(g.zRepositoryName,"/")==0 && !g.fJail ){ |
| 1210 | /* For the special case of the "repository directory" being "/", |
| 1211 | ** show all of the repositories named in the ~/.fossil database. |
| 1212 | ** |
| 1213 | ** On unix systems, then entries are of the form "repo:/home/..." |
| 1214 | ** and on Windows systems they are like on unix, starting with a "/" |
| 1215 | ** or they can begin with a drive letter: "repo:C:/Users/...". In either |
| 1216 | ** case, we want returned path to omit any initial "/". |
| 1217 | */ |
| 1218 | db_open_config(1, 0); |
| 1219 | db_multi_exec( |
| 1220 | "CREATE TEMP VIEW sfile AS" |
| 1221 | " SELECT ltrim(substr(name,6),'/') AS 'pathname' FROM global_config" |
| 1222 | " WHERE name GLOB 'repo:*'" |
| 1223 | ); |
| 1224 | allRepo = 1; |
| 1225 | }else{ |
| 1226 | /* The default case: All repositories under the g.zRepositoryName |
| 1227 | ** directory. |
| 1228 | */ |
| 1229 | blob_init(&base, g.zRepositoryName, -1); |
| @@ -1236,10 +1230,11 @@ | |
| 1230 | sqlite3_open(":memory:", &g.db); |
| 1231 | db_multi_exec("CREATE TABLE sfile(pathname TEXT);"); |
| 1232 | db_multi_exec("CREATE TABLE vfile(pathname);"); |
| 1233 | vfile_scan(&base, blob_size(&base), 0, 0, 0); |
| 1234 | db_multi_exec("DELETE FROM sfile WHERE pathname NOT GLOB '*[^/].fossil'"); |
| 1235 | allRepo = 0; |
| 1236 | } |
| 1237 | @ <html> |
| 1238 | @ <head> |
| 1239 | @ <base href="%s(g.zBaseURL)/" /> |
| 1240 | @ <title>Repository List</title> |
| @@ -1253,11 +1248,15 @@ | |
| 1248 | db_prepare(&q, "SELECT pathname, substr(pathname,-7,-100000)||'/home'" |
| 1249 | " FROM sfile ORDER BY pathname COLLATE nocase;"); |
| 1250 | while( db_step(&q)==SQLITE_ROW ){ |
| 1251 | const char *zName = db_column_text(&q, 0); |
| 1252 | const char *zUrl = db_column_text(&q, 1); |
| 1253 | if( allRepo && sqlite3_strglob("[a-zA-Z]:/?*", zName)!=0 ){ |
| 1254 | @ <li><a href="%R/%T(zUrl)" target="_blank">/%h(zName)</a></li> |
| 1255 | }else{ |
| 1256 | @ <li><a href="%R/%T(zUrl)" target="_blank">%h(zName)</a></li> |
| 1257 | } |
| 1258 | } |
| 1259 | @ </ol> |
| 1260 | }else{ |
| 1261 | @ <h1>No Repositories Found</h1> |
| 1262 | } |
| 1263 |