Fossil SCM
Add the --branch option to the "diff" command, for showing all changes in a particular branch.
Commit
f06e492ad81edd1c16aac670c7650c0830065ee0
Parent
a4e01221c8c4254…
1 file changed
+10
+10
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -481,10 +481,11 @@ | ||
| 481 | 481 | ** |
| 482 | 482 | ** The "-N" or "--new-file" option causes the complete text of added or |
| 483 | 483 | ** deleted files to be displayed. |
| 484 | 484 | ** |
| 485 | 485 | ** Options: |
| 486 | +** --branch BRANCH Show diff of all changes on BRANCH | |
| 486 | 487 | ** --brief Show filenames only |
| 487 | 488 | ** --context|-c N Use N lines of context |
| 488 | 489 | ** --from|-r VERSION select VERSION as source for the diff |
| 489 | 490 | ** -i use internal diff logic |
| 490 | 491 | ** --new-file|-N output complete text of added or deleted files |
| @@ -496,22 +497,31 @@ | ||
| 496 | 497 | int isGDiff; /* True for gdiff. False for normal diff */ |
| 497 | 498 | int isInternDiff; /* True for internal diff */ |
| 498 | 499 | int hasNFlag; /* True if -N or --new-file flag is used */ |
| 499 | 500 | const char *zFrom; /* Source version number */ |
| 500 | 501 | const char *zTo; /* Target version number */ |
| 502 | + const char *zBranch; /* Branch to diff */ | |
| 501 | 503 | const char *zDiffCmd = 0; /* External diff command. NULL for internal diff */ |
| 502 | 504 | int diffFlags = 0; /* Flags to control the DIFF */ |
| 503 | 505 | int f; |
| 504 | 506 | |
| 505 | 507 | isGDiff = g.argv[1][0]=='g'; |
| 506 | 508 | isInternDiff = find_option("internal","i",0)!=0; |
| 507 | 509 | zFrom = find_option("from", "r", 1); |
| 508 | 510 | zTo = find_option("to", 0, 1); |
| 511 | + zBranch = find_option("branch", 0, 1); | |
| 509 | 512 | diffFlags = diff_options(); |
| 510 | 513 | hasNFlag = find_option("new-file","N",0)!=0; |
| 511 | 514 | if( hasNFlag ) diffFlags |= DIFF_NEWFILE; |
| 512 | 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 | + } | |
| 513 | 523 | if( zTo==0 ){ |
| 514 | 524 | db_must_be_within_tree(); |
| 515 | 525 | verify_all_options(); |
| 516 | 526 | if( !isInternDiff ){ |
| 517 | 527 | zDiffCmd = db_get(isGDiff ? "gdiff-command" : "diff-command", 0); |
| 518 | 528 |
| --- 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 |