Fossil SCM
Use clearer method of differentiating between the status and changes commands
Commit
4d33d95899d709a398c2b5af1b1c269c953ff619
Parent
d1214f37977aff3…
1 file changed
+8
-8
+8
-8
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -428,22 +428,22 @@ | ||
| 428 | 428 | }, noFlagDefs[] = { |
| 429 | 429 | {"no-merge", C_MERGE }, {"no-classify", C_CLASSIFY }, |
| 430 | 430 | }; |
| 431 | 431 | |
| 432 | 432 | Blob report = BLOB_INITIALIZER; |
| 433 | - int changes = g.argv[1][0]=='c'; | |
| 433 | + enum {CHANGES, STATUS} command = *g.argv[1]=='s' ? STATUS : CHANGES; | |
| 434 | 434 | int useSha1sum = find_option("sha1sum", 0, 0)!=0; |
| 435 | - int showHdr = changes && find_option("header", 0, 0); | |
| 436 | - int verboseFlag = changes && find_option("verbose", "v", 0); | |
| 435 | + int showHdr = command==CHANGES && find_option("header", 0, 0); | |
| 436 | + int verboseFlag = command==CHANGES && find_option("verbose", "v", 0); | |
| 437 | 437 | const char *zIgnoreFlag = find_option("ignore", 0, 1); |
| 438 | 438 | unsigned scanFlags = 0; |
| 439 | 439 | unsigned flags = 0; |
| 440 | 440 | int vid, i; |
| 441 | 441 | |
| 442 | 442 | /* Load affirmative flag options. */ |
| 443 | 443 | for( i=0; i<count(flagDefs); ++i ){ |
| 444 | - if( (changes || !(flagDefs[i].mask & C_CLASSIFY)) | |
| 444 | + if( (command==CHANGES || !(flagDefs[i].mask & C_CLASSIFY)) | |
| 445 | 445 | && find_option(flagDefs[i].option, 0, 0) ){ |
| 446 | 446 | flags |= flagDefs[i].mask; |
| 447 | 447 | } |
| 448 | 448 | } |
| 449 | 449 | |
| @@ -456,17 +456,17 @@ | ||
| 456 | 456 | * Having one filter means flags masked by C_FILTER is a power of two. If a |
| 457 | 457 | * number masked by one less than itself is zero, it's either zero or a power |
| 458 | 458 | * of two. It's already known to not be zero because of the above defaults. |
| 459 | 459 | * Unlike --all, --changed is a single filter, i.e. it sets only one bit. |
| 460 | 460 | * Also force classification for the status command. */ |
| 461 | - if( !changes || (flags & (flags-1) & C_FILTER) ){ | |
| 461 | + if( command==STATUS || (flags & (flags-1) & C_FILTER) ){ | |
| 462 | 462 | flags |= C_CLASSIFY; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | /* Negative flag options override defaults applied above. */ |
| 466 | 466 | for( i=0; i<count(noFlagDefs); ++i ){ |
| 467 | - if( (changes || !(noFlagDefs[i].mask & C_CLASSIFY)) | |
| 467 | + if( (command==CHANGES || !(noFlagDefs[i].mask & C_CLASSIFY)) | |
| 468 | 468 | && find_option(noFlagDefs[i].option, 0, 0) ){ |
| 469 | 469 | flags &= ~noFlagDefs[i].mask; |
| 470 | 470 | } |
| 471 | 471 | } |
| 472 | 472 | |
| @@ -503,11 +503,11 @@ | ||
| 503 | 503 | locate_unmanaged_files(g.argc-2, g.argv+2, scanFlags, pIgnore); |
| 504 | 504 | glob_free(pIgnore); |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | /* The status command prints general information before the change list. */ |
| 508 | - if( !changes ){ | |
| 508 | + if( command==STATUS ){ | |
| 509 | 509 | fossil_print("repository: %s\n", db_repository_filename()); |
| 510 | 510 | fossil_print("local-root: %s\n", g.zLocalRoot); |
| 511 | 511 | if( g.zConfigDbName ){ |
| 512 | 512 | fossil_print("config-db: %s\n", g.zConfigDbName); |
| 513 | 513 | } |
| @@ -530,11 +530,11 @@ | ||
| 530 | 530 | fossil_print(" (none)\n"); |
| 531 | 531 | } |
| 532 | 532 | blob_reset(&report); |
| 533 | 533 | |
| 534 | 534 | /* The status command ends with warnings about ambiguous leaves (forks). */ |
| 535 | - if( !changes ){ | |
| 535 | + if( command==STATUS ){ | |
| 536 | 536 | leaf_ambiguity_warning(vid, vid); |
| 537 | 537 | } |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | /* |
| 541 | 541 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -428,22 +428,22 @@ | |
| 428 | }, noFlagDefs[] = { |
| 429 | {"no-merge", C_MERGE }, {"no-classify", C_CLASSIFY }, |
| 430 | }; |
| 431 | |
| 432 | Blob report = BLOB_INITIALIZER; |
| 433 | int changes = g.argv[1][0]=='c'; |
| 434 | int useSha1sum = find_option("sha1sum", 0, 0)!=0; |
| 435 | int showHdr = changes && find_option("header", 0, 0); |
| 436 | int verboseFlag = changes && find_option("verbose", "v", 0); |
| 437 | const char *zIgnoreFlag = find_option("ignore", 0, 1); |
| 438 | unsigned scanFlags = 0; |
| 439 | unsigned flags = 0; |
| 440 | int vid, i; |
| 441 | |
| 442 | /* Load affirmative flag options. */ |
| 443 | for( i=0; i<count(flagDefs); ++i ){ |
| 444 | if( (changes || !(flagDefs[i].mask & C_CLASSIFY)) |
| 445 | && find_option(flagDefs[i].option, 0, 0) ){ |
| 446 | flags |= flagDefs[i].mask; |
| 447 | } |
| 448 | } |
| 449 | |
| @@ -456,17 +456,17 @@ | |
| 456 | * Having one filter means flags masked by C_FILTER is a power of two. If a |
| 457 | * number masked by one less than itself is zero, it's either zero or a power |
| 458 | * of two. It's already known to not be zero because of the above defaults. |
| 459 | * Unlike --all, --changed is a single filter, i.e. it sets only one bit. |
| 460 | * Also force classification for the status command. */ |
| 461 | if( !changes || (flags & (flags-1) & C_FILTER) ){ |
| 462 | flags |= C_CLASSIFY; |
| 463 | } |
| 464 | |
| 465 | /* Negative flag options override defaults applied above. */ |
| 466 | for( i=0; i<count(noFlagDefs); ++i ){ |
| 467 | if( (changes || !(noFlagDefs[i].mask & C_CLASSIFY)) |
| 468 | && find_option(noFlagDefs[i].option, 0, 0) ){ |
| 469 | flags &= ~noFlagDefs[i].mask; |
| 470 | } |
| 471 | } |
| 472 | |
| @@ -503,11 +503,11 @@ | |
| 503 | locate_unmanaged_files(g.argc-2, g.argv+2, scanFlags, pIgnore); |
| 504 | glob_free(pIgnore); |
| 505 | } |
| 506 | |
| 507 | /* The status command prints general information before the change list. */ |
| 508 | if( !changes ){ |
| 509 | fossil_print("repository: %s\n", db_repository_filename()); |
| 510 | fossil_print("local-root: %s\n", g.zLocalRoot); |
| 511 | if( g.zConfigDbName ){ |
| 512 | fossil_print("config-db: %s\n", g.zConfigDbName); |
| 513 | } |
| @@ -530,11 +530,11 @@ | |
| 530 | fossil_print(" (none)\n"); |
| 531 | } |
| 532 | blob_reset(&report); |
| 533 | |
| 534 | /* The status command ends with warnings about ambiguous leaves (forks). */ |
| 535 | if( !changes ){ |
| 536 | leaf_ambiguity_warning(vid, vid); |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | /* |
| 541 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -428,22 +428,22 @@ | |
| 428 | }, noFlagDefs[] = { |
| 429 | {"no-merge", C_MERGE }, {"no-classify", C_CLASSIFY }, |
| 430 | }; |
| 431 | |
| 432 | Blob report = BLOB_INITIALIZER; |
| 433 | enum {CHANGES, STATUS} command = *g.argv[1]=='s' ? STATUS : CHANGES; |
| 434 | int useSha1sum = find_option("sha1sum", 0, 0)!=0; |
| 435 | int showHdr = command==CHANGES && find_option("header", 0, 0); |
| 436 | int verboseFlag = command==CHANGES && find_option("verbose", "v", 0); |
| 437 | const char *zIgnoreFlag = find_option("ignore", 0, 1); |
| 438 | unsigned scanFlags = 0; |
| 439 | unsigned flags = 0; |
| 440 | int vid, i; |
| 441 | |
| 442 | /* Load affirmative flag options. */ |
| 443 | for( i=0; i<count(flagDefs); ++i ){ |
| 444 | if( (command==CHANGES || !(flagDefs[i].mask & C_CLASSIFY)) |
| 445 | && find_option(flagDefs[i].option, 0, 0) ){ |
| 446 | flags |= flagDefs[i].mask; |
| 447 | } |
| 448 | } |
| 449 | |
| @@ -456,17 +456,17 @@ | |
| 456 | * Having one filter means flags masked by C_FILTER is a power of two. If a |
| 457 | * number masked by one less than itself is zero, it's either zero or a power |
| 458 | * of two. It's already known to not be zero because of the above defaults. |
| 459 | * Unlike --all, --changed is a single filter, i.e. it sets only one bit. |
| 460 | * Also force classification for the status command. */ |
| 461 | if( command==STATUS || (flags & (flags-1) & C_FILTER) ){ |
| 462 | flags |= C_CLASSIFY; |
| 463 | } |
| 464 | |
| 465 | /* Negative flag options override defaults applied above. */ |
| 466 | for( i=0; i<count(noFlagDefs); ++i ){ |
| 467 | if( (command==CHANGES || !(noFlagDefs[i].mask & C_CLASSIFY)) |
| 468 | && find_option(noFlagDefs[i].option, 0, 0) ){ |
| 469 | flags &= ~noFlagDefs[i].mask; |
| 470 | } |
| 471 | } |
| 472 | |
| @@ -503,11 +503,11 @@ | |
| 503 | locate_unmanaged_files(g.argc-2, g.argv+2, scanFlags, pIgnore); |
| 504 | glob_free(pIgnore); |
| 505 | } |
| 506 | |
| 507 | /* The status command prints general information before the change list. */ |
| 508 | if( command==STATUS ){ |
| 509 | fossil_print("repository: %s\n", db_repository_filename()); |
| 510 | fossil_print("local-root: %s\n", g.zLocalRoot); |
| 511 | if( g.zConfigDbName ){ |
| 512 | fossil_print("config-db: %s\n", g.zConfigDbName); |
| 513 | } |
| @@ -530,11 +530,11 @@ | |
| 530 | fossil_print(" (none)\n"); |
| 531 | } |
| 532 | blob_reset(&report); |
| 533 | |
| 534 | /* The status command ends with warnings about ambiguous leaves (forks). */ |
| 535 | if( command==STATUS ){ |
| 536 | leaf_ambiguity_warning(vid, vid); |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | /* |
| 541 |