| | @@ -171,33 +171,30 @@ |
| 171 | 171 | |
| 172 | 172 | if( g.argc < 3 ){ |
| 173 | 173 | usage("?OPTIONS? FILE-OR-URL ?NEW-REPOSITORY?"); |
| 174 | 174 | } |
| 175 | 175 | db_open_config(0, 0); |
| 176 | | - zRepo = g.argc==4 ? g.argv[3] : 0; |
| 177 | | - if( zRepo!=0 && -1 != file_size(zRepo, ExtFILE) ){ |
| 178 | | - fossil_fatal("file already exists: %s", zRepo); |
| 179 | | - } |
| 180 | | - url_parse(g.argv[2], urlFlags); |
| 181 | | - if( zRepo==0 ){ |
| 182 | | - int i; |
| 183 | | - const char *z = file_tail(g.url.isFile ? g.url.name : g.url.path); |
| 184 | | - if( z==0 || z[0]==0 ){ |
| 176 | + if( g.argc==4 ){ |
| 177 | + zRepo = g.argv[3]; |
| 178 | + }else{ |
| 179 | + char *zBase = url_to_repo_basename(g.argv[2]); |
| 180 | + if( zBase==0 ){ |
| 185 | 181 | fossil_fatal( |
| 186 | 182 | "unable to guess a repository name from the url \"%s\".\n" |
| 187 | 183 | "give the repository filename as an additional argument.", |
| 188 | 184 | g.argv[2]); |
| 189 | 185 | } |
| 190 | | - for(i=0; z[i] && z[i]!='.'; i++){} |
| 186 | + zRepo = mprintf("./%s.fossil", zBase); |
| 191 | 187 | if( zWorkDir==0 ){ |
| 192 | | - zWorkDir = mprintf("./%.*s", i, z); |
| 188 | + zWorkDir = mprintf("./%s", zBase); |
| 193 | 189 | } |
| 194 | | - zRepo = mprintf("./%.*s.fossil", i, z); |
| 195 | | - if( -1 != file_size(zRepo, ExtFILE) ){ |
| 196 | | - fossil_fatal("file already exists: %s", zRepo); |
| 197 | | - } |
| 190 | + fossil_free(zBase); |
| 191 | + } |
| 192 | + if( -1 != file_size(zRepo, ExtFILE) ){ |
| 193 | + fossil_fatal("file already exists: %s", zRepo); |
| 198 | 194 | } |
| 195 | + url_parse(g.argv[2], urlFlags); |
| 199 | 196 | if( zDefaultUser==0 && g.url.user!=0 ) zDefaultUser = g.url.user; |
| 200 | 197 | if( g.url.isFile ){ |
| 201 | 198 | file_copy(g.url.name, zRepo); |
| 202 | 199 | db_close(1); |
| 203 | 200 | db_open_repository(zRepo); |
| 204 | 201 | |