Fossil SCM
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
Commit
01ce2cf3dc8949a16646fecaa3f48bd353fe12d7
Parent
c82fb6177511032…
2 files changed
+28
-14
+2
-2
+28
-14
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -42,49 +42,63 @@ | ||
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /* |
| 46 | 46 | ** COMMAND: diff |
| 47 | +** COMMAND: gdiff | |
| 47 | 48 | ** |
| 48 | -** Usage: %fossil diff ?-i FILE... | |
| 49 | +** Usage: %fossil diff|gdiff ?-i FILE... | |
| 49 | 50 | ** |
| 50 | 51 | ** Show the difference between the current version of a file (as it |
| 51 | 52 | ** exists on disk) and that same file as it was checked out. |
| 52 | -** If -i is supplied, the internal diff command will be executed | |
| 53 | -** otherwise, fossil attempts to use the user configured diff-command. | |
| 53 | +** | |
| 54 | +** diff will show a textual diff while gdiff will attempt to run a | |
| 55 | +** graphical diff command that you have setup. If the choosen command | |
| 56 | +** is not yet configured, the internal textual diff command will be | |
| 57 | +** used. | |
| 58 | +** | |
| 59 | +** If -i is supplied for either diff or gdiff, the internal textual | |
| 60 | +** diff command will be executed. | |
| 54 | 61 | ** |
| 55 | 62 | ** Here are a few external diff command settings, for example: |
| 56 | 63 | ** |
| 57 | -** %fossil config diff-command=tkdiff | |
| 58 | -** %fossil config diff-command=eskill22 | |
| 59 | -** %fossil config diff-command=tortoisemerge | |
| 60 | -** %fossil config diff-command=meld | |
| 61 | -** %fossil config diff-command=xxdiff | |
| 62 | -** %fossil config diff-command=kdiff3 | |
| 64 | +** %fossil config diff-command=diff | |
| 65 | +** | |
| 66 | +** %fossil config gdiff-command=tkdiff | |
| 67 | +** %fossil config gdiff-command=eskill22 | |
| 68 | +** %fossil config gdiff-command=tortoisemerge | |
| 69 | +** %fossil config gdiff-command=meld | |
| 70 | +** %fossil config gdiff-command=xxdiff | |
| 71 | +** %fossil config gdiff-command=kdiff3 | |
| 63 | 72 | */ |
| 64 | 73 | void diff_cmd(void){ |
| 65 | 74 | const char *zFile; |
| 66 | 75 | Blob cmd; |
| 67 | 76 | Blob fname; |
| 68 | 77 | int i, internalDiff; |
| 69 | 78 | char *zV1 = 0; |
| 70 | 79 | char *zV2 = 0; |
| 71 | 80 | |
| 72 | - internalDiff = find_option("intertal","i",0)!=0; | |
| 81 | + internalDiff = find_option("internal","i",0)!=0; | |
| 73 | 82 | |
| 74 | 83 | if( g.argc<3 ){ |
| 75 | 84 | usage("?OPTIONS? FILE"); |
| 76 | 85 | } |
| 77 | 86 | db_must_be_within_tree(); |
| 78 | 87 | |
| 79 | 88 | if( internalDiff==0 ){ |
| 80 | - const char *zExternalCommand = db_global_get("diff-command", 0); | |
| 89 | + const char *zExternalCommand; | |
| 90 | + if( strcmp(g.argv[1], "diff")==0 ){ | |
| 91 | + zExternalCommand = db_global_get("diff-command", 0); | |
| 92 | + }else{ | |
| 93 | + zExternalCommand = db_global_get("gdiff-command", 0); | |
| 94 | + } | |
| 81 | 95 | if( zExternalCommand==0 ){ |
| 82 | 96 | internalDiff=1; |
| 83 | 97 | } |
| 84 | - blob_zero(&cmd); | |
| 85 | - blob_appendf(&cmd, "%s ", zExternalCommand); | |
| 98 | + blob_zero(&cmd); | |
| 99 | + blob_appendf(&cmd, "%s ", zExternalCommand); | |
| 86 | 100 | } |
| 87 | 101 | for(i=2; i<g.argc-1; i++){ |
| 88 | 102 | const char *z = g.argv[i]; |
| 89 | 103 | if( (strcmp(z,"-v")==0 || strcmp(z,"--version")==0) && i<g.argc-2 ){ |
| 90 | 104 | if( zV1==0 ){ |
| @@ -123,11 +137,11 @@ | ||
| 123 | 137 | Blob current; |
| 124 | 138 | Blob out; |
| 125 | 139 | blob_zero(¤t); |
| 126 | 140 | blob_read_from_file(¤t, zFile); |
| 127 | 141 | blob_zero(&out); |
| 128 | - unified_diff(¤t, &record, 5, &out); | |
| 142 | + unified_diff(&record, ¤t, 5, &out); | |
| 129 | 143 | printf("%s\n", blob_str(&out)); |
| 130 | 144 | blob_reset(¤t); |
| 131 | 145 | blob_reset(&out); |
| 132 | 146 | }else{ |
| 133 | 147 | blob_write_to_file(&record, blob_str(&vname)); |
| 134 | 148 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -42,49 +42,63 @@ | |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | /* |
| 46 | ** COMMAND: diff |
| 47 | ** |
| 48 | ** Usage: %fossil diff ?-i FILE... |
| 49 | ** |
| 50 | ** Show the difference between the current version of a file (as it |
| 51 | ** exists on disk) and that same file as it was checked out. |
| 52 | ** If -i is supplied, the internal diff command will be executed |
| 53 | ** otherwise, fossil attempts to use the user configured diff-command. |
| 54 | ** |
| 55 | ** Here are a few external diff command settings, for example: |
| 56 | ** |
| 57 | ** %fossil config diff-command=tkdiff |
| 58 | ** %fossil config diff-command=eskill22 |
| 59 | ** %fossil config diff-command=tortoisemerge |
| 60 | ** %fossil config diff-command=meld |
| 61 | ** %fossil config diff-command=xxdiff |
| 62 | ** %fossil config diff-command=kdiff3 |
| 63 | */ |
| 64 | void diff_cmd(void){ |
| 65 | const char *zFile; |
| 66 | Blob cmd; |
| 67 | Blob fname; |
| 68 | int i, internalDiff; |
| 69 | char *zV1 = 0; |
| 70 | char *zV2 = 0; |
| 71 | |
| 72 | internalDiff = find_option("intertal","i",0)!=0; |
| 73 | |
| 74 | if( g.argc<3 ){ |
| 75 | usage("?OPTIONS? FILE"); |
| 76 | } |
| 77 | db_must_be_within_tree(); |
| 78 | |
| 79 | if( internalDiff==0 ){ |
| 80 | const char *zExternalCommand = db_global_get("diff-command", 0); |
| 81 | if( zExternalCommand==0 ){ |
| 82 | internalDiff=1; |
| 83 | } |
| 84 | blob_zero(&cmd); |
| 85 | blob_appendf(&cmd, "%s ", zExternalCommand); |
| 86 | } |
| 87 | for(i=2; i<g.argc-1; i++){ |
| 88 | const char *z = g.argv[i]; |
| 89 | if( (strcmp(z,"-v")==0 || strcmp(z,"--version")==0) && i<g.argc-2 ){ |
| 90 | if( zV1==0 ){ |
| @@ -123,11 +137,11 @@ | |
| 123 | Blob current; |
| 124 | Blob out; |
| 125 | blob_zero(¤t); |
| 126 | blob_read_from_file(¤t, zFile); |
| 127 | blob_zero(&out); |
| 128 | unified_diff(¤t, &record, 5, &out); |
| 129 | printf("%s\n", blob_str(&out)); |
| 130 | blob_reset(¤t); |
| 131 | blob_reset(&out); |
| 132 | }else{ |
| 133 | blob_write_to_file(&record, blob_str(&vname)); |
| 134 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -42,49 +42,63 @@ | |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | /* |
| 46 | ** COMMAND: diff |
| 47 | ** COMMAND: gdiff |
| 48 | ** |
| 49 | ** Usage: %fossil diff|gdiff ?-i FILE... |
| 50 | ** |
| 51 | ** Show the difference between the current version of a file (as it |
| 52 | ** exists on disk) and that same file as it was checked out. |
| 53 | ** |
| 54 | ** diff will show a textual diff while gdiff will attempt to run a |
| 55 | ** graphical diff command that you have setup. If the choosen command |
| 56 | ** is not yet configured, the internal textual diff command will be |
| 57 | ** used. |
| 58 | ** |
| 59 | ** If -i is supplied for either diff or gdiff, the internal textual |
| 60 | ** diff command will be executed. |
| 61 | ** |
| 62 | ** Here are a few external diff command settings, for example: |
| 63 | ** |
| 64 | ** %fossil config diff-command=diff |
| 65 | ** |
| 66 | ** %fossil config gdiff-command=tkdiff |
| 67 | ** %fossil config gdiff-command=eskill22 |
| 68 | ** %fossil config gdiff-command=tortoisemerge |
| 69 | ** %fossil config gdiff-command=meld |
| 70 | ** %fossil config gdiff-command=xxdiff |
| 71 | ** %fossil config gdiff-command=kdiff3 |
| 72 | */ |
| 73 | void diff_cmd(void){ |
| 74 | const char *zFile; |
| 75 | Blob cmd; |
| 76 | Blob fname; |
| 77 | int i, internalDiff; |
| 78 | char *zV1 = 0; |
| 79 | char *zV2 = 0; |
| 80 | |
| 81 | internalDiff = find_option("internal","i",0)!=0; |
| 82 | |
| 83 | if( g.argc<3 ){ |
| 84 | usage("?OPTIONS? FILE"); |
| 85 | } |
| 86 | db_must_be_within_tree(); |
| 87 | |
| 88 | if( internalDiff==0 ){ |
| 89 | const char *zExternalCommand; |
| 90 | if( strcmp(g.argv[1], "diff")==0 ){ |
| 91 | zExternalCommand = db_global_get("diff-command", 0); |
| 92 | }else{ |
| 93 | zExternalCommand = db_global_get("gdiff-command", 0); |
| 94 | } |
| 95 | if( zExternalCommand==0 ){ |
| 96 | internalDiff=1; |
| 97 | } |
| 98 | blob_zero(&cmd); |
| 99 | blob_appendf(&cmd, "%s ", zExternalCommand); |
| 100 | } |
| 101 | for(i=2; i<g.argc-1; i++){ |
| 102 | const char *z = g.argv[i]; |
| 103 | if( (strcmp(z,"-v")==0 || strcmp(z,"--version")==0) && i<g.argc-2 ){ |
| 104 | if( zV1==0 ){ |
| @@ -123,11 +137,11 @@ | |
| 137 | Blob current; |
| 138 | Blob out; |
| 139 | blob_zero(¤t); |
| 140 | blob_read_from_file(¤t, zFile); |
| 141 | blob_zero(&out); |
| 142 | unified_diff(&record, ¤t, 5, &out); |
| 143 | printf("%s\n", blob_str(&out)); |
| 144 | blob_reset(¤t); |
| 145 | blob_reset(&out); |
| 146 | }else{ |
| 147 | blob_write_to_file(&record, blob_str(&vname)); |
| 148 |
+2
-2
| --- src/style.c | ||
| +++ src/style.c | ||
| @@ -107,12 +107,12 @@ | ||
| 107 | 107 | } |
| 108 | 108 | if( !g.noPswd ){ |
| 109 | 109 | @ | <a href="%s(g.zBaseURL)/login">%s(zLogInOut)</a> |
| 110 | 110 | } |
| 111 | 111 | @ </div> |
| 112 | - @ <div id="sub-menu"> | |
| 113 | 112 | if( nSubmenu>0 ){ |
| 113 | + @ <div id="sub-menu"> | |
| 114 | 114 | int i; |
| 115 | 115 | qsort(aSubmenu, nSubmenu, sizeof(aSubmenu[0]), submenuCompare); |
| 116 | 116 | for(i=0; i<nSubmenu; i++){ |
| 117 | 117 | struct Submenu *p = &aSubmenu[i]; |
| 118 | 118 | char *zTail = i<nSubmenu-1 ? " | " : ""; |
| @@ -122,12 +122,12 @@ | ||
| 122 | 122 | }else{ |
| 123 | 123 | @ <a class="label" href="%T(p->zLink)">%h(p->zLabel)</a> |
| 124 | 124 | @ <span class="tail">%s(zTail)</span> |
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | + @ </div> | |
| 127 | 128 | } |
| 128 | - @ </div> | |
| 129 | 129 | @ <div id="page"> |
| 130 | 130 | g.cgiPanic = 1; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /* |
| 134 | 134 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -107,12 +107,12 @@ | |
| 107 | } |
| 108 | if( !g.noPswd ){ |
| 109 | @ | <a href="%s(g.zBaseURL)/login">%s(zLogInOut)</a> |
| 110 | } |
| 111 | @ </div> |
| 112 | @ <div id="sub-menu"> |
| 113 | if( nSubmenu>0 ){ |
| 114 | int i; |
| 115 | qsort(aSubmenu, nSubmenu, sizeof(aSubmenu[0]), submenuCompare); |
| 116 | for(i=0; i<nSubmenu; i++){ |
| 117 | struct Submenu *p = &aSubmenu[i]; |
| 118 | char *zTail = i<nSubmenu-1 ? " | " : ""; |
| @@ -122,12 +122,12 @@ | |
| 122 | }else{ |
| 123 | @ <a class="label" href="%T(p->zLink)">%h(p->zLabel)</a> |
| 124 | @ <span class="tail">%s(zTail)</span> |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | @ </div> |
| 129 | @ <div id="page"> |
| 130 | g.cgiPanic = 1; |
| 131 | } |
| 132 | |
| 133 | /* |
| 134 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -107,12 +107,12 @@ | |
| 107 | } |
| 108 | if( !g.noPswd ){ |
| 109 | @ | <a href="%s(g.zBaseURL)/login">%s(zLogInOut)</a> |
| 110 | } |
| 111 | @ </div> |
| 112 | if( nSubmenu>0 ){ |
| 113 | @ <div id="sub-menu"> |
| 114 | int i; |
| 115 | qsort(aSubmenu, nSubmenu, sizeof(aSubmenu[0]), submenuCompare); |
| 116 | for(i=0; i<nSubmenu; i++){ |
| 117 | struct Submenu *p = &aSubmenu[i]; |
| 118 | char *zTail = i<nSubmenu-1 ? " | " : ""; |
| @@ -122,12 +122,12 @@ | |
| 122 | }else{ |
| 123 | @ <a class="label" href="%T(p->zLink)">%h(p->zLabel)</a> |
| 124 | @ <span class="tail">%s(zTail)</span> |
| 125 | } |
| 126 | } |
| 127 | @ </div> |
| 128 | } |
| 129 | @ <div id="page"> |
| 130 | g.cgiPanic = 1; |
| 131 | } |
| 132 | |
| 133 | /* |
| 134 |