Fossil SCM
In directory/repolist mode, do not link to X/Y.fossil if X.fossil exists, to avoid the X/Y/... URI ambiguity. Reported in [forum:f50f647c97c72fc1 | forum post f50f647c97c72fc1].
Commit
9584806cc6a8c005f93dcb4498caa9a08465c5c69d185798feaaddabfe3ade1a
Parent
eeacf82158a9cb3…
1 file changed
+20
+20
| --- src/repolist.c | ||
| +++ src/repolist.c | ||
| @@ -230,10 +230,30 @@ | ||
| 230 | 230 | blob_append_sql(&html, "%h (hidden)", zName); |
| 231 | 231 | } else if( allRepo && sqlite3_strglob("[a-zA-Z]:/?*", zName)!=0 ){ |
| 232 | 232 | blob_append_sql(&html, |
| 233 | 233 | "<a href='%R/%T/home' target='_blank'>/%h</a>\n", |
| 234 | 234 | zUrl, zName); |
| 235 | + }else if( sqlite3_strglob("*/*.fossil", zName)==0 ){ | |
| 236 | + /* As described in | |
| 237 | + ** https://fossil-scm.org/forum/info/f50f647c97c72fc1: if | |
| 238 | + ** foo.fossil and foo/bar.fossil both exist and we create a | |
| 239 | + ** link to foo/bar/... then the URI dispatcher will instead | |
| 240 | + ** see that as a link to foo.fossil. In such cases, do not | |
| 241 | + ** emit a link to foo/bar.fossil. */ | |
| 242 | + char * zDirPart = file_dirname(zName); | |
| 243 | + if( db_exists("SELECT 1 FROM sfile " | |
| 244 | + "WHERE pathname=(%Q || '.fossil') COLLATE nocase", | |
| 245 | + zDirPart) ){ | |
| 246 | + blob_append_sql(&html, | |
| 247 | + "<s>%h</s> (directory/repo name collision)\n", | |
| 248 | + zName); | |
| 249 | + }else{ | |
| 250 | + blob_append_sql(&html, | |
| 251 | + "<a href='%R/%T/home' target='_blank'>%h</a>\n", | |
| 252 | + zUrl, zName); | |
| 253 | + } | |
| 254 | + fossil_free(zDirPart); | |
| 235 | 255 | }else{ |
| 236 | 256 | blob_append_sql(&html, |
| 237 | 257 | "<a href='%R/%T/home' target='_blank'>%h</a>\n", |
| 238 | 258 | zUrl, zName); |
| 239 | 259 | } |
| 240 | 260 |
| --- src/repolist.c | |
| +++ src/repolist.c | |
| @@ -230,10 +230,30 @@ | |
| 230 | blob_append_sql(&html, "%h (hidden)", zName); |
| 231 | } else if( allRepo && sqlite3_strglob("[a-zA-Z]:/?*", zName)!=0 ){ |
| 232 | blob_append_sql(&html, |
| 233 | "<a href='%R/%T/home' target='_blank'>/%h</a>\n", |
| 234 | zUrl, zName); |
| 235 | }else{ |
| 236 | blob_append_sql(&html, |
| 237 | "<a href='%R/%T/home' target='_blank'>%h</a>\n", |
| 238 | zUrl, zName); |
| 239 | } |
| 240 |
| --- src/repolist.c | |
| +++ src/repolist.c | |
| @@ -230,10 +230,30 @@ | |
| 230 | blob_append_sql(&html, "%h (hidden)", zName); |
| 231 | } else if( allRepo && sqlite3_strglob("[a-zA-Z]:/?*", zName)!=0 ){ |
| 232 | blob_append_sql(&html, |
| 233 | "<a href='%R/%T/home' target='_blank'>/%h</a>\n", |
| 234 | zUrl, zName); |
| 235 | }else if( sqlite3_strglob("*/*.fossil", zName)==0 ){ |
| 236 | /* As described in |
| 237 | ** https://fossil-scm.org/forum/info/f50f647c97c72fc1: if |
| 238 | ** foo.fossil and foo/bar.fossil both exist and we create a |
| 239 | ** link to foo/bar/... then the URI dispatcher will instead |
| 240 | ** see that as a link to foo.fossil. In such cases, do not |
| 241 | ** emit a link to foo/bar.fossil. */ |
| 242 | char * zDirPart = file_dirname(zName); |
| 243 | if( db_exists("SELECT 1 FROM sfile " |
| 244 | "WHERE pathname=(%Q || '.fossil') COLLATE nocase", |
| 245 | zDirPart) ){ |
| 246 | blob_append_sql(&html, |
| 247 | "<s>%h</s> (directory/repo name collision)\n", |
| 248 | zName); |
| 249 | }else{ |
| 250 | blob_append_sql(&html, |
| 251 | "<a href='%R/%T/home' target='_blank'>%h</a>\n", |
| 252 | zUrl, zName); |
| 253 | } |
| 254 | fossil_free(zDirPart); |
| 255 | }else{ |
| 256 | blob_append_sql(&html, |
| 257 | "<a href='%R/%T/home' target='_blank'>%h</a>\n", |
| 258 | zUrl, zName); |
| 259 | } |
| 260 |