Fossil SCM
Coding style tweaks.
Commit
32e418f85687d54d9cf3b2ee9fee534b38901ef2
Parent
98f4ee8f71b67ad…
2 files changed
+21
-21
+1
-1
+21
-21
| --- src/export.c | ||
| +++ src/export.c | ||
| @@ -133,21 +133,21 @@ | ||
| 133 | 133 | /* |
| 134 | 134 | ** create_mark() |
| 135 | 135 | ** Create a new (mark,rid,uuid) entry for the given rid in the 'xmark' table, |
| 136 | 136 | ** and return that information as a struct mark_t in *mark. |
| 137 | 137 | ** *unused_mark is a value representing a mark that is free for use--that is, |
| 138 | -** it does not appear in the marks file, and has not been used during this | |
| 139 | -** export run. Specifically, it is the supremum of the set of used marks | |
| 140 | -** plus one. | |
| 138 | +** it does not appear in the marks file, and has not been used during this | |
| 139 | +** export run. Specifically, it is the supremum of the set of used marks | |
| 140 | +** plus one. | |
| 141 | 141 | ** This function returns -1 in the case where 'rid' does not exist, otherwise |
| 142 | 142 | ** it returns 0. |
| 143 | 143 | ** mark->name is dynamically allocated and is owned by the caller upon return. |
| 144 | 144 | */ |
| 145 | 145 | int create_mark(int rid, struct mark_t *mark, unsigned int *unused_mark){ |
| 146 | 146 | char sid[13]; |
| 147 | 147 | char *zUuid = rid_to_uuid(rid); |
| 148 | - if(!zUuid){ | |
| 148 | + if( !zUuid ){ | |
| 149 | 149 | fossil_trace("Undefined rid=%d\n", rid); |
| 150 | 150 | return -1; |
| 151 | 151 | } |
| 152 | 152 | mark->rid = rid; |
| 153 | 153 | sqlite3_snprintf(sizeof(sid), sid, ":%d", *unused_mark); |
| @@ -170,13 +170,13 @@ | ||
| 170 | 170 | ** (i.e. is not valid). Otherwise, it returns the name of the mark, which is |
| 171 | 171 | ** dynamically allocated and is owned by the caller of this function. |
| 172 | 172 | */ |
| 173 | 173 | char * mark_name_from_rid(int rid, unsigned int *unused_mark){ |
| 174 | 174 | char *zMark = db_text(0, "SELECT tname FROM xmark WHERE trid=%d", rid); |
| 175 | - if(zMark==NULL){ | |
| 175 | + if( zMark==NULL ){ | |
| 176 | 176 | struct mark_t mark; |
| 177 | - if(create_mark(rid, &mark, unused_mark)==0){ | |
| 177 | + if( create_mark(rid, &mark, unused_mark)==0 ){ | |
| 178 | 178 | zMark = mark.name; |
| 179 | 179 | }else{ |
| 180 | 180 | return NULL; |
| 181 | 181 | } |
| 182 | 182 | } |
| @@ -195,23 +195,23 @@ | ||
| 195 | 195 | */ |
| 196 | 196 | int parse_mark(char *line, struct mark_t *mark){ |
| 197 | 197 | char *cur_tok; |
| 198 | 198 | char type_; |
| 199 | 199 | cur_tok = strtok(line, " \t"); |
| 200 | - if(!cur_tok||strlen(cur_tok)<2){ | |
| 200 | + if( !cur_tok || strlen(cur_tok)<2 ){ | |
| 201 | 201 | return -1; |
| 202 | 202 | } |
| 203 | 203 | mark->rid = atoi(&cur_tok[1]); |
| 204 | 204 | type_ = cur_tok[0]; |
| 205 | - if(type_!='c'&&type_!='b'){ | |
| 205 | + if( type_!='c' && type_!='b' ){ | |
| 206 | 206 | /* This is probably a blob mark */ |
| 207 | 207 | mark->name = NULL; |
| 208 | 208 | return 0; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | cur_tok = strtok(NULL, " \t"); |
| 212 | - if(!cur_tok){ | |
| 212 | + if( !cur_tok ){ | |
| 213 | 213 | /* This mark was generated by an older version of Fossil and doesn't |
| 214 | 214 | ** include the mark name and uuid. create_mark() will name the new mark |
| 215 | 215 | ** exactly as it was when exported to git, so that we should have a |
| 216 | 216 | ** valid mapping from git sha1<->mark name<->fossil sha1. */ |
| 217 | 217 | unsigned int mid; |
| @@ -225,20 +225,20 @@ | ||
| 225 | 225 | }else{ |
| 226 | 226 | mark->name = fossil_strdup(cur_tok); |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | cur_tok = strtok(NULL, "\n"); |
| 230 | - if(!cur_tok||strlen(cur_tok)!=40){ | |
| 230 | + if( !cur_tok || strlen(cur_tok)!=40 ){ | |
| 231 | 231 | free(mark->name); |
| 232 | 232 | fossil_trace("Invalid SHA-1 in marks file: %s\n", cur_tok); |
| 233 | 233 | return -1; |
| 234 | 234 | }else{ |
| 235 | 235 | sqlite3_snprintf(sizeof(mark->uuid), mark->uuid, "%s", cur_tok); |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | /* make sure that rid corresponds to UUID */ |
| 239 | - if(fast_uuid_to_rid(mark->uuid)!=mark->rid){ | |
| 239 | + if( fast_uuid_to_rid(mark->uuid)!=mark->rid ){ | |
| 240 | 240 | free(mark->name); |
| 241 | 241 | fossil_trace("Non-existent SHA-1 in marks file: %s\n", mark->uuid); |
| 242 | 242 | return -1; |
| 243 | 243 | } |
| 244 | 244 | |
| @@ -264,18 +264,18 @@ | ||
| 264 | 264 | */ |
| 265 | 265 | int import_marks(FILE* f, Bag *blobs, Bag *vers, unsigned int *unused_mark){ |
| 266 | 266 | char line[101]; |
| 267 | 267 | while(fgets(line, sizeof(line), f)){ |
| 268 | 268 | struct mark_t mark; |
| 269 | - if(strlen(line)==100&&line[99]!='\n'){ | |
| 269 | + if( strlen(line)==100 && line[99]!='\n' ){ | |
| 270 | 270 | /* line too long */ |
| 271 | 271 | return -1; |
| 272 | 272 | } |
| 273 | 273 | if( parse_mark(line, &mark)<0 ){ |
| 274 | 274 | return -1; |
| 275 | 275 | }else if( line[0]=='b' ){ |
| 276 | - if(blobs!=NULL){ | |
| 276 | + if( blobs!=NULL ){ | |
| 277 | 277 | bag_insert(blobs, mark.rid); |
| 278 | 278 | } |
| 279 | 279 | }else{ |
| 280 | 280 | if( vers!=NULL ){ |
| 281 | 281 | bag_insert(vers, mark.rid); |
| @@ -295,11 +295,11 @@ | ||
| 295 | 295 | void export_mark(FILE* f, int rid, char obj_type) |
| 296 | 296 | { |
| 297 | 297 | unsigned int z = 0; |
| 298 | 298 | char *zUuid = rid_to_uuid(rid); |
| 299 | 299 | char *zMark; |
| 300 | - if(zUuid==NULL){ | |
| 300 | + if( zUuid==NULL ){ | |
| 301 | 301 | fossil_trace("No uuid matching rid=%d when exporting marks\n", rid); |
| 302 | 302 | return; |
| 303 | 303 | } |
| 304 | 304 | /* Since rid is already in the 'xmark' table, the value of z won't be |
| 305 | 305 | ** used, but pass in a valid pointer just to be safe. */ |
| @@ -319,11 +319,11 @@ | ||
| 319 | 319 | ** be found for an rid in 'vers'. |
| 320 | 320 | */ |
| 321 | 321 | void export_marks(FILE* f, Bag *blobs, Bag *vers){ |
| 322 | 322 | int rid; |
| 323 | 323 | |
| 324 | - if( blobs!=NULL ) { | |
| 324 | + if( blobs!=NULL ){ | |
| 325 | 325 | rid = bag_first(blobs); |
| 326 | 326 | if( rid!=0 ){ |
| 327 | 327 | do{ |
| 328 | 328 | export_mark(f, rid, 'b'); |
| 329 | 329 | }while( (rid = bag_next(blobs, rid))!=0 ); |
| @@ -398,25 +398,25 @@ | ||
| 398 | 398 | |
| 399 | 399 | f = fossil_fopen(markfile_in, "r"); |
| 400 | 400 | if( f==0 ){ |
| 401 | 401 | fossil_fatal("cannot open %s for reading", markfile_in); |
| 402 | 402 | } |
| 403 | - if(import_marks(f, &blobs, &vers, &unused_mark)<0){ | |
| 403 | + if( import_marks(f, &blobs, &vers, &unused_mark)<0 ){ | |
| 404 | 404 | fossil_fatal("error importing marks from file: %s\n", markfile_in); |
| 405 | 405 | } |
| 406 | 406 | db_prepare(&qb, "INSERT OR IGNORE INTO oldblob VALUES (:rid)"); |
| 407 | 407 | db_prepare(&qc, "INSERT OR IGNORE INTO oldcommit VALUES (:rid)"); |
| 408 | 408 | rid = bag_first(&blobs); |
| 409 | - if(rid!=0){ | |
| 409 | + if( rid!=0 ){ | |
| 410 | 410 | do{ |
| 411 | 411 | db_bind_int(&qb, ":rid", rid); |
| 412 | 412 | db_step(&qb); |
| 413 | 413 | db_reset(&qb); |
| 414 | 414 | }while((rid = bag_next(&blobs, rid))!=0); |
| 415 | 415 | } |
| 416 | 416 | rid = bag_first(&vers); |
| 417 | - if(rid!=0){ | |
| 417 | + if( rid!=0 ){ | |
| 418 | 418 | do{ |
| 419 | 419 | db_bind_int(&qc, ":rid", rid); |
| 420 | 420 | db_step(&qc); |
| 421 | 421 | db_reset(&qc); |
| 422 | 422 | }while((rid = bag_next(&vers, rid))!=0); |
| @@ -555,13 +555,13 @@ | ||
| 555 | 555 | ); |
| 556 | 556 | while( db_step(&q4)==SQLITE_ROW ){ |
| 557 | 557 | const char *zName = db_column_text(&q4,0); |
| 558 | 558 | int zNew = db_column_int(&q4,1); |
| 559 | 559 | int mPerm = db_column_int(&q4,2); |
| 560 | - if( zNew==0) | |
| 560 | + if( zNew==0 ){ | |
| 561 | 561 | printf("D %s\n", zName); |
| 562 | - else if( bag_find(&blobs, zNew) ) { | |
| 562 | + }else if( bag_find(&blobs, zNew) ){ | |
| 563 | 563 | zMark = mark_name_from_rid(zNew, &unused_mark); |
| 564 | 564 | const char *zPerm; |
| 565 | 565 | switch( mPerm ){ |
| 566 | 566 | case PERM_LNK: zPerm = "120000"; break; |
| 567 | 567 | case PERM_EXE: zPerm = "100755"; break; |
| @@ -611,12 +611,12 @@ | ||
| 611 | 611 | f = fossil_fopen(markfile_out, "w"); |
| 612 | 612 | if( f == 0 ){ |
| 613 | 613 | fossil_fatal("cannot open %s for writing", markfile_out); |
| 614 | 614 | } |
| 615 | 615 | export_marks(f, &blobs, &vers); |
| 616 | - if( ferror(f)!=0 || fclose(f)!=0 ) { | |
| 616 | + if( ferror(f)!=0 || fclose(f)!=0 ){ | |
| 617 | 617 | fossil_fatal("error while writing %s", markfile_out); |
| 618 | 618 | } |
| 619 | 619 | } |
| 620 | 620 | bag_clear(&blobs); |
| 621 | 621 | bag_clear(&vers); |
| 622 | 622 | } |
| 623 | 623 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -133,21 +133,21 @@ | |
| 133 | /* |
| 134 | ** create_mark() |
| 135 | ** Create a new (mark,rid,uuid) entry for the given rid in the 'xmark' table, |
| 136 | ** and return that information as a struct mark_t in *mark. |
| 137 | ** *unused_mark is a value representing a mark that is free for use--that is, |
| 138 | ** it does not appear in the marks file, and has not been used during this |
| 139 | ** export run. Specifically, it is the supremum of the set of used marks |
| 140 | ** plus one. |
| 141 | ** This function returns -1 in the case where 'rid' does not exist, otherwise |
| 142 | ** it returns 0. |
| 143 | ** mark->name is dynamically allocated and is owned by the caller upon return. |
| 144 | */ |
| 145 | int create_mark(int rid, struct mark_t *mark, unsigned int *unused_mark){ |
| 146 | char sid[13]; |
| 147 | char *zUuid = rid_to_uuid(rid); |
| 148 | if(!zUuid){ |
| 149 | fossil_trace("Undefined rid=%d\n", rid); |
| 150 | return -1; |
| 151 | } |
| 152 | mark->rid = rid; |
| 153 | sqlite3_snprintf(sizeof(sid), sid, ":%d", *unused_mark); |
| @@ -170,13 +170,13 @@ | |
| 170 | ** (i.e. is not valid). Otherwise, it returns the name of the mark, which is |
| 171 | ** dynamically allocated and is owned by the caller of this function. |
| 172 | */ |
| 173 | char * mark_name_from_rid(int rid, unsigned int *unused_mark){ |
| 174 | char *zMark = db_text(0, "SELECT tname FROM xmark WHERE trid=%d", rid); |
| 175 | if(zMark==NULL){ |
| 176 | struct mark_t mark; |
| 177 | if(create_mark(rid, &mark, unused_mark)==0){ |
| 178 | zMark = mark.name; |
| 179 | }else{ |
| 180 | return NULL; |
| 181 | } |
| 182 | } |
| @@ -195,23 +195,23 @@ | |
| 195 | */ |
| 196 | int parse_mark(char *line, struct mark_t *mark){ |
| 197 | char *cur_tok; |
| 198 | char type_; |
| 199 | cur_tok = strtok(line, " \t"); |
| 200 | if(!cur_tok||strlen(cur_tok)<2){ |
| 201 | return -1; |
| 202 | } |
| 203 | mark->rid = atoi(&cur_tok[1]); |
| 204 | type_ = cur_tok[0]; |
| 205 | if(type_!='c'&&type_!='b'){ |
| 206 | /* This is probably a blob mark */ |
| 207 | mark->name = NULL; |
| 208 | return 0; |
| 209 | } |
| 210 | |
| 211 | cur_tok = strtok(NULL, " \t"); |
| 212 | if(!cur_tok){ |
| 213 | /* This mark was generated by an older version of Fossil and doesn't |
| 214 | ** include the mark name and uuid. create_mark() will name the new mark |
| 215 | ** exactly as it was when exported to git, so that we should have a |
| 216 | ** valid mapping from git sha1<->mark name<->fossil sha1. */ |
| 217 | unsigned int mid; |
| @@ -225,20 +225,20 @@ | |
| 225 | }else{ |
| 226 | mark->name = fossil_strdup(cur_tok); |
| 227 | } |
| 228 | |
| 229 | cur_tok = strtok(NULL, "\n"); |
| 230 | if(!cur_tok||strlen(cur_tok)!=40){ |
| 231 | free(mark->name); |
| 232 | fossil_trace("Invalid SHA-1 in marks file: %s\n", cur_tok); |
| 233 | return -1; |
| 234 | }else{ |
| 235 | sqlite3_snprintf(sizeof(mark->uuid), mark->uuid, "%s", cur_tok); |
| 236 | } |
| 237 | |
| 238 | /* make sure that rid corresponds to UUID */ |
| 239 | if(fast_uuid_to_rid(mark->uuid)!=mark->rid){ |
| 240 | free(mark->name); |
| 241 | fossil_trace("Non-existent SHA-1 in marks file: %s\n", mark->uuid); |
| 242 | return -1; |
| 243 | } |
| 244 | |
| @@ -264,18 +264,18 @@ | |
| 264 | */ |
| 265 | int import_marks(FILE* f, Bag *blobs, Bag *vers, unsigned int *unused_mark){ |
| 266 | char line[101]; |
| 267 | while(fgets(line, sizeof(line), f)){ |
| 268 | struct mark_t mark; |
| 269 | if(strlen(line)==100&&line[99]!='\n'){ |
| 270 | /* line too long */ |
| 271 | return -1; |
| 272 | } |
| 273 | if( parse_mark(line, &mark)<0 ){ |
| 274 | return -1; |
| 275 | }else if( line[0]=='b' ){ |
| 276 | if(blobs!=NULL){ |
| 277 | bag_insert(blobs, mark.rid); |
| 278 | } |
| 279 | }else{ |
| 280 | if( vers!=NULL ){ |
| 281 | bag_insert(vers, mark.rid); |
| @@ -295,11 +295,11 @@ | |
| 295 | void export_mark(FILE* f, int rid, char obj_type) |
| 296 | { |
| 297 | unsigned int z = 0; |
| 298 | char *zUuid = rid_to_uuid(rid); |
| 299 | char *zMark; |
| 300 | if(zUuid==NULL){ |
| 301 | fossil_trace("No uuid matching rid=%d when exporting marks\n", rid); |
| 302 | return; |
| 303 | } |
| 304 | /* Since rid is already in the 'xmark' table, the value of z won't be |
| 305 | ** used, but pass in a valid pointer just to be safe. */ |
| @@ -319,11 +319,11 @@ | |
| 319 | ** be found for an rid in 'vers'. |
| 320 | */ |
| 321 | void export_marks(FILE* f, Bag *blobs, Bag *vers){ |
| 322 | int rid; |
| 323 | |
| 324 | if( blobs!=NULL ) { |
| 325 | rid = bag_first(blobs); |
| 326 | if( rid!=0 ){ |
| 327 | do{ |
| 328 | export_mark(f, rid, 'b'); |
| 329 | }while( (rid = bag_next(blobs, rid))!=0 ); |
| @@ -398,25 +398,25 @@ | |
| 398 | |
| 399 | f = fossil_fopen(markfile_in, "r"); |
| 400 | if( f==0 ){ |
| 401 | fossil_fatal("cannot open %s for reading", markfile_in); |
| 402 | } |
| 403 | if(import_marks(f, &blobs, &vers, &unused_mark)<0){ |
| 404 | fossil_fatal("error importing marks from file: %s\n", markfile_in); |
| 405 | } |
| 406 | db_prepare(&qb, "INSERT OR IGNORE INTO oldblob VALUES (:rid)"); |
| 407 | db_prepare(&qc, "INSERT OR IGNORE INTO oldcommit VALUES (:rid)"); |
| 408 | rid = bag_first(&blobs); |
| 409 | if(rid!=0){ |
| 410 | do{ |
| 411 | db_bind_int(&qb, ":rid", rid); |
| 412 | db_step(&qb); |
| 413 | db_reset(&qb); |
| 414 | }while((rid = bag_next(&blobs, rid))!=0); |
| 415 | } |
| 416 | rid = bag_first(&vers); |
| 417 | if(rid!=0){ |
| 418 | do{ |
| 419 | db_bind_int(&qc, ":rid", rid); |
| 420 | db_step(&qc); |
| 421 | db_reset(&qc); |
| 422 | }while((rid = bag_next(&vers, rid))!=0); |
| @@ -555,13 +555,13 @@ | |
| 555 | ); |
| 556 | while( db_step(&q4)==SQLITE_ROW ){ |
| 557 | const char *zName = db_column_text(&q4,0); |
| 558 | int zNew = db_column_int(&q4,1); |
| 559 | int mPerm = db_column_int(&q4,2); |
| 560 | if( zNew==0) |
| 561 | printf("D %s\n", zName); |
| 562 | else if( bag_find(&blobs, zNew) ) { |
| 563 | zMark = mark_name_from_rid(zNew, &unused_mark); |
| 564 | const char *zPerm; |
| 565 | switch( mPerm ){ |
| 566 | case PERM_LNK: zPerm = "120000"; break; |
| 567 | case PERM_EXE: zPerm = "100755"; break; |
| @@ -611,12 +611,12 @@ | |
| 611 | f = fossil_fopen(markfile_out, "w"); |
| 612 | if( f == 0 ){ |
| 613 | fossil_fatal("cannot open %s for writing", markfile_out); |
| 614 | } |
| 615 | export_marks(f, &blobs, &vers); |
| 616 | if( ferror(f)!=0 || fclose(f)!=0 ) { |
| 617 | fossil_fatal("error while writing %s", markfile_out); |
| 618 | } |
| 619 | } |
| 620 | bag_clear(&blobs); |
| 621 | bag_clear(&vers); |
| 622 | } |
| 623 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -133,21 +133,21 @@ | |
| 133 | /* |
| 134 | ** create_mark() |
| 135 | ** Create a new (mark,rid,uuid) entry for the given rid in the 'xmark' table, |
| 136 | ** and return that information as a struct mark_t in *mark. |
| 137 | ** *unused_mark is a value representing a mark that is free for use--that is, |
| 138 | ** it does not appear in the marks file, and has not been used during this |
| 139 | ** export run. Specifically, it is the supremum of the set of used marks |
| 140 | ** plus one. |
| 141 | ** This function returns -1 in the case where 'rid' does not exist, otherwise |
| 142 | ** it returns 0. |
| 143 | ** mark->name is dynamically allocated and is owned by the caller upon return. |
| 144 | */ |
| 145 | int create_mark(int rid, struct mark_t *mark, unsigned int *unused_mark){ |
| 146 | char sid[13]; |
| 147 | char *zUuid = rid_to_uuid(rid); |
| 148 | if( !zUuid ){ |
| 149 | fossil_trace("Undefined rid=%d\n", rid); |
| 150 | return -1; |
| 151 | } |
| 152 | mark->rid = rid; |
| 153 | sqlite3_snprintf(sizeof(sid), sid, ":%d", *unused_mark); |
| @@ -170,13 +170,13 @@ | |
| 170 | ** (i.e. is not valid). Otherwise, it returns the name of the mark, which is |
| 171 | ** dynamically allocated and is owned by the caller of this function. |
| 172 | */ |
| 173 | char * mark_name_from_rid(int rid, unsigned int *unused_mark){ |
| 174 | char *zMark = db_text(0, "SELECT tname FROM xmark WHERE trid=%d", rid); |
| 175 | if( zMark==NULL ){ |
| 176 | struct mark_t mark; |
| 177 | if( create_mark(rid, &mark, unused_mark)==0 ){ |
| 178 | zMark = mark.name; |
| 179 | }else{ |
| 180 | return NULL; |
| 181 | } |
| 182 | } |
| @@ -195,23 +195,23 @@ | |
| 195 | */ |
| 196 | int parse_mark(char *line, struct mark_t *mark){ |
| 197 | char *cur_tok; |
| 198 | char type_; |
| 199 | cur_tok = strtok(line, " \t"); |
| 200 | if( !cur_tok || strlen(cur_tok)<2 ){ |
| 201 | return -1; |
| 202 | } |
| 203 | mark->rid = atoi(&cur_tok[1]); |
| 204 | type_ = cur_tok[0]; |
| 205 | if( type_!='c' && type_!='b' ){ |
| 206 | /* This is probably a blob mark */ |
| 207 | mark->name = NULL; |
| 208 | return 0; |
| 209 | } |
| 210 | |
| 211 | cur_tok = strtok(NULL, " \t"); |
| 212 | if( !cur_tok ){ |
| 213 | /* This mark was generated by an older version of Fossil and doesn't |
| 214 | ** include the mark name and uuid. create_mark() will name the new mark |
| 215 | ** exactly as it was when exported to git, so that we should have a |
| 216 | ** valid mapping from git sha1<->mark name<->fossil sha1. */ |
| 217 | unsigned int mid; |
| @@ -225,20 +225,20 @@ | |
| 225 | }else{ |
| 226 | mark->name = fossil_strdup(cur_tok); |
| 227 | } |
| 228 | |
| 229 | cur_tok = strtok(NULL, "\n"); |
| 230 | if( !cur_tok || strlen(cur_tok)!=40 ){ |
| 231 | free(mark->name); |
| 232 | fossil_trace("Invalid SHA-1 in marks file: %s\n", cur_tok); |
| 233 | return -1; |
| 234 | }else{ |
| 235 | sqlite3_snprintf(sizeof(mark->uuid), mark->uuid, "%s", cur_tok); |
| 236 | } |
| 237 | |
| 238 | /* make sure that rid corresponds to UUID */ |
| 239 | if( fast_uuid_to_rid(mark->uuid)!=mark->rid ){ |
| 240 | free(mark->name); |
| 241 | fossil_trace("Non-existent SHA-1 in marks file: %s\n", mark->uuid); |
| 242 | return -1; |
| 243 | } |
| 244 | |
| @@ -264,18 +264,18 @@ | |
| 264 | */ |
| 265 | int import_marks(FILE* f, Bag *blobs, Bag *vers, unsigned int *unused_mark){ |
| 266 | char line[101]; |
| 267 | while(fgets(line, sizeof(line), f)){ |
| 268 | struct mark_t mark; |
| 269 | if( strlen(line)==100 && line[99]!='\n' ){ |
| 270 | /* line too long */ |
| 271 | return -1; |
| 272 | } |
| 273 | if( parse_mark(line, &mark)<0 ){ |
| 274 | return -1; |
| 275 | }else if( line[0]=='b' ){ |
| 276 | if( blobs!=NULL ){ |
| 277 | bag_insert(blobs, mark.rid); |
| 278 | } |
| 279 | }else{ |
| 280 | if( vers!=NULL ){ |
| 281 | bag_insert(vers, mark.rid); |
| @@ -295,11 +295,11 @@ | |
| 295 | void export_mark(FILE* f, int rid, char obj_type) |
| 296 | { |
| 297 | unsigned int z = 0; |
| 298 | char *zUuid = rid_to_uuid(rid); |
| 299 | char *zMark; |
| 300 | if( zUuid==NULL ){ |
| 301 | fossil_trace("No uuid matching rid=%d when exporting marks\n", rid); |
| 302 | return; |
| 303 | } |
| 304 | /* Since rid is already in the 'xmark' table, the value of z won't be |
| 305 | ** used, but pass in a valid pointer just to be safe. */ |
| @@ -319,11 +319,11 @@ | |
| 319 | ** be found for an rid in 'vers'. |
| 320 | */ |
| 321 | void export_marks(FILE* f, Bag *blobs, Bag *vers){ |
| 322 | int rid; |
| 323 | |
| 324 | if( blobs!=NULL ){ |
| 325 | rid = bag_first(blobs); |
| 326 | if( rid!=0 ){ |
| 327 | do{ |
| 328 | export_mark(f, rid, 'b'); |
| 329 | }while( (rid = bag_next(blobs, rid))!=0 ); |
| @@ -398,25 +398,25 @@ | |
| 398 | |
| 399 | f = fossil_fopen(markfile_in, "r"); |
| 400 | if( f==0 ){ |
| 401 | fossil_fatal("cannot open %s for reading", markfile_in); |
| 402 | } |
| 403 | if( import_marks(f, &blobs, &vers, &unused_mark)<0 ){ |
| 404 | fossil_fatal("error importing marks from file: %s\n", markfile_in); |
| 405 | } |
| 406 | db_prepare(&qb, "INSERT OR IGNORE INTO oldblob VALUES (:rid)"); |
| 407 | db_prepare(&qc, "INSERT OR IGNORE INTO oldcommit VALUES (:rid)"); |
| 408 | rid = bag_first(&blobs); |
| 409 | if( rid!=0 ){ |
| 410 | do{ |
| 411 | db_bind_int(&qb, ":rid", rid); |
| 412 | db_step(&qb); |
| 413 | db_reset(&qb); |
| 414 | }while((rid = bag_next(&blobs, rid))!=0); |
| 415 | } |
| 416 | rid = bag_first(&vers); |
| 417 | if( rid!=0 ){ |
| 418 | do{ |
| 419 | db_bind_int(&qc, ":rid", rid); |
| 420 | db_step(&qc); |
| 421 | db_reset(&qc); |
| 422 | }while((rid = bag_next(&vers, rid))!=0); |
| @@ -555,13 +555,13 @@ | |
| 555 | ); |
| 556 | while( db_step(&q4)==SQLITE_ROW ){ |
| 557 | const char *zName = db_column_text(&q4,0); |
| 558 | int zNew = db_column_int(&q4,1); |
| 559 | int mPerm = db_column_int(&q4,2); |
| 560 | if( zNew==0 ){ |
| 561 | printf("D %s\n", zName); |
| 562 | }else if( bag_find(&blobs, zNew) ){ |
| 563 | zMark = mark_name_from_rid(zNew, &unused_mark); |
| 564 | const char *zPerm; |
| 565 | switch( mPerm ){ |
| 566 | case PERM_LNK: zPerm = "120000"; break; |
| 567 | case PERM_EXE: zPerm = "100755"; break; |
| @@ -611,12 +611,12 @@ | |
| 611 | f = fossil_fopen(markfile_out, "w"); |
| 612 | if( f == 0 ){ |
| 613 | fossil_fatal("cannot open %s for writing", markfile_out); |
| 614 | } |
| 615 | export_marks(f, &blobs, &vers); |
| 616 | if( ferror(f)!=0 || fclose(f)!=0 ){ |
| 617 | fossil_fatal("error while writing %s", markfile_out); |
| 618 | } |
| 619 | } |
| 620 | bag_clear(&blobs); |
| 621 | bag_clear(&vers); |
| 622 | } |
| 623 |
+1
-1
| --- src/import.c | ||
| +++ src/import.c | ||
| @@ -1770,11 +1770,11 @@ | ||
| 1770 | 1770 | if( markfile_in ){ |
| 1771 | 1771 | FILE *f = fossil_fopen(markfile_in, "r"); |
| 1772 | 1772 | if( !f ){ |
| 1773 | 1773 | fossil_fatal("cannot open %s for reading\n", markfile_in); |
| 1774 | 1774 | } |
| 1775 | - if(import_marks(f, &blobs, NULL, NULL)<0){ | |
| 1775 | + if( import_marks(f, &blobs, NULL, NULL)<0 ){ | |
| 1776 | 1776 | fossil_fatal("error importing marks from file: %s\n", markfile_in); |
| 1777 | 1777 | } |
| 1778 | 1778 | fclose(f); |
| 1779 | 1779 | } |
| 1780 | 1780 | |
| 1781 | 1781 |
| --- src/import.c | |
| +++ src/import.c | |
| @@ -1770,11 +1770,11 @@ | |
| 1770 | if( markfile_in ){ |
| 1771 | FILE *f = fossil_fopen(markfile_in, "r"); |
| 1772 | if( !f ){ |
| 1773 | fossil_fatal("cannot open %s for reading\n", markfile_in); |
| 1774 | } |
| 1775 | if(import_marks(f, &blobs, NULL, NULL)<0){ |
| 1776 | fossil_fatal("error importing marks from file: %s\n", markfile_in); |
| 1777 | } |
| 1778 | fclose(f); |
| 1779 | } |
| 1780 | |
| 1781 |
| --- src/import.c | |
| +++ src/import.c | |
| @@ -1770,11 +1770,11 @@ | |
| 1770 | if( markfile_in ){ |
| 1771 | FILE *f = fossil_fopen(markfile_in, "r"); |
| 1772 | if( !f ){ |
| 1773 | fossil_fatal("cannot open %s for reading\n", markfile_in); |
| 1774 | } |
| 1775 | if( import_marks(f, &blobs, NULL, NULL)<0 ){ |
| 1776 | fossil_fatal("error importing marks from file: %s\n", markfile_in); |
| 1777 | } |
| 1778 | fclose(f); |
| 1779 | } |
| 1780 | |
| 1781 |