Fossil SCM

Simplification of the logic that uses --tk for gdiff if no other graphical diff program is specified and if Tcl/Tk is available. Improvement to check-in [5bec7a698eb110ef].

drh 2026-08-01 19:33 UTC trunk
Commit f3c2b9a29e540d1102ecc10fdc77b64fdd1c9c19c9f6ce5b5c271fe4ecf1da79
2 files changed +4 -10 -9
+4 -10
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -1385,11 +1385,14 @@
13851385
FileDirList *pFileDir = 0; /* Restrict the diff to these files */
13861386
DiffConfig DCfg; /* Diff configuration object */
13871387
int bFromIsDir = 0; /* True if zFrom is a directory name */
13881388
13891389
isGDiff = g.argv[1][0]=='g';
1390
- if( find_option("tk",0,0)!=0|| has_option("tclsh") ){
1390
+ if( find_option("tk",0,0)!=0
1391
+ || has_option("tclsh")
1392
+ || gdiff_using_tk(isGDiff)
1393
+ ){
13911394
diff_tk("diff", 2);
13921395
return;
13931396
}
13941397
zFrom = find_option("from", "r", 1);
13951398
zTo = find_option("to", 0, 1);
@@ -1420,19 +1423,10 @@
14201423
db_find_and_open_repository(0, 0);
14211424
}
14221425
}else{
14231426
db_find_and_open_repository(0, 0);
14241427
}
1425
- if( gdiff_using_tk(isGDiff) ){
1426
- restore_option("--from", zFrom, 1);
1427
- restore_option("--to", zTo, 1);
1428
- restore_option("--checkin", zCheckin, 1);
1429
- restore_option("--branch", zBranch, 1);
1430
- if( againstUndo ) restore_option("--undo", 0, 0);
1431
- diff_tk("diff", 2);
1432
- return;
1433
- }
14341428
determine_exec_relative_option(1);
14351429
if( zFrom!=file_tail(zFrom)
14361430
&& file_isdir(zFrom, ExtFILE)==1
14371431
&& !db_exists("SELECT 1 FROM tag WHERE tagname='sym-%q'", zFrom)
14381432
){
14391433
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -1385,11 +1385,14 @@
1385 FileDirList *pFileDir = 0; /* Restrict the diff to these files */
1386 DiffConfig DCfg; /* Diff configuration object */
1387 int bFromIsDir = 0; /* True if zFrom is a directory name */
1388
1389 isGDiff = g.argv[1][0]=='g';
1390 if( find_option("tk",0,0)!=0|| has_option("tclsh") ){
 
 
 
1391 diff_tk("diff", 2);
1392 return;
1393 }
1394 zFrom = find_option("from", "r", 1);
1395 zTo = find_option("to", 0, 1);
@@ -1420,19 +1423,10 @@
1420 db_find_and_open_repository(0, 0);
1421 }
1422 }else{
1423 db_find_and_open_repository(0, 0);
1424 }
1425 if( gdiff_using_tk(isGDiff) ){
1426 restore_option("--from", zFrom, 1);
1427 restore_option("--to", zTo, 1);
1428 restore_option("--checkin", zCheckin, 1);
1429 restore_option("--branch", zBranch, 1);
1430 if( againstUndo ) restore_option("--undo", 0, 0);
1431 diff_tk("diff", 2);
1432 return;
1433 }
1434 determine_exec_relative_option(1);
1435 if( zFrom!=file_tail(zFrom)
1436 && file_isdir(zFrom, ExtFILE)==1
1437 && !db_exists("SELECT 1 FROM tag WHERE tagname='sym-%q'", zFrom)
1438 ){
1439
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -1385,11 +1385,14 @@
1385 FileDirList *pFileDir = 0; /* Restrict the diff to these files */
1386 DiffConfig DCfg; /* Diff configuration object */
1387 int bFromIsDir = 0; /* True if zFrom is a directory name */
1388
1389 isGDiff = g.argv[1][0]=='g';
1390 if( find_option("tk",0,0)!=0
1391 || has_option("tclsh")
1392 || gdiff_using_tk(isGDiff)
1393 ){
1394 diff_tk("diff", 2);
1395 return;
1396 }
1397 zFrom = find_option("from", "r", 1);
1398 zTo = find_option("to", 0, 1);
@@ -1420,19 +1423,10 @@
1423 db_find_and_open_repository(0, 0);
1424 }
1425 }else{
1426 db_find_and_open_repository(0, 0);
1427 }
 
 
 
 
 
 
 
 
 
1428 determine_exec_relative_option(1);
1429 if( zFrom!=file_tail(zFrom)
1430 && file_isdir(zFrom, ExtFILE)==1
1431 && !db_exists("SELECT 1 FROM tag WHERE tagname='sym-%q'", zFrom)
1432 ){
1433
-9
--- src/main.c
+++ src/main.c
@@ -1105,19 +1105,10 @@
11051105
}
11061106
}
11071107
return zReturn;
11081108
}
11091109
1110
-/*
1111
-** Restore an option previously removed by find_option().
1112
-*/
1113
-void restore_option(const char *zName, const char *zValue, int hasOpt){
1114
- if( zValue==0 && hasOpt ) return;
1115
- g.argv[g.argc++] = (char*)zName;
1116
- if( hasOpt ) g.argv[g.argc++] = (char*)zValue;
1117
-}
1118
-
11191110
/* Return true if zOption exists in the command-line arguments,
11201111
** but do not remove it from the list or otherwise process it.
11211112
*/
11221113
int has_option(const char *zOption){
11231114
int i;
11241115
--- src/main.c
+++ src/main.c
@@ -1105,19 +1105,10 @@
1105 }
1106 }
1107 return zReturn;
1108 }
1109
1110 /*
1111 ** Restore an option previously removed by find_option().
1112 */
1113 void restore_option(const char *zName, const char *zValue, int hasOpt){
1114 if( zValue==0 && hasOpt ) return;
1115 g.argv[g.argc++] = (char*)zName;
1116 if( hasOpt ) g.argv[g.argc++] = (char*)zValue;
1117 }
1118
1119 /* Return true if zOption exists in the command-line arguments,
1120 ** but do not remove it from the list or otherwise process it.
1121 */
1122 int has_option(const char *zOption){
1123 int i;
1124
--- src/main.c
+++ src/main.c
@@ -1105,19 +1105,10 @@
1105 }
1106 }
1107 return zReturn;
1108 }
1109
 
 
 
 
 
 
 
 
 
1110 /* Return true if zOption exists in the command-line arguments,
1111 ** but do not remove it from the list or otherwise process it.
1112 */
1113 int has_option(const char *zOption){
1114 int i;
1115

Keyboard Shortcuts

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