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]

drh 2010-12-11 00:28 trunk
Commit 35aa6f81884aabca18225fa0e3279ed6aa28f3d7
1 file changed +27 -4
+27 -4
--- src/import.c
+++ src/import.c
@@ -283,10 +283,33 @@
283283
}else{
284284
*pzIn = &z[i];
285285
}
286286
return z;
287287
}
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
+}
288311
289312
/*
290313
** Convert a "mark" or "committish" into the UUID.
291314
*/
292315
static char *resolve_committish(const char *zCommittish){
@@ -476,11 +499,11 @@
476499
if( memcmp(zLine, "M ", 2)==0 ){
477500
import_prior_files();
478501
z = &zLine[2];
479502
zPerm = next_token(&z);
480503
zUuid = next_token(&z);
481
- zName = next_token(&z);
504
+ zName = rest_of_line(&z);
482505
i = 0;
483506
pFile = import_find_file(zName, &i, gg.nFile);
484507
if( pFile==0 ){
485508
pFile = import_add_file();
486509
pFile->zName = import_strdup(zName);
@@ -491,11 +514,11 @@
491514
pFile->isFrom = 0;
492515
}else
493516
if( memcmp(zLine, "D ", 2)==0 ){
494517
import_prior_files();
495518
z = &zLine[2];
496
- zName = next_token(&z);
519
+ zName = rest_of_line(&z);
497520
i = 0;
498521
while( (pFile = import_find_file(zName, &i, gg.nFile))!=0 ){
499522
if( pFile->isFrom==0 ) continue;
500523
fossil_free(pFile->zName);
501524
fossil_free(pFile->zPrior);
@@ -507,11 +530,11 @@
507530
if( memcmp(zLine, "C ", 2)==0 ){
508531
int nFrom;
509532
import_prior_files();
510533
z = &zLine[2];
511534
zFrom = next_token(&z);
512
- zTo = next_token(&z);
535
+ zTo = rest_of_line(&z);
513536
i = 0;
514537
mx = gg.nFile;
515538
nFrom = strlen(zFrom);
516539
while( (pFile = import_find_file(zFrom, &i, mx))!=0 ){
517540
if( pFile->isFrom==0 ) continue;
@@ -530,11 +553,11 @@
530553
if( memcmp(zLine, "R ", 2)==0 ){
531554
int nFrom;
532555
import_prior_files();
533556
z = &zLine[2];
534557
zFrom = next_token(&z);
535
- zTo = next_token(&z);
558
+ zTo = rest_of_line(&z);
536559
i = 0;
537560
nFrom = strlen(zFrom);
538561
while( (pFile = import_find_file(zFrom, &i, gg.nFile))!=0 ){
539562
if( pFile->isFrom==0 ) continue;
540563
pNew = import_add_file();
541564
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button