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].
Commit
f3c2b9a29e540d1102ecc10fdc77b64fdd1c9c19c9f6ce5b5c271fe4ecf1da79
Parent
84ced252d972b74…
2 files changed
+4
-10
-9
+4
-10
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -1385,11 +1385,14 @@ | ||
| 1385 | 1385 | FileDirList *pFileDir = 0; /* Restrict the diff to these files */ |
| 1386 | 1386 | DiffConfig DCfg; /* Diff configuration object */ |
| 1387 | 1387 | int bFromIsDir = 0; /* True if zFrom is a directory name */ |
| 1388 | 1388 | |
| 1389 | 1389 | 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 | + ){ | |
| 1391 | 1394 | diff_tk("diff", 2); |
| 1392 | 1395 | return; |
| 1393 | 1396 | } |
| 1394 | 1397 | zFrom = find_option("from", "r", 1); |
| 1395 | 1398 | zTo = find_option("to", 0, 1); |
| @@ -1420,19 +1423,10 @@ | ||
| 1420 | 1423 | db_find_and_open_repository(0, 0); |
| 1421 | 1424 | } |
| 1422 | 1425 | }else{ |
| 1423 | 1426 | db_find_and_open_repository(0, 0); |
| 1424 | 1427 | } |
| 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 | 1428 | determine_exec_relative_option(1); |
| 1435 | 1429 | if( zFrom!=file_tail(zFrom) |
| 1436 | 1430 | && file_isdir(zFrom, ExtFILE)==1 |
| 1437 | 1431 | && !db_exists("SELECT 1 FROM tag WHERE tagname='sym-%q'", zFrom) |
| 1438 | 1432 | ){ |
| 1439 | 1433 |
| --- 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 @@ | ||
| 1105 | 1105 | } |
| 1106 | 1106 | } |
| 1107 | 1107 | return zReturn; |
| 1108 | 1108 | } |
| 1109 | 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 | 1110 | /* Return true if zOption exists in the command-line arguments, |
| 1120 | 1111 | ** but do not remove it from the list or otherwise process it. |
| 1121 | 1112 | */ |
| 1122 | 1113 | int has_option(const char *zOption){ |
| 1123 | 1114 | int i; |
| 1124 | 1115 |
| --- 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 |