Fossil SCM
Add the --brief option to the "diff" command.
Commit
e0565d43513cbefdaa0a6ae7605ad0e1950c9acd
Parent
b1530c29ab659a5…
2 files changed
+8
-3
+19
-6
+8
-3
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -30,11 +30,12 @@ | ||
| 30 | 30 | #define DIFF_CONTEXT_MASK 0x0000ffff /* Lines of context. Default if 0 */ |
| 31 | 31 | #define DIFF_WIDTH_MASK 0x00ff0000 /* side-by-side column width */ |
| 32 | 32 | #define DIFF_IGNORE_EOLWS 0x01000000 /* Ignore end-of-line whitespace */ |
| 33 | 33 | #define DIFF_SIDEBYSIDE 0x02000000 /* Generate a side-by-side diff */ |
| 34 | 34 | #define DIFF_NEWFILE 0x04000000 /* Missing files are as empty files */ |
| 35 | -#define DIFF_INLINE 0x08000000 /* Inline (not side-by-side) diff */ | |
| 35 | +#define DIFF_BRIEF 0x08000000 /* Show filenames only */ | |
| 36 | +#define DIFF_INLINE 0x00000000 /* Inline (not side-by-side) diff */ | |
| 36 | 37 | #define DIFF_HTML 0x10000000 /* Render for HTML */ |
| 37 | 38 | #define DIFF_LINENO 0x20000000 /* Show line numbers in context diff */ |
| 38 | 39 | #define DIFF_NOOPT 0x40000000 /* Suppress optimizations for debug */ |
| 39 | 40 | #define DIFF_INVERT 0x80000000 /* Invert the diff for debug */ |
| 40 | 41 | |
| @@ -1331,15 +1332,18 @@ | ||
| 1331 | 1332 | |
| 1332 | 1333 | /* |
| 1333 | 1334 | ** Process diff-related command-line options and return an appropriate |
| 1334 | 1335 | ** "diffFlags" integer. |
| 1335 | 1336 | ** |
| 1336 | -** --side-by-side|-y Side-by-side diff. DIFF_SIDEBYSIDE | |
| 1337 | +** --brief Show filenames only DIFF_BRIEF | |
| 1337 | 1338 | ** --context|-c N N lines of context. DIFF_CONTEXT_MASK |
| 1338 | -** --width|-W N N character lines. DIFF_WIDTH_MASK | |
| 1339 | 1339 | ** --html Format for HTML DIFF_HTML |
| 1340 | +** --invert Invert the diff DIFF_INVERT | |
| 1340 | 1341 | ** --linenum|-n Show line numbers DIFF_LINENO |
| 1342 | +** --noopt Disable optimization DIFF_NOOPT | |
| 1343 | +** --side-by-side|-y Side-by-side diff. DIFF_SIDEBYSIDE | |
| 1344 | +** --width|-W N N character lines. DIFF_WIDTH_MASK | |
| 1341 | 1345 | */ |
| 1342 | 1346 | int diff_options(void){ |
| 1343 | 1347 | int diffFlags = 0; |
| 1344 | 1348 | const char *z; |
| 1345 | 1349 | int f; |
| @@ -1355,10 +1359,11 @@ | ||
| 1355 | 1359 | } |
| 1356 | 1360 | if( find_option("html",0,0)!=0 ) diffFlags |= DIFF_HTML; |
| 1357 | 1361 | if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO; |
| 1358 | 1362 | if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT; |
| 1359 | 1363 | if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT; |
| 1364 | + if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF; | |
| 1360 | 1365 | return diffFlags; |
| 1361 | 1366 | } |
| 1362 | 1367 | |
| 1363 | 1368 | /* |
| 1364 | 1369 | ** COMMAND: test-rawdiff |
| 1365 | 1370 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -30,11 +30,12 @@ | |
| 30 | #define DIFF_CONTEXT_MASK 0x0000ffff /* Lines of context. Default if 0 */ |
| 31 | #define DIFF_WIDTH_MASK 0x00ff0000 /* side-by-side column width */ |
| 32 | #define DIFF_IGNORE_EOLWS 0x01000000 /* Ignore end-of-line whitespace */ |
| 33 | #define DIFF_SIDEBYSIDE 0x02000000 /* Generate a side-by-side diff */ |
| 34 | #define DIFF_NEWFILE 0x04000000 /* Missing files are as empty files */ |
| 35 | #define DIFF_INLINE 0x08000000 /* Inline (not side-by-side) diff */ |
| 36 | #define DIFF_HTML 0x10000000 /* Render for HTML */ |
| 37 | #define DIFF_LINENO 0x20000000 /* Show line numbers in context diff */ |
| 38 | #define DIFF_NOOPT 0x40000000 /* Suppress optimizations for debug */ |
| 39 | #define DIFF_INVERT 0x80000000 /* Invert the diff for debug */ |
| 40 | |
| @@ -1331,15 +1332,18 @@ | |
| 1331 | |
| 1332 | /* |
| 1333 | ** Process diff-related command-line options and return an appropriate |
| 1334 | ** "diffFlags" integer. |
| 1335 | ** |
| 1336 | ** --side-by-side|-y Side-by-side diff. DIFF_SIDEBYSIDE |
| 1337 | ** --context|-c N N lines of context. DIFF_CONTEXT_MASK |
| 1338 | ** --width|-W N N character lines. DIFF_WIDTH_MASK |
| 1339 | ** --html Format for HTML DIFF_HTML |
| 1340 | ** --linenum|-n Show line numbers DIFF_LINENO |
| 1341 | */ |
| 1342 | int diff_options(void){ |
| 1343 | int diffFlags = 0; |
| 1344 | const char *z; |
| 1345 | int f; |
| @@ -1355,10 +1359,11 @@ | |
| 1355 | } |
| 1356 | if( find_option("html",0,0)!=0 ) diffFlags |= DIFF_HTML; |
| 1357 | if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO; |
| 1358 | if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT; |
| 1359 | if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT; |
| 1360 | return diffFlags; |
| 1361 | } |
| 1362 | |
| 1363 | /* |
| 1364 | ** COMMAND: test-rawdiff |
| 1365 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -30,11 +30,12 @@ | |
| 30 | #define DIFF_CONTEXT_MASK 0x0000ffff /* Lines of context. Default if 0 */ |
| 31 | #define DIFF_WIDTH_MASK 0x00ff0000 /* side-by-side column width */ |
| 32 | #define DIFF_IGNORE_EOLWS 0x01000000 /* Ignore end-of-line whitespace */ |
| 33 | #define DIFF_SIDEBYSIDE 0x02000000 /* Generate a side-by-side diff */ |
| 34 | #define DIFF_NEWFILE 0x04000000 /* Missing files are as empty files */ |
| 35 | #define DIFF_BRIEF 0x08000000 /* Show filenames only */ |
| 36 | #define DIFF_INLINE 0x00000000 /* Inline (not side-by-side) diff */ |
| 37 | #define DIFF_HTML 0x10000000 /* Render for HTML */ |
| 38 | #define DIFF_LINENO 0x20000000 /* Show line numbers in context diff */ |
| 39 | #define DIFF_NOOPT 0x40000000 /* Suppress optimizations for debug */ |
| 40 | #define DIFF_INVERT 0x80000000 /* Invert the diff for debug */ |
| 41 | |
| @@ -1331,15 +1332,18 @@ | |
| 1332 | |
| 1333 | /* |
| 1334 | ** Process diff-related command-line options and return an appropriate |
| 1335 | ** "diffFlags" integer. |
| 1336 | ** |
| 1337 | ** --brief Show filenames only DIFF_BRIEF |
| 1338 | ** --context|-c N N lines of context. DIFF_CONTEXT_MASK |
| 1339 | ** --html Format for HTML DIFF_HTML |
| 1340 | ** --invert Invert the diff DIFF_INVERT |
| 1341 | ** --linenum|-n Show line numbers DIFF_LINENO |
| 1342 | ** --noopt Disable optimization DIFF_NOOPT |
| 1343 | ** --side-by-side|-y Side-by-side diff. DIFF_SIDEBYSIDE |
| 1344 | ** --width|-W N N character lines. DIFF_WIDTH_MASK |
| 1345 | */ |
| 1346 | int diff_options(void){ |
| 1347 | int diffFlags = 0; |
| 1348 | const char *z; |
| 1349 | int f; |
| @@ -1355,10 +1359,11 @@ | |
| 1359 | } |
| 1360 | if( find_option("html",0,0)!=0 ) diffFlags |= DIFF_HTML; |
| 1361 | if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO; |
| 1362 | if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT; |
| 1363 | if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT; |
| 1364 | if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF; |
| 1365 | return diffFlags; |
| 1366 | } |
| 1367 | |
| 1368 | /* |
| 1369 | ** COMMAND: test-rawdiff |
| 1370 |
+19
-6
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -23,11 +23,11 @@ | ||
| 23 | 23 | |
| 24 | 24 | /* |
| 25 | 25 | ** Print the "Index:" message that patches wants to see at the top of a diff. |
| 26 | 26 | */ |
| 27 | 27 | void diff_print_index(const char *zFile, int diffFlags){ |
| 28 | - if( (diffFlags & DIFF_SIDEBYSIDE)==0 ){ | |
| 28 | + if( (diffFlags & (DIFF_SIDEBYSIDE|DIFF_BRIEF))==0 ){ | |
| 29 | 29 | char *z = mprintf("Index: %s\n%.66c\n", zFile, '='); |
| 30 | 30 | fossil_print("%s", z); |
| 31 | 31 | fossil_free(z); |
| 32 | 32 | } |
| 33 | 33 | } |
| @@ -35,11 +35,13 @@ | ||
| 35 | 35 | /* |
| 36 | 36 | ** Print the +++/--- filename lines for a diff operation. |
| 37 | 37 | */ |
| 38 | 38 | void diff_print_filenames(const char *zLeft, const char *zRight, int diffFlags){ |
| 39 | 39 | char *z = 0; |
| 40 | - if( diffFlags & DIFF_SIDEBYSIDE ){ | |
| 40 | + if( diffFlags & DIFF_BRIEF ){ | |
| 41 | + /* no-op */ | |
| 42 | + }else if( diffFlags & DIFF_SIDEBYSIDE ){ | |
| 41 | 43 | int w = diff_width(diffFlags); |
| 42 | 44 | int n1 = strlen(zLeft); |
| 43 | 45 | int x; |
| 44 | 46 | if( n1>w*2 ) n1 = w*2; |
| 45 | 47 | x = w*2+17 - (n1+2); |
| @@ -66,10 +68,11 @@ | ||
| 66 | 68 | const char *zFile2, /* On disk content to compare to */ |
| 67 | 69 | const char *zName, /* Display name of the file */ |
| 68 | 70 | const char *zDiffCmd, /* Command for comparison */ |
| 69 | 71 | int diffFlags /* Flags to control the diff */ |
| 70 | 72 | ){ |
| 73 | + if( diffFlags & DIFF_BRIEF ) return; | |
| 71 | 74 | if( zDiffCmd==0 ){ |
| 72 | 75 | Blob out; /* Diff output text */ |
| 73 | 76 | Blob file2; /* Content of zFile2 */ |
| 74 | 77 | const char *zName2; /* Name of zFile2 for display */ |
| 75 | 78 | |
| @@ -142,10 +145,11 @@ | ||
| 142 | 145 | Blob *pFile2, /* In memory content to compare to */ |
| 143 | 146 | const char *zName, /* Display name of the file */ |
| 144 | 147 | const char *zDiffCmd, /* Command for comparison */ |
| 145 | 148 | int diffFlags /* Diff flags */ |
| 146 | 149 | ){ |
| 150 | + if( diffFlags & DIFF_BRIEF ) return; | |
| 147 | 151 | if( zDiffCmd==0 ){ |
| 148 | 152 | Blob out; /* Diff output text */ |
| 149 | 153 | |
| 150 | 154 | blob_zero(&out); |
| 151 | 155 | text_diff(pFile1, pFile2, &out, diffFlags); |
| @@ -193,10 +197,11 @@ | ||
| 193 | 197 | const char *zFileTreeName |
| 194 | 198 | ){ |
| 195 | 199 | Blob fname; |
| 196 | 200 | Blob content; |
| 197 | 201 | int isLink; |
| 202 | + if( diffFlags & DIFF_BRIEF ) return; | |
| 198 | 203 | file_tree_name(zFileTreeName, &fname, 1); |
| 199 | 204 | historical_version_of_file(zFrom, blob_str(&fname), &content, &isLink, 0, 0); |
| 200 | 205 | if( !isLink != !file_wd_islink(zFrom) ){ |
| 201 | 206 | fossil_print("cannot compute difference between " |
| 202 | 207 | "symlink and regular file\n"); |
| @@ -287,11 +292,13 @@ | ||
| 287 | 292 | }else if( isChnged==3 ){ |
| 288 | 293 | fossil_print("ADDED_BY_MERGE %s\n", zPathname); |
| 289 | 294 | srcid = 0; |
| 290 | 295 | if( !asNewFile ){ showDiff = 0; } |
| 291 | 296 | } |
| 292 | - if( showDiff ){ | |
| 297 | + if( diffFlags & DIFF_BRIEF ){ | |
| 298 | + if( showDiff ) fossil_print("CHANGED %s\n", zPathname); | |
| 299 | + }else if( showDiff ){ | |
| 293 | 300 | Blob content; |
| 294 | 301 | if( !isLink != !file_wd_islink(zFullName) ){ |
| 295 | 302 | diff_print_index(zPathname, diffFlags); |
| 296 | 303 | diff_print_filenames(zPathname, zPathname, diffFlags); |
| 297 | 304 | fossil_print("cannot compute difference between " |
| @@ -326,10 +333,11 @@ | ||
| 326 | 333 | ){ |
| 327 | 334 | char *zName; |
| 328 | 335 | Blob fname; |
| 329 | 336 | Blob v1, v2; |
| 330 | 337 | int isLink1, isLink2; |
| 338 | + if( diffFlags & DIFF_BRIEF ) return; | |
| 331 | 339 | file_tree_name(zFileTreeName, &fname, 1); |
| 332 | 340 | zName = blob_str(&fname); |
| 333 | 341 | historical_version_of_file(zFrom, zName, &v1, &isLink1, 0, 0); |
| 334 | 342 | historical_version_of_file(zTo, zName, &v2, &isLink2, 0, 0); |
| 335 | 343 | if( isLink1 != isLink2 ){ |
| @@ -355,10 +363,11 @@ | ||
| 355 | 363 | int diffFlags |
| 356 | 364 | ){ |
| 357 | 365 | Blob f1, f2; |
| 358 | 366 | int rid; |
| 359 | 367 | const char *zName = pFrom ? pFrom->zName : pTo->zName; |
| 368 | + if( diffFlags & DIFF_BRIEF ) return; | |
| 360 | 369 | diff_print_index(zName, diffFlags); |
| 361 | 370 | if( pFrom ){ |
| 362 | 371 | rid = uuid_to_rid(pFrom->zUuid, 0); |
| 363 | 372 | content_get(rid, &f1); |
| 364 | 373 | }else{ |
| @@ -419,12 +428,15 @@ | ||
| 419 | 428 | }else if( fossil_strcmp(pFromFile->zUuid, pToFile->zUuid)==0 ){ |
| 420 | 429 | /* No changes */ |
| 421 | 430 | pFromFile = manifest_file_next(pFrom,0); |
| 422 | 431 | pToFile = manifest_file_next(pTo,0); |
| 423 | 432 | }else{ |
| 424 | - /* fossil_print("CHANGED %s\n", pFromFile->zName); */ | |
| 425 | - diff_manifest_entry(pFromFile, pToFile, zDiffCmd, diffFlags); | |
| 433 | + if( diffFlags & DIFF_BRIEF ){ | |
| 434 | + fossil_print("CHANGED %s\n", pFromFile->zName); | |
| 435 | + }else{ | |
| 436 | + diff_manifest_entry(pFromFile, pToFile, zDiffCmd, diffFlags); | |
| 437 | + } | |
| 426 | 438 | pFromFile = manifest_file_next(pFrom,0); |
| 427 | 439 | pToFile = manifest_file_next(pTo,0); |
| 428 | 440 | } |
| 429 | 441 | } |
| 430 | 442 | manifest_destroy(pFrom); |
| @@ -458,14 +470,15 @@ | ||
| 458 | 470 | ** |
| 459 | 471 | ** The "-N" or "--new-file" option causes the complete text of added or |
| 460 | 472 | ** deleted files to be displayed. |
| 461 | 473 | ** |
| 462 | 474 | ** Options: |
| 475 | +** --brief Show filenames only | |
| 463 | 476 | ** --context|-c N Use N lines of context |
| 464 | 477 | ** --from|-r VERSION select VERSION as source for the diff |
| 465 | -** --new-file|-N output complete text of added or deleted files | |
| 466 | 478 | ** -i use internal diff logic |
| 479 | +** --new-file|-N output complete text of added or deleted files | |
| 467 | 480 | ** --to VERSION select VERSION as target for the diff |
| 468 | 481 | ** --side-by-side|-y side-by-side diff |
| 469 | 482 | ** --width|-W N Width of lines in side-by-side diff |
| 470 | 483 | */ |
| 471 | 484 | void diff_cmd(void){ |
| 472 | 485 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -23,11 +23,11 @@ | |
| 23 | |
| 24 | /* |
| 25 | ** Print the "Index:" message that patches wants to see at the top of a diff. |
| 26 | */ |
| 27 | void diff_print_index(const char *zFile, int diffFlags){ |
| 28 | if( (diffFlags & DIFF_SIDEBYSIDE)==0 ){ |
| 29 | char *z = mprintf("Index: %s\n%.66c\n", zFile, '='); |
| 30 | fossil_print("%s", z); |
| 31 | fossil_free(z); |
| 32 | } |
| 33 | } |
| @@ -35,11 +35,13 @@ | |
| 35 | /* |
| 36 | ** Print the +++/--- filename lines for a diff operation. |
| 37 | */ |
| 38 | void diff_print_filenames(const char *zLeft, const char *zRight, int diffFlags){ |
| 39 | char *z = 0; |
| 40 | if( diffFlags & DIFF_SIDEBYSIDE ){ |
| 41 | int w = diff_width(diffFlags); |
| 42 | int n1 = strlen(zLeft); |
| 43 | int x; |
| 44 | if( n1>w*2 ) n1 = w*2; |
| 45 | x = w*2+17 - (n1+2); |
| @@ -66,10 +68,11 @@ | |
| 66 | const char *zFile2, /* On disk content to compare to */ |
| 67 | const char *zName, /* Display name of the file */ |
| 68 | const char *zDiffCmd, /* Command for comparison */ |
| 69 | int diffFlags /* Flags to control the diff */ |
| 70 | ){ |
| 71 | if( zDiffCmd==0 ){ |
| 72 | Blob out; /* Diff output text */ |
| 73 | Blob file2; /* Content of zFile2 */ |
| 74 | const char *zName2; /* Name of zFile2 for display */ |
| 75 | |
| @@ -142,10 +145,11 @@ | |
| 142 | Blob *pFile2, /* In memory content to compare to */ |
| 143 | const char *zName, /* Display name of the file */ |
| 144 | const char *zDiffCmd, /* Command for comparison */ |
| 145 | int diffFlags /* Diff flags */ |
| 146 | ){ |
| 147 | if( zDiffCmd==0 ){ |
| 148 | Blob out; /* Diff output text */ |
| 149 | |
| 150 | blob_zero(&out); |
| 151 | text_diff(pFile1, pFile2, &out, diffFlags); |
| @@ -193,10 +197,11 @@ | |
| 193 | const char *zFileTreeName |
| 194 | ){ |
| 195 | Blob fname; |
| 196 | Blob content; |
| 197 | int isLink; |
| 198 | file_tree_name(zFileTreeName, &fname, 1); |
| 199 | historical_version_of_file(zFrom, blob_str(&fname), &content, &isLink, 0, 0); |
| 200 | if( !isLink != !file_wd_islink(zFrom) ){ |
| 201 | fossil_print("cannot compute difference between " |
| 202 | "symlink and regular file\n"); |
| @@ -287,11 +292,13 @@ | |
| 287 | }else if( isChnged==3 ){ |
| 288 | fossil_print("ADDED_BY_MERGE %s\n", zPathname); |
| 289 | srcid = 0; |
| 290 | if( !asNewFile ){ showDiff = 0; } |
| 291 | } |
| 292 | if( showDiff ){ |
| 293 | Blob content; |
| 294 | if( !isLink != !file_wd_islink(zFullName) ){ |
| 295 | diff_print_index(zPathname, diffFlags); |
| 296 | diff_print_filenames(zPathname, zPathname, diffFlags); |
| 297 | fossil_print("cannot compute difference between " |
| @@ -326,10 +333,11 @@ | |
| 326 | ){ |
| 327 | char *zName; |
| 328 | Blob fname; |
| 329 | Blob v1, v2; |
| 330 | int isLink1, isLink2; |
| 331 | file_tree_name(zFileTreeName, &fname, 1); |
| 332 | zName = blob_str(&fname); |
| 333 | historical_version_of_file(zFrom, zName, &v1, &isLink1, 0, 0); |
| 334 | historical_version_of_file(zTo, zName, &v2, &isLink2, 0, 0); |
| 335 | if( isLink1 != isLink2 ){ |
| @@ -355,10 +363,11 @@ | |
| 355 | int diffFlags |
| 356 | ){ |
| 357 | Blob f1, f2; |
| 358 | int rid; |
| 359 | const char *zName = pFrom ? pFrom->zName : pTo->zName; |
| 360 | diff_print_index(zName, diffFlags); |
| 361 | if( pFrom ){ |
| 362 | rid = uuid_to_rid(pFrom->zUuid, 0); |
| 363 | content_get(rid, &f1); |
| 364 | }else{ |
| @@ -419,12 +428,15 @@ | |
| 419 | }else if( fossil_strcmp(pFromFile->zUuid, pToFile->zUuid)==0 ){ |
| 420 | /* No changes */ |
| 421 | pFromFile = manifest_file_next(pFrom,0); |
| 422 | pToFile = manifest_file_next(pTo,0); |
| 423 | }else{ |
| 424 | /* fossil_print("CHANGED %s\n", pFromFile->zName); */ |
| 425 | diff_manifest_entry(pFromFile, pToFile, zDiffCmd, diffFlags); |
| 426 | pFromFile = manifest_file_next(pFrom,0); |
| 427 | pToFile = manifest_file_next(pTo,0); |
| 428 | } |
| 429 | } |
| 430 | manifest_destroy(pFrom); |
| @@ -458,14 +470,15 @@ | |
| 458 | ** |
| 459 | ** The "-N" or "--new-file" option causes the complete text of added or |
| 460 | ** deleted files to be displayed. |
| 461 | ** |
| 462 | ** Options: |
| 463 | ** --context|-c N Use N lines of context |
| 464 | ** --from|-r VERSION select VERSION as source for the diff |
| 465 | ** --new-file|-N output complete text of added or deleted files |
| 466 | ** -i use internal diff logic |
| 467 | ** --to VERSION select VERSION as target for the diff |
| 468 | ** --side-by-side|-y side-by-side diff |
| 469 | ** --width|-W N Width of lines in side-by-side diff |
| 470 | */ |
| 471 | void diff_cmd(void){ |
| 472 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -23,11 +23,11 @@ | |
| 23 | |
| 24 | /* |
| 25 | ** Print the "Index:" message that patches wants to see at the top of a diff. |
| 26 | */ |
| 27 | void diff_print_index(const char *zFile, int diffFlags){ |
| 28 | if( (diffFlags & (DIFF_SIDEBYSIDE|DIFF_BRIEF))==0 ){ |
| 29 | char *z = mprintf("Index: %s\n%.66c\n", zFile, '='); |
| 30 | fossil_print("%s", z); |
| 31 | fossil_free(z); |
| 32 | } |
| 33 | } |
| @@ -35,11 +35,13 @@ | |
| 35 | /* |
| 36 | ** Print the +++/--- filename lines for a diff operation. |
| 37 | */ |
| 38 | void diff_print_filenames(const char *zLeft, const char *zRight, int diffFlags){ |
| 39 | char *z = 0; |
| 40 | if( diffFlags & DIFF_BRIEF ){ |
| 41 | /* no-op */ |
| 42 | }else if( diffFlags & DIFF_SIDEBYSIDE ){ |
| 43 | int w = diff_width(diffFlags); |
| 44 | int n1 = strlen(zLeft); |
| 45 | int x; |
| 46 | if( n1>w*2 ) n1 = w*2; |
| 47 | x = w*2+17 - (n1+2); |
| @@ -66,10 +68,11 @@ | |
| 68 | const char *zFile2, /* On disk content to compare to */ |
| 69 | const char *zName, /* Display name of the file */ |
| 70 | const char *zDiffCmd, /* Command for comparison */ |
| 71 | int diffFlags /* Flags to control the diff */ |
| 72 | ){ |
| 73 | if( diffFlags & DIFF_BRIEF ) return; |
| 74 | if( zDiffCmd==0 ){ |
| 75 | Blob out; /* Diff output text */ |
| 76 | Blob file2; /* Content of zFile2 */ |
| 77 | const char *zName2; /* Name of zFile2 for display */ |
| 78 | |
| @@ -142,10 +145,11 @@ | |
| 145 | Blob *pFile2, /* In memory content to compare to */ |
| 146 | const char *zName, /* Display name of the file */ |
| 147 | const char *zDiffCmd, /* Command for comparison */ |
| 148 | int diffFlags /* Diff flags */ |
| 149 | ){ |
| 150 | if( diffFlags & DIFF_BRIEF ) return; |
| 151 | if( zDiffCmd==0 ){ |
| 152 | Blob out; /* Diff output text */ |
| 153 | |
| 154 | blob_zero(&out); |
| 155 | text_diff(pFile1, pFile2, &out, diffFlags); |
| @@ -193,10 +197,11 @@ | |
| 197 | const char *zFileTreeName |
| 198 | ){ |
| 199 | Blob fname; |
| 200 | Blob content; |
| 201 | int isLink; |
| 202 | if( diffFlags & DIFF_BRIEF ) return; |
| 203 | file_tree_name(zFileTreeName, &fname, 1); |
| 204 | historical_version_of_file(zFrom, blob_str(&fname), &content, &isLink, 0, 0); |
| 205 | if( !isLink != !file_wd_islink(zFrom) ){ |
| 206 | fossil_print("cannot compute difference between " |
| 207 | "symlink and regular file\n"); |
| @@ -287,11 +292,13 @@ | |
| 292 | }else if( isChnged==3 ){ |
| 293 | fossil_print("ADDED_BY_MERGE %s\n", zPathname); |
| 294 | srcid = 0; |
| 295 | if( !asNewFile ){ showDiff = 0; } |
| 296 | } |
| 297 | if( diffFlags & DIFF_BRIEF ){ |
| 298 | if( showDiff ) fossil_print("CHANGED %s\n", zPathname); |
| 299 | }else if( showDiff ){ |
| 300 | Blob content; |
| 301 | if( !isLink != !file_wd_islink(zFullName) ){ |
| 302 | diff_print_index(zPathname, diffFlags); |
| 303 | diff_print_filenames(zPathname, zPathname, diffFlags); |
| 304 | fossil_print("cannot compute difference between " |
| @@ -326,10 +333,11 @@ | |
| 333 | ){ |
| 334 | char *zName; |
| 335 | Blob fname; |
| 336 | Blob v1, v2; |
| 337 | int isLink1, isLink2; |
| 338 | if( diffFlags & DIFF_BRIEF ) return; |
| 339 | file_tree_name(zFileTreeName, &fname, 1); |
| 340 | zName = blob_str(&fname); |
| 341 | historical_version_of_file(zFrom, zName, &v1, &isLink1, 0, 0); |
| 342 | historical_version_of_file(zTo, zName, &v2, &isLink2, 0, 0); |
| 343 | if( isLink1 != isLink2 ){ |
| @@ -355,10 +363,11 @@ | |
| 363 | int diffFlags |
| 364 | ){ |
| 365 | Blob f1, f2; |
| 366 | int rid; |
| 367 | const char *zName = pFrom ? pFrom->zName : pTo->zName; |
| 368 | if( diffFlags & DIFF_BRIEF ) return; |
| 369 | diff_print_index(zName, diffFlags); |
| 370 | if( pFrom ){ |
| 371 | rid = uuid_to_rid(pFrom->zUuid, 0); |
| 372 | content_get(rid, &f1); |
| 373 | }else{ |
| @@ -419,12 +428,15 @@ | |
| 428 | }else if( fossil_strcmp(pFromFile->zUuid, pToFile->zUuid)==0 ){ |
| 429 | /* No changes */ |
| 430 | pFromFile = manifest_file_next(pFrom,0); |
| 431 | pToFile = manifest_file_next(pTo,0); |
| 432 | }else{ |
| 433 | if( diffFlags & DIFF_BRIEF ){ |
| 434 | fossil_print("CHANGED %s\n", pFromFile->zName); |
| 435 | }else{ |
| 436 | diff_manifest_entry(pFromFile, pToFile, zDiffCmd, diffFlags); |
| 437 | } |
| 438 | pFromFile = manifest_file_next(pFrom,0); |
| 439 | pToFile = manifest_file_next(pTo,0); |
| 440 | } |
| 441 | } |
| 442 | manifest_destroy(pFrom); |
| @@ -458,14 +470,15 @@ | |
| 470 | ** |
| 471 | ** The "-N" or "--new-file" option causes the complete text of added or |
| 472 | ** deleted files to be displayed. |
| 473 | ** |
| 474 | ** Options: |
| 475 | ** --brief Show filenames only |
| 476 | ** --context|-c N Use N lines of context |
| 477 | ** --from|-r VERSION select VERSION as source for the diff |
| 478 | ** -i use internal diff logic |
| 479 | ** --new-file|-N output complete text of added or deleted files |
| 480 | ** --to VERSION select VERSION as target for the diff |
| 481 | ** --side-by-side|-y side-by-side diff |
| 482 | ** --width|-W N Width of lines in side-by-side diff |
| 483 | */ |
| 484 | void diff_cmd(void){ |
| 485 |