Fossil SCM
Update the git fast-export importer so that it is able to handle filenames with spaces - or at least to the extent that the fast-export format is able to deal with such filename. Ticket [4ee4aa5a30733a]
Commit
35aa6f81884aabca18225fa0e3279ed6aa28f3d7
Parent
56d69dbd8580833…
1 file changed
+27
-4
+27
-4
| --- src/import.c | ||
| +++ src/import.c | ||
| @@ -283,10 +283,33 @@ | ||
| 283 | 283 | }else{ |
| 284 | 284 | *pzIn = &z[i]; |
| 285 | 285 | } |
| 286 | 286 | return z; |
| 287 | 287 | } |
| 288 | + | |
| 289 | +/* | |
| 290 | +** Return a token that is all text up to (but omitting) the next \n | |
| 291 | +** or \r\n. | |
| 292 | +*/ | |
| 293 | +static char *rest_of_line(char **pzIn){ | |
| 294 | + char *z = *pzIn; | |
| 295 | + int i; | |
| 296 | + if( z[0]==0 ) return z; | |
| 297 | + for(i=0; z[i] && z[i]!='\r' && z[i]!='\n'; i++){} | |
| 298 | + if( z[i] ){ | |
| 299 | + if( z[i]=='\r' && z[i+1]=='\n' ){ | |
| 300 | + z[i] = 0; | |
| 301 | + i++; | |
| 302 | + }else{ | |
| 303 | + z[i] = 0; | |
| 304 | + } | |
| 305 | + *pzIn = &z[i+1]; | |
| 306 | + }else{ | |
| 307 | + *pzIn = &z[i]; | |
| 308 | + } | |
| 309 | + return z; | |
| 310 | +} | |
| 288 | 311 | |
| 289 | 312 | /* |
| 290 | 313 | ** Convert a "mark" or "committish" into the UUID. |
| 291 | 314 | */ |
| 292 | 315 | static char *resolve_committish(const char *zCommittish){ |
| @@ -476,11 +499,11 @@ | ||
| 476 | 499 | if( memcmp(zLine, "M ", 2)==0 ){ |
| 477 | 500 | import_prior_files(); |
| 478 | 501 | z = &zLine[2]; |
| 479 | 502 | zPerm = next_token(&z); |
| 480 | 503 | zUuid = next_token(&z); |
| 481 | - zName = next_token(&z); | |
| 504 | + zName = rest_of_line(&z); | |
| 482 | 505 | i = 0; |
| 483 | 506 | pFile = import_find_file(zName, &i, gg.nFile); |
| 484 | 507 | if( pFile==0 ){ |
| 485 | 508 | pFile = import_add_file(); |
| 486 | 509 | pFile->zName = import_strdup(zName); |
| @@ -491,11 +514,11 @@ | ||
| 491 | 514 | pFile->isFrom = 0; |
| 492 | 515 | }else |
| 493 | 516 | if( memcmp(zLine, "D ", 2)==0 ){ |
| 494 | 517 | import_prior_files(); |
| 495 | 518 | z = &zLine[2]; |
| 496 | - zName = next_token(&z); | |
| 519 | + zName = rest_of_line(&z); | |
| 497 | 520 | i = 0; |
| 498 | 521 | while( (pFile = import_find_file(zName, &i, gg.nFile))!=0 ){ |
| 499 | 522 | if( pFile->isFrom==0 ) continue; |
| 500 | 523 | fossil_free(pFile->zName); |
| 501 | 524 | fossil_free(pFile->zPrior); |
| @@ -507,11 +530,11 @@ | ||
| 507 | 530 | if( memcmp(zLine, "C ", 2)==0 ){ |
| 508 | 531 | int nFrom; |
| 509 | 532 | import_prior_files(); |
| 510 | 533 | z = &zLine[2]; |
| 511 | 534 | zFrom = next_token(&z); |
| 512 | - zTo = next_token(&z); | |
| 535 | + zTo = rest_of_line(&z); | |
| 513 | 536 | i = 0; |
| 514 | 537 | mx = gg.nFile; |
| 515 | 538 | nFrom = strlen(zFrom); |
| 516 | 539 | while( (pFile = import_find_file(zFrom, &i, mx))!=0 ){ |
| 517 | 540 | if( pFile->isFrom==0 ) continue; |
| @@ -530,11 +553,11 @@ | ||
| 530 | 553 | if( memcmp(zLine, "R ", 2)==0 ){ |
| 531 | 554 | int nFrom; |
| 532 | 555 | import_prior_files(); |
| 533 | 556 | z = &zLine[2]; |
| 534 | 557 | zFrom = next_token(&z); |
| 535 | - zTo = next_token(&z); | |
| 558 | + zTo = rest_of_line(&z); | |
| 536 | 559 | i = 0; |
| 537 | 560 | nFrom = strlen(zFrom); |
| 538 | 561 | while( (pFile = import_find_file(zFrom, &i, gg.nFile))!=0 ){ |
| 539 | 562 | if( pFile->isFrom==0 ) continue; |
| 540 | 563 | pNew = import_add_file(); |
| 541 | 564 |
| --- src/import.c | |
| +++ src/import.c | |
| @@ -283,10 +283,33 @@ | |
| 283 | }else{ |
| 284 | *pzIn = &z[i]; |
| 285 | } |
| 286 | return z; |
| 287 | } |
| 288 | |
| 289 | /* |
| 290 | ** Convert a "mark" or "committish" into the UUID. |
| 291 | */ |
| 292 | static char *resolve_committish(const char *zCommittish){ |
| @@ -476,11 +499,11 @@ | |
| 476 | if( memcmp(zLine, "M ", 2)==0 ){ |
| 477 | import_prior_files(); |
| 478 | z = &zLine[2]; |
| 479 | zPerm = next_token(&z); |
| 480 | zUuid = next_token(&z); |
| 481 | zName = next_token(&z); |
| 482 | i = 0; |
| 483 | pFile = import_find_file(zName, &i, gg.nFile); |
| 484 | if( pFile==0 ){ |
| 485 | pFile = import_add_file(); |
| 486 | pFile->zName = import_strdup(zName); |
| @@ -491,11 +514,11 @@ | |
| 491 | pFile->isFrom = 0; |
| 492 | }else |
| 493 | if( memcmp(zLine, "D ", 2)==0 ){ |
| 494 | import_prior_files(); |
| 495 | z = &zLine[2]; |
| 496 | zName = next_token(&z); |
| 497 | i = 0; |
| 498 | while( (pFile = import_find_file(zName, &i, gg.nFile))!=0 ){ |
| 499 | if( pFile->isFrom==0 ) continue; |
| 500 | fossil_free(pFile->zName); |
| 501 | fossil_free(pFile->zPrior); |
| @@ -507,11 +530,11 @@ | |
| 507 | if( memcmp(zLine, "C ", 2)==0 ){ |
| 508 | int nFrom; |
| 509 | import_prior_files(); |
| 510 | z = &zLine[2]; |
| 511 | zFrom = next_token(&z); |
| 512 | zTo = next_token(&z); |
| 513 | i = 0; |
| 514 | mx = gg.nFile; |
| 515 | nFrom = strlen(zFrom); |
| 516 | while( (pFile = import_find_file(zFrom, &i, mx))!=0 ){ |
| 517 | if( pFile->isFrom==0 ) continue; |
| @@ -530,11 +553,11 @@ | |
| 530 | if( memcmp(zLine, "R ", 2)==0 ){ |
| 531 | int nFrom; |
| 532 | import_prior_files(); |
| 533 | z = &zLine[2]; |
| 534 | zFrom = next_token(&z); |
| 535 | zTo = next_token(&z); |
| 536 | i = 0; |
| 537 | nFrom = strlen(zFrom); |
| 538 | while( (pFile = import_find_file(zFrom, &i, gg.nFile))!=0 ){ |
| 539 | if( pFile->isFrom==0 ) continue; |
| 540 | pNew = import_add_file(); |
| 541 |
| --- src/import.c | |
| +++ src/import.c | |
| @@ -283,10 +283,33 @@ | |
| 283 | }else{ |
| 284 | *pzIn = &z[i]; |
| 285 | } |
| 286 | return z; |
| 287 | } |
| 288 | |
| 289 | /* |
| 290 | ** Return a token that is all text up to (but omitting) the next \n |
| 291 | ** or \r\n. |
| 292 | */ |
| 293 | static char *rest_of_line(char **pzIn){ |
| 294 | char *z = *pzIn; |
| 295 | int i; |
| 296 | if( z[0]==0 ) return z; |
| 297 | for(i=0; z[i] && z[i]!='\r' && z[i]!='\n'; i++){} |
| 298 | if( z[i] ){ |
| 299 | if( z[i]=='\r' && z[i+1]=='\n' ){ |
| 300 | z[i] = 0; |
| 301 | i++; |
| 302 | }else{ |
| 303 | z[i] = 0; |
| 304 | } |
| 305 | *pzIn = &z[i+1]; |
| 306 | }else{ |
| 307 | *pzIn = &z[i]; |
| 308 | } |
| 309 | return z; |
| 310 | } |
| 311 | |
| 312 | /* |
| 313 | ** Convert a "mark" or "committish" into the UUID. |
| 314 | */ |
| 315 | static char *resolve_committish(const char *zCommittish){ |
| @@ -476,11 +499,11 @@ | |
| 499 | if( memcmp(zLine, "M ", 2)==0 ){ |
| 500 | import_prior_files(); |
| 501 | z = &zLine[2]; |
| 502 | zPerm = next_token(&z); |
| 503 | zUuid = next_token(&z); |
| 504 | zName = rest_of_line(&z); |
| 505 | i = 0; |
| 506 | pFile = import_find_file(zName, &i, gg.nFile); |
| 507 | if( pFile==0 ){ |
| 508 | pFile = import_add_file(); |
| 509 | pFile->zName = import_strdup(zName); |
| @@ -491,11 +514,11 @@ | |
| 514 | pFile->isFrom = 0; |
| 515 | }else |
| 516 | if( memcmp(zLine, "D ", 2)==0 ){ |
| 517 | import_prior_files(); |
| 518 | z = &zLine[2]; |
| 519 | zName = rest_of_line(&z); |
| 520 | i = 0; |
| 521 | while( (pFile = import_find_file(zName, &i, gg.nFile))!=0 ){ |
| 522 | if( pFile->isFrom==0 ) continue; |
| 523 | fossil_free(pFile->zName); |
| 524 | fossil_free(pFile->zPrior); |
| @@ -507,11 +530,11 @@ | |
| 530 | if( memcmp(zLine, "C ", 2)==0 ){ |
| 531 | int nFrom; |
| 532 | import_prior_files(); |
| 533 | z = &zLine[2]; |
| 534 | zFrom = next_token(&z); |
| 535 | zTo = rest_of_line(&z); |
| 536 | i = 0; |
| 537 | mx = gg.nFile; |
| 538 | nFrom = strlen(zFrom); |
| 539 | while( (pFile = import_find_file(zFrom, &i, mx))!=0 ){ |
| 540 | if( pFile->isFrom==0 ) continue; |
| @@ -530,11 +553,11 @@ | |
| 553 | if( memcmp(zLine, "R ", 2)==0 ){ |
| 554 | int nFrom; |
| 555 | import_prior_files(); |
| 556 | z = &zLine[2]; |
| 557 | zFrom = next_token(&z); |
| 558 | zTo = rest_of_line(&z); |
| 559 | i = 0; |
| 560 | nFrom = strlen(zFrom); |
| 561 | while( (pFile = import_find_file(zFrom, &i, gg.nFile))!=0 ){ |
| 562 | if( pFile->isFrom==0 ) continue; |
| 563 | pNew = import_add_file(); |
| 564 |