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.
Commit
954fb421e16ea89e8cdd6154b8a2769a602bcefae9aa5fa876579c27c65d3431
Parent
8025b52a90e6254…
1 file changed
+17
-9
+17
-9
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -1165,25 +1165,33 @@ | ||
| 1165 | 1165 | /* |
| 1166 | 1166 | ** Return the name of the external diff command, or return NULL if |
| 1167 | 1167 | ** no external diff command is defined. |
| 1168 | 1168 | */ |
| 1169 | 1169 | const char *diff_command_external(int guiDiff){ |
| 1170 | - const char *zDefault; | |
| 1170 | + const char *zResult; | |
| 1171 | 1171 | const char *zName; |
| 1172 | 1172 | |
| 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[] = { | |
| 1174 | 1177 | #if defined(_WIN32) |
| 1175 | - zDefault = "WinDiff.exe"; | |
| 1178 | + "winmergeu", "meld", "kdiff3", "bcompare", "vimdiff", "examdiff" | |
| 1176 | 1179 | #else |
| 1177 | - zDefault = 0; | |
| 1180 | + "meld", "kdiff3" | |
| 1178 | 1181 | #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 | + } | |
| 1183 | 1191 | } |
| 1184 | - return db_get(zName, zDefault); | |
| 1192 | + return zResult; | |
| 1185 | 1193 | } |
| 1186 | 1194 | |
| 1187 | 1195 | /* |
| 1188 | 1196 | ** Show diff output in a Tcl/Tk window, in response to the --tk option |
| 1189 | 1197 | ** to the diff command. |
| 1190 | 1198 |
| --- 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 |