Fossil SCM

Add the --branch option to the "diff" command, for showing all changes in a particular branch.

drh 2012-07-14 04:59 UTC root-tag
Commit f06e492ad81edd1c16aac670c7650c0830065ee0
1 file changed +10
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -481,10 +481,11 @@
481481
**
482482
** The "-N" or "--new-file" option causes the complete text of added or
483483
** deleted files to be displayed.
484484
**
485485
** Options:
486
+** --branch BRANCH Show diff of all changes on BRANCH
486487
** --brief Show filenames only
487488
** --context|-c N Use N lines of context
488489
** --from|-r VERSION select VERSION as source for the diff
489490
** -i use internal diff logic
490491
** --new-file|-N output complete text of added or deleted files
@@ -496,22 +497,31 @@
496497
int isGDiff; /* True for gdiff. False for normal diff */
497498
int isInternDiff; /* True for internal diff */
498499
int hasNFlag; /* True if -N or --new-file flag is used */
499500
const char *zFrom; /* Source version number */
500501
const char *zTo; /* Target version number */
502
+ const char *zBranch; /* Branch to diff */
501503
const char *zDiffCmd = 0; /* External diff command. NULL for internal diff */
502504
int diffFlags = 0; /* Flags to control the DIFF */
503505
int f;
504506
505507
isGDiff = g.argv[1][0]=='g';
506508
isInternDiff = find_option("internal","i",0)!=0;
507509
zFrom = find_option("from", "r", 1);
508510
zTo = find_option("to", 0, 1);
511
+ zBranch = find_option("branch", 0, 1);
509512
diffFlags = diff_options();
510513
hasNFlag = find_option("new-file","N",0)!=0;
511514
if( hasNFlag ) diffFlags |= DIFF_NEWFILE;
512515
516
+ if( zBranch ){
517
+ if( zTo || zFrom ){
518
+ fossil_fatal("cannot use --from or --to with --branch");
519
+ }
520
+ zTo = mprintf("tag:%s", zBranch);
521
+ zFrom = mprintf("root:%s", zBranch);
522
+ }
513523
if( zTo==0 ){
514524
db_must_be_within_tree();
515525
verify_all_options();
516526
if( !isInternDiff ){
517527
zDiffCmd = db_get(isGDiff ? "gdiff-command" : "diff-command", 0);
518528
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -481,10 +481,11 @@
481 **
482 ** The "-N" or "--new-file" option causes the complete text of added or
483 ** deleted files to be displayed.
484 **
485 ** Options:
 
486 ** --brief Show filenames only
487 ** --context|-c N Use N lines of context
488 ** --from|-r VERSION select VERSION as source for the diff
489 ** -i use internal diff logic
490 ** --new-file|-N output complete text of added or deleted files
@@ -496,22 +497,31 @@
496 int isGDiff; /* True for gdiff. False for normal diff */
497 int isInternDiff; /* True for internal diff */
498 int hasNFlag; /* True if -N or --new-file flag is used */
499 const char *zFrom; /* Source version number */
500 const char *zTo; /* Target version number */
 
501 const char *zDiffCmd = 0; /* External diff command. NULL for internal diff */
502 int diffFlags = 0; /* Flags to control the DIFF */
503 int f;
504
505 isGDiff = g.argv[1][0]=='g';
506 isInternDiff = find_option("internal","i",0)!=0;
507 zFrom = find_option("from", "r", 1);
508 zTo = find_option("to", 0, 1);
 
509 diffFlags = diff_options();
510 hasNFlag = find_option("new-file","N",0)!=0;
511 if( hasNFlag ) diffFlags |= DIFF_NEWFILE;
512
 
 
 
 
 
 
 
513 if( zTo==0 ){
514 db_must_be_within_tree();
515 verify_all_options();
516 if( !isInternDiff ){
517 zDiffCmd = db_get(isGDiff ? "gdiff-command" : "diff-command", 0);
518
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -481,10 +481,11 @@
481 **
482 ** The "-N" or "--new-file" option causes the complete text of added or
483 ** deleted files to be displayed.
484 **
485 ** Options:
486 ** --branch BRANCH Show diff of all changes on BRANCH
487 ** --brief Show filenames only
488 ** --context|-c N Use N lines of context
489 ** --from|-r VERSION select VERSION as source for the diff
490 ** -i use internal diff logic
491 ** --new-file|-N output complete text of added or deleted files
@@ -496,22 +497,31 @@
497 int isGDiff; /* True for gdiff. False for normal diff */
498 int isInternDiff; /* True for internal diff */
499 int hasNFlag; /* True if -N or --new-file flag is used */
500 const char *zFrom; /* Source version number */
501 const char *zTo; /* Target version number */
502 const char *zBranch; /* Branch to diff */
503 const char *zDiffCmd = 0; /* External diff command. NULL for internal diff */
504 int diffFlags = 0; /* Flags to control the DIFF */
505 int f;
506
507 isGDiff = g.argv[1][0]=='g';
508 isInternDiff = find_option("internal","i",0)!=0;
509 zFrom = find_option("from", "r", 1);
510 zTo = find_option("to", 0, 1);
511 zBranch = find_option("branch", 0, 1);
512 diffFlags = diff_options();
513 hasNFlag = find_option("new-file","N",0)!=0;
514 if( hasNFlag ) diffFlags |= DIFF_NEWFILE;
515
516 if( zBranch ){
517 if( zTo || zFrom ){
518 fossil_fatal("cannot use --from or --to with --branch");
519 }
520 zTo = mprintf("tag:%s", zBranch);
521 zFrom = mprintf("root:%s", zBranch);
522 }
523 if( zTo==0 ){
524 db_must_be_within_tree();
525 verify_all_options();
526 if( !isInternDiff ){
527 zDiffCmd = db_get(isGDiff ? "gdiff-command" : "diff-command", 0);
528

Keyboard Shortcuts

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