Differences From:
File
src/diffcmd.c
part of check-in
[c82fb61775]
- Added support for a user defined diff command, which if set (fossil config diff-command), is run by default. The user can give a -i flag to run the internal diff command regardless of user defined diff command setting. Removed command tkdiff, no longer needed. Made the config remove message a bit more clear, when removing a config setting, it states it has been removed instead of telling you it's undefined.
by
jnc on
2007-09-24 06:53:46.
[view]
To:
File
src/diffcmd.c
part of check-in
[01ce2cf3dc]
- Added a gdiff command. diff command now runs config diff-command, gdiff command (graphical diff) now runs config gdiff-command. With both, if -i is supplied, internal diff is used. With both, if they are not configured, internal diff is used. Fixed bug with internal diff giving files in reverse order. Also put div id="sub-menu" inside of submenu if, as to not display the sub menu if no sub menu items exist
by
jnc on
2007-09-24 14:02:30.
[view]
@@ -43,24 +43,33 @@
}
/*
** COMMAND: diff
+** COMMAND: gdiff
**
-** Usage: %fossil diff ?-i FILE...
+** Usage: %fossil diff|gdiff ?-i FILE...
**
** Show the difference between the current version of a file (as it
** exists on disk) and that same file as it was checked out.
-** If -i is supplied, the internal diff command will be executed
-** otherwise, fossil attempts to use the user configured diff-command.
+**
+** diff will show a textual diff while gdiff will attempt to run a
+** graphical diff command that you have setup. If the choosen command
+** is not yet configured, the internal textual diff command will be
+** used.
+**
+** If -i is supplied for either diff or gdiff, the internal textual
+** diff command will be executed.
**
** Here are a few external diff command settings, for example:
**
-** %fossil config diff-command=tkdiff
-** %fossil config diff-command=eskill22
-** %fossil config diff-command=tortoisemerge
-** %fossil config diff-command=meld
-** %fossil config diff-command=xxdiff
-** %fossil config diff-command=kdiff3
+** %fossil config diff-command=diff
+**
+** %fossil config gdiff-command=tkdiff
+** %fossil config gdiff-command=eskill22
+** %fossil config gdiff-command=tortoisemerge
+** %fossil config gdiff-command=meld
+** %fossil config gdiff-command=xxdiff
+** %fossil config gdiff-command=kdiff3
*/
void diff_cmd(void){
const char *zFile;
Blob cmd;
@@ -68,22 +77,27 @@
int i, internalDiff;
char *zV1 = 0;
char *zV2 = 0;
- internalDiff = find_option("intertal","i",0)!=0;
+ internalDiff = find_option("internal","i",0)!=0;
if( g.argc<3 ){
usage("?OPTIONS? FILE");
}
db_must_be_within_tree();
if( internalDiff==0 ){
- const char *zExternalCommand = db_global_get("diff-command", 0);
+ const char *zExternalCommand;
+ if( strcmp(g.argv[1], "diff")==0 ){
+ zExternalCommand = db_global_get("diff-command", 0);
+ }else{
+ zExternalCommand = db_global_get("gdiff-command", 0);
+ }
if( zExternalCommand==0 ){
internalDiff=1;
}
- blob_zero(&cmd);
- blob_appendf(&cmd, "%s ", zExternalCommand);
+ blob_zero(&cmd);
+ blob_appendf(&cmd, "%s ", zExternalCommand);
}
for(i=2; i<g.argc-1; i++){
const char *z = g.argv[i];
if( (strcmp(z,"-v")==0 || strcmp(z,"--version")==0) && i<g.argc-2 ){
@@ -124,9 +138,9 @@
Blob out;
blob_zero(¤t);
blob_read_from_file(¤t, zFile);
blob_zero(&out);
- unified_diff(¤t, &record, 5, &out);
+ unified_diff(&record, ¤t, 5, &out);
printf("%s\n", blob_str(&out));
blob_reset(¤t);
blob_reset(&out);
}else{