Fossil SCM

Use clearer method of differentiating between the status and changes commands

andygoth 2016-11-06 05:15 UTC andygoth-changes
Commit 4d33d95899d709a398c2b5af1b1c269c953ff619
1 file changed +8 -8
+8 -8
--- src/checkin.c
+++ src/checkin.c
@@ -428,22 +428,22 @@
428428
}, noFlagDefs[] = {
429429
{"no-merge", C_MERGE }, {"no-classify", C_CLASSIFY },
430430
};
431431
432432
Blob report = BLOB_INITIALIZER;
433
- int changes = g.argv[1][0]=='c';
433
+ enum {CHANGES, STATUS} command = *g.argv[1]=='s' ? STATUS : CHANGES;
434434
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);
437437
const char *zIgnoreFlag = find_option("ignore", 0, 1);
438438
unsigned scanFlags = 0;
439439
unsigned flags = 0;
440440
int vid, i;
441441
442442
/* Load affirmative flag options. */
443443
for( i=0; i<count(flagDefs); ++i ){
444
- if( (changes || !(flagDefs[i].mask & C_CLASSIFY))
444
+ if( (command==CHANGES || !(flagDefs[i].mask & C_CLASSIFY))
445445
&& find_option(flagDefs[i].option, 0, 0) ){
446446
flags |= flagDefs[i].mask;
447447
}
448448
}
449449
@@ -456,17 +456,17 @@
456456
* Having one filter means flags masked by C_FILTER is a power of two. If a
457457
* number masked by one less than itself is zero, it's either zero or a power
458458
* of two. It's already known to not be zero because of the above defaults.
459459
* Unlike --all, --changed is a single filter, i.e. it sets only one bit.
460460
* Also force classification for the status command. */
461
- if( !changes || (flags & (flags-1) & C_FILTER) ){
461
+ if( command==STATUS || (flags & (flags-1) & C_FILTER) ){
462462
flags |= C_CLASSIFY;
463463
}
464464
465465
/* Negative flag options override defaults applied above. */
466466
for( i=0; i<count(noFlagDefs); ++i ){
467
- if( (changes || !(noFlagDefs[i].mask & C_CLASSIFY))
467
+ if( (command==CHANGES || !(noFlagDefs[i].mask & C_CLASSIFY))
468468
&& find_option(noFlagDefs[i].option, 0, 0) ){
469469
flags &= ~noFlagDefs[i].mask;
470470
}
471471
}
472472
@@ -503,11 +503,11 @@
503503
locate_unmanaged_files(g.argc-2, g.argv+2, scanFlags, pIgnore);
504504
glob_free(pIgnore);
505505
}
506506
507507
/* The status command prints general information before the change list. */
508
- if( !changes ){
508
+ if( command==STATUS ){
509509
fossil_print("repository: %s\n", db_repository_filename());
510510
fossil_print("local-root: %s\n", g.zLocalRoot);
511511
if( g.zConfigDbName ){
512512
fossil_print("config-db: %s\n", g.zConfigDbName);
513513
}
@@ -530,11 +530,11 @@
530530
fossil_print(" (none)\n");
531531
}
532532
blob_reset(&report);
533533
534534
/* The status command ends with warnings about ambiguous leaves (forks). */
535
- if( !changes ){
535
+ if( command==STATUS ){
536536
leaf_ambiguity_warning(vid, vid);
537537
}
538538
}
539539
540540
/*
541541
--- 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

Keyboard Shortcuts

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