Fossil SCM
Improvements to the output of the "diff" command so that it is closer to standards.
Commit
85670cfcc852fdf5ca15a761185dadf9f02310d2
Parent
56177cfe12dec52…
1 file changed
+14
-6
+14
-6
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -93,10 +93,14 @@ | ||
| 93 | 93 | }else if( isDeleted ){ |
| 94 | 94 | printf("DELETED %s\n", zPathname); |
| 95 | 95 | }else if( isChnged==3 ){ |
| 96 | 96 | printf("ADDED_BY_MERGE %s\n", zPathname); |
| 97 | 97 | }else{ |
| 98 | + printf("Index: %s\n=======================================" | |
| 99 | + "============================\n", | |
| 100 | + zPathname | |
| 101 | + ); | |
| 98 | 102 | shell_escape(&cmd, zFullName); |
| 99 | 103 | printf("%s\n", blob_str(&cmd)); |
| 100 | 104 | fflush(stdout); |
| 101 | 105 | system(blob_str(&cmd)); |
| 102 | 106 | } |
| @@ -132,18 +136,21 @@ | ||
| 132 | 136 | ** %fossil setting gdiff-command meld |
| 133 | 137 | ** %fossil setting gdiff-command xxdiff |
| 134 | 138 | ** %fossil setting gdiff-command kdiff3 |
| 135 | 139 | */ |
| 136 | 140 | void diff_cmd(void){ |
| 137 | - int isGDiff = g.argv[1][0]=='g'; | |
| 138 | - const char *zFile, *zRevision; | |
| 139 | - Blob cmd; | |
| 140 | - Blob fname; | |
| 141 | + int isGDiff; /* True for gdiff. False for normal diff */ | |
| 142 | + const char *zFile; /* Name of file to diff */ | |
| 143 | + const char *zRevision; /* Version of file to diff against current */ | |
| 144 | + Blob cmd; /* The diff command-line for external diff */ | |
| 145 | + Blob fname; /* */ | |
| 141 | 146 | Blob vname; |
| 142 | 147 | Blob record; |
| 143 | - int cnt=0,internalDiff; | |
| 148 | + int cnt=0; | |
| 149 | + int internalDiff; /* True to use the internal diff engine */ | |
| 144 | 150 | |
| 151 | + isGDiff = g.argv[1][0]=='g'; | |
| 145 | 152 | internalDiff = find_option("internal","i",0)!=0; |
| 146 | 153 | zRevision = find_option("revision", "r", 1); |
| 147 | 154 | verify_all_options(); |
| 148 | 155 | db_must_be_within_tree(); |
| 149 | 156 | |
| @@ -178,11 +185,11 @@ | ||
| 178 | 185 | }while( access(blob_str(&vname),0)==0 ); |
| 179 | 186 | |
| 180 | 187 | if( zRevision==0 ){ |
| 181 | 188 | int rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B", &fname); |
| 182 | 189 | if( rid==0 ){ |
| 183 | - fossil_panic("no history for file: %b", &fname); | |
| 190 | + fossil_fatal("no history for file: %b", &fname); | |
| 184 | 191 | } |
| 185 | 192 | content_get(rid, &record); |
| 186 | 193 | }else{ |
| 187 | 194 | historical_version_of_file(zRevision, blob_str(&fname), &record); |
| 188 | 195 | } |
| @@ -191,10 +198,11 @@ | ||
| 191 | 198 | Blob current; |
| 192 | 199 | blob_zero(¤t); |
| 193 | 200 | blob_read_from_file(¤t, zFile); |
| 194 | 201 | blob_zero(&out); |
| 195 | 202 | text_diff(&record, ¤t, &out, 5); |
| 203 | + printf("--- %s\n+++ %s\n", blob_str(&fname), blob_str(&fname)); | |
| 196 | 204 | printf("%s\n", blob_str(&out)); |
| 197 | 205 | blob_reset(¤t); |
| 198 | 206 | blob_reset(&out); |
| 199 | 207 | }else{ |
| 200 | 208 | blob_write_to_file(&record, blob_str(&vname)); |
| 201 | 209 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -93,10 +93,14 @@ | |
| 93 | }else if( isDeleted ){ |
| 94 | printf("DELETED %s\n", zPathname); |
| 95 | }else if( isChnged==3 ){ |
| 96 | printf("ADDED_BY_MERGE %s\n", zPathname); |
| 97 | }else{ |
| 98 | shell_escape(&cmd, zFullName); |
| 99 | printf("%s\n", blob_str(&cmd)); |
| 100 | fflush(stdout); |
| 101 | system(blob_str(&cmd)); |
| 102 | } |
| @@ -132,18 +136,21 @@ | |
| 132 | ** %fossil setting gdiff-command meld |
| 133 | ** %fossil setting gdiff-command xxdiff |
| 134 | ** %fossil setting gdiff-command kdiff3 |
| 135 | */ |
| 136 | void diff_cmd(void){ |
| 137 | int isGDiff = g.argv[1][0]=='g'; |
| 138 | const char *zFile, *zRevision; |
| 139 | Blob cmd; |
| 140 | Blob fname; |
| 141 | Blob vname; |
| 142 | Blob record; |
| 143 | int cnt=0,internalDiff; |
| 144 | |
| 145 | internalDiff = find_option("internal","i",0)!=0; |
| 146 | zRevision = find_option("revision", "r", 1); |
| 147 | verify_all_options(); |
| 148 | db_must_be_within_tree(); |
| 149 | |
| @@ -178,11 +185,11 @@ | |
| 178 | }while( access(blob_str(&vname),0)==0 ); |
| 179 | |
| 180 | if( zRevision==0 ){ |
| 181 | int rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B", &fname); |
| 182 | if( rid==0 ){ |
| 183 | fossil_panic("no history for file: %b", &fname); |
| 184 | } |
| 185 | content_get(rid, &record); |
| 186 | }else{ |
| 187 | historical_version_of_file(zRevision, blob_str(&fname), &record); |
| 188 | } |
| @@ -191,10 +198,11 @@ | |
| 191 | Blob current; |
| 192 | blob_zero(¤t); |
| 193 | blob_read_from_file(¤t, zFile); |
| 194 | blob_zero(&out); |
| 195 | text_diff(&record, ¤t, &out, 5); |
| 196 | printf("%s\n", blob_str(&out)); |
| 197 | blob_reset(¤t); |
| 198 | blob_reset(&out); |
| 199 | }else{ |
| 200 | blob_write_to_file(&record, blob_str(&vname)); |
| 201 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -93,10 +93,14 @@ | |
| 93 | }else if( isDeleted ){ |
| 94 | printf("DELETED %s\n", zPathname); |
| 95 | }else if( isChnged==3 ){ |
| 96 | printf("ADDED_BY_MERGE %s\n", zPathname); |
| 97 | }else{ |
| 98 | printf("Index: %s\n=======================================" |
| 99 | "============================\n", |
| 100 | zPathname |
| 101 | ); |
| 102 | shell_escape(&cmd, zFullName); |
| 103 | printf("%s\n", blob_str(&cmd)); |
| 104 | fflush(stdout); |
| 105 | system(blob_str(&cmd)); |
| 106 | } |
| @@ -132,18 +136,21 @@ | |
| 136 | ** %fossil setting gdiff-command meld |
| 137 | ** %fossil setting gdiff-command xxdiff |
| 138 | ** %fossil setting gdiff-command kdiff3 |
| 139 | */ |
| 140 | void diff_cmd(void){ |
| 141 | int isGDiff; /* True for gdiff. False for normal diff */ |
| 142 | const char *zFile; /* Name of file to diff */ |
| 143 | const char *zRevision; /* Version of file to diff against current */ |
| 144 | Blob cmd; /* The diff command-line for external diff */ |
| 145 | Blob fname; /* */ |
| 146 | Blob vname; |
| 147 | Blob record; |
| 148 | int cnt=0; |
| 149 | int internalDiff; /* True to use the internal diff engine */ |
| 150 | |
| 151 | isGDiff = g.argv[1][0]=='g'; |
| 152 | internalDiff = find_option("internal","i",0)!=0; |
| 153 | zRevision = find_option("revision", "r", 1); |
| 154 | verify_all_options(); |
| 155 | db_must_be_within_tree(); |
| 156 | |
| @@ -178,11 +185,11 @@ | |
| 185 | }while( access(blob_str(&vname),0)==0 ); |
| 186 | |
| 187 | if( zRevision==0 ){ |
| 188 | int rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B", &fname); |
| 189 | if( rid==0 ){ |
| 190 | fossil_fatal("no history for file: %b", &fname); |
| 191 | } |
| 192 | content_get(rid, &record); |
| 193 | }else{ |
| 194 | historical_version_of_file(zRevision, blob_str(&fname), &record); |
| 195 | } |
| @@ -191,10 +198,11 @@ | |
| 198 | Blob current; |
| 199 | blob_zero(¤t); |
| 200 | blob_read_from_file(¤t, zFile); |
| 201 | blob_zero(&out); |
| 202 | text_diff(&record, ¤t, &out, 5); |
| 203 | printf("--- %s\n+++ %s\n", blob_str(&fname), blob_str(&fname)); |
| 204 | printf("%s\n", blob_str(&out)); |
| 205 | blob_reset(¤t); |
| 206 | blob_reset(&out); |
| 207 | }else{ |
| 208 | blob_write_to_file(&record, blob_str(&vname)); |
| 209 |