Fossil SCM

If the "gdiff-command" setting is not defined when the "fossil gdiff" command is run, go on a search for a suitable replacement.

drh 2025-03-17 14:02 trunk
Commit 954fb421e16ea89e8cdd6154b8a2769a602bcefae9aa5fa876579c27c65d3431
1 file changed +17 -9
+17 -9
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -1165,25 +1165,33 @@
11651165
/*
11661166
** Return the name of the external diff command, or return NULL if
11671167
** no external diff command is defined.
11681168
*/
11691169
const char *diff_command_external(int guiDiff){
1170
- const char *zDefault;
1170
+ const char *zResult;
11711171
const char *zName;
11721172
1173
- if( guiDiff ){
1173
+ zName = guiDiff ? "gdiff-command" : "diff-command";
1174
+ zResult = db_get(zName, "");
1175
+ if( zResult[0]==0 && guiDiff ){
1176
+ static const char *azGuiDiff[] = {
11741177
#if defined(_WIN32)
1175
- zDefault = "WinDiff.exe";
1178
+ "winmergeu", "meld", "kdiff3", "bcompare", "vimdiff", "examdiff"
11761179
#else
1177
- zDefault = 0;
1180
+ "meld", "kdiff3"
11781181
#endif
1179
- zName = "gdiff-command";
1180
- }else{
1181
- zDefault = 0;
1182
- zName = "diff-command";
1182
+ };
1183
+ int i;
1184
+ zResult = 0;
1185
+ for(i=0; i<count(azGuiDiff); i++){
1186
+ if( fossil_app_on_path(azGuiDiff[i], 0) ){
1187
+ zResult = azGuiDiff[i];
1188
+ break;
1189
+ }
1190
+ }
11831191
}
1184
- return db_get(zName, zDefault);
1192
+ return zResult;
11851193
}
11861194
11871195
/*
11881196
** Show diff output in a Tcl/Tk window, in response to the --tk option
11891197
** to the diff command.
11901198
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -1165,25 +1165,33 @@
1165 /*
1166 ** Return the name of the external diff command, or return NULL if
1167 ** no external diff command is defined.
1168 */
1169 const char *diff_command_external(int guiDiff){
1170 const char *zDefault;
1171 const char *zName;
1172
1173 if( guiDiff ){
 
 
 
1174 #if defined(_WIN32)
1175 zDefault = "WinDiff.exe";
1176 #else
1177 zDefault = 0;
1178 #endif
1179 zName = "gdiff-command";
1180 }else{
1181 zDefault = 0;
1182 zName = "diff-command";
 
 
 
 
 
1183 }
1184 return db_get(zName, zDefault);
1185 }
1186
1187 /*
1188 ** Show diff output in a Tcl/Tk window, in response to the --tk option
1189 ** to the diff command.
1190
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -1165,25 +1165,33 @@
1165 /*
1166 ** Return the name of the external diff command, or return NULL if
1167 ** no external diff command is defined.
1168 */
1169 const char *diff_command_external(int guiDiff){
1170 const char *zResult;
1171 const char *zName;
1172
1173 zName = guiDiff ? "gdiff-command" : "diff-command";
1174 zResult = db_get(zName, "");
1175 if( zResult[0]==0 && guiDiff ){
1176 static const char *azGuiDiff[] = {
1177 #if defined(_WIN32)
1178 "winmergeu", "meld", "kdiff3", "bcompare", "vimdiff", "examdiff"
1179 #else
1180 "meld", "kdiff3"
1181 #endif
1182 };
1183 int i;
1184 zResult = 0;
1185 for(i=0; i<count(azGuiDiff); i++){
1186 if( fossil_app_on_path(azGuiDiff[i], 0) ){
1187 zResult = azGuiDiff[i];
1188 break;
1189 }
1190 }
1191 }
1192 return zResult;
1193 }
1194
1195 /*
1196 ** Show diff output in a Tcl/Tk window, in response to the --tk option
1197 ** to the diff command.
1198

Keyboard Shortcuts

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