Fossil SCM
Add the --sha1sum option to the "status" and "changes" commands to force a detailed (but slow) SHA1 checksum verification that files have not changed.
Commit
e154a4386b660f3c329bd3d73077636e4e3f72de
Parent
000af3234f32afd…
7 files changed
+13
-2
+1
-1
+1
-1
+1
-1
+1
-1
+2
-2
+2
-2
+13
-2
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -102,18 +102,24 @@ | ||
| 102 | 102 | ** |
| 103 | 103 | ** Usage: %fossil changes |
| 104 | 104 | ** |
| 105 | 105 | ** Report on the edit status of all files in the current checkout. |
| 106 | 106 | ** See also the "status" and "extra" commands. |
| 107 | +** | |
| 108 | +** Options: | |
| 109 | +** | |
| 110 | +** --sha1sum Verify file status using SHA1 hashing rather | |
| 111 | +** than relying on file mtimes. | |
| 107 | 112 | */ |
| 108 | 113 | void changes_cmd(void){ |
| 109 | 114 | Blob report; |
| 110 | 115 | int vid; |
| 116 | + int useSha1sum = find_option("sha1sum", 0, 0)!=0; | |
| 111 | 117 | db_must_be_within_tree(); |
| 112 | 118 | blob_zero(&report); |
| 113 | 119 | vid = db_lget_int("checkout", 0); |
| 114 | - vfile_check_signature(vid, 0); | |
| 120 | + vfile_check_signature(vid, 0, useSha1sum); | |
| 115 | 121 | status_report(&report, "", 0); |
| 116 | 122 | blob_write_to_file(&report, "-"); |
| 117 | 123 | } |
| 118 | 124 | |
| 119 | 125 | /* |
| @@ -120,10 +126,15 @@ | ||
| 120 | 126 | ** COMMAND: status |
| 121 | 127 | ** |
| 122 | 128 | ** Usage: %fossil status |
| 123 | 129 | ** |
| 124 | 130 | ** Report on the status of the current checkout. |
| 131 | +** | |
| 132 | +** Options: | |
| 133 | +** | |
| 134 | +** --sha1sum Verify file status using SHA1 hashing rather | |
| 135 | +** than relying on file mtimes. | |
| 125 | 136 | */ |
| 126 | 137 | void status_cmd(void){ |
| 127 | 138 | int vid; |
| 128 | 139 | db_must_be_within_tree(); |
| 129 | 140 | /* 012345678901234 */ |
| @@ -151,11 +162,11 @@ | ||
| 151 | 162 | int isBrief; |
| 152 | 163 | |
| 153 | 164 | isBrief = find_option("l","l", 0)==0; |
| 154 | 165 | db_must_be_within_tree(); |
| 155 | 166 | vid = db_lget_int("checkout", 0); |
| 156 | - vfile_check_signature(vid, 0); | |
| 167 | + vfile_check_signature(vid, 0, 0); | |
| 157 | 168 | db_prepare(&q, |
| 158 | 169 | "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)" |
| 159 | 170 | " FROM vfile" |
| 160 | 171 | " ORDER BY 1" |
| 161 | 172 | ); |
| 162 | 173 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -102,18 +102,24 @@ | |
| 102 | ** |
| 103 | ** Usage: %fossil changes |
| 104 | ** |
| 105 | ** Report on the edit status of all files in the current checkout. |
| 106 | ** See also the "status" and "extra" commands. |
| 107 | */ |
| 108 | void changes_cmd(void){ |
| 109 | Blob report; |
| 110 | int vid; |
| 111 | db_must_be_within_tree(); |
| 112 | blob_zero(&report); |
| 113 | vid = db_lget_int("checkout", 0); |
| 114 | vfile_check_signature(vid, 0); |
| 115 | status_report(&report, "", 0); |
| 116 | blob_write_to_file(&report, "-"); |
| 117 | } |
| 118 | |
| 119 | /* |
| @@ -120,10 +126,15 @@ | |
| 120 | ** COMMAND: status |
| 121 | ** |
| 122 | ** Usage: %fossil status |
| 123 | ** |
| 124 | ** Report on the status of the current checkout. |
| 125 | */ |
| 126 | void status_cmd(void){ |
| 127 | int vid; |
| 128 | db_must_be_within_tree(); |
| 129 | /* 012345678901234 */ |
| @@ -151,11 +162,11 @@ | |
| 151 | int isBrief; |
| 152 | |
| 153 | isBrief = find_option("l","l", 0)==0; |
| 154 | db_must_be_within_tree(); |
| 155 | vid = db_lget_int("checkout", 0); |
| 156 | vfile_check_signature(vid, 0); |
| 157 | db_prepare(&q, |
| 158 | "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)" |
| 159 | " FROM vfile" |
| 160 | " ORDER BY 1" |
| 161 | ); |
| 162 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -102,18 +102,24 @@ | |
| 102 | ** |
| 103 | ** Usage: %fossil changes |
| 104 | ** |
| 105 | ** Report on the edit status of all files in the current checkout. |
| 106 | ** See also the "status" and "extra" commands. |
| 107 | ** |
| 108 | ** Options: |
| 109 | ** |
| 110 | ** --sha1sum Verify file status using SHA1 hashing rather |
| 111 | ** than relying on file mtimes. |
| 112 | */ |
| 113 | void changes_cmd(void){ |
| 114 | Blob report; |
| 115 | int vid; |
| 116 | int useSha1sum = find_option("sha1sum", 0, 0)!=0; |
| 117 | db_must_be_within_tree(); |
| 118 | blob_zero(&report); |
| 119 | vid = db_lget_int("checkout", 0); |
| 120 | vfile_check_signature(vid, 0, useSha1sum); |
| 121 | status_report(&report, "", 0); |
| 122 | blob_write_to_file(&report, "-"); |
| 123 | } |
| 124 | |
| 125 | /* |
| @@ -120,10 +126,15 @@ | |
| 126 | ** COMMAND: status |
| 127 | ** |
| 128 | ** Usage: %fossil status |
| 129 | ** |
| 130 | ** Report on the status of the current checkout. |
| 131 | ** |
| 132 | ** Options: |
| 133 | ** |
| 134 | ** --sha1sum Verify file status using SHA1 hashing rather |
| 135 | ** than relying on file mtimes. |
| 136 | */ |
| 137 | void status_cmd(void){ |
| 138 | int vid; |
| 139 | db_must_be_within_tree(); |
| 140 | /* 012345678901234 */ |
| @@ -151,11 +162,11 @@ | |
| 162 | int isBrief; |
| 163 | |
| 164 | isBrief = find_option("l","l", 0)==0; |
| 165 | db_must_be_within_tree(); |
| 166 | vid = db_lget_int("checkout", 0); |
| 167 | vfile_check_signature(vid, 0, 0); |
| 168 | db_prepare(&q, |
| 169 | "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)" |
| 170 | " FROM vfile" |
| 171 | " ORDER BY 1" |
| 172 | ); |
| 173 |
+1
-1
| --- src/checkout.c | ||
| +++ src/checkout.c | ||
| @@ -33,11 +33,11 @@ | ||
| 33 | 33 | int unsaved_changes(void){ |
| 34 | 34 | int vid; |
| 35 | 35 | db_must_be_within_tree(); |
| 36 | 36 | vid = db_lget_int("checkout",0); |
| 37 | 37 | if( vid==0 ) return 2; |
| 38 | - vfile_check_signature(vid, 1); | |
| 38 | + vfile_check_signature(vid, 1, 0); | |
| 39 | 39 | return db_exists("SELECT 1 FROM vfile WHERE chnged" |
| 40 | 40 | " OR coalesce(origname!=pathname,0)"); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /* |
| 44 | 44 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -33,11 +33,11 @@ | |
| 33 | int unsaved_changes(void){ |
| 34 | int vid; |
| 35 | db_must_be_within_tree(); |
| 36 | vid = db_lget_int("checkout",0); |
| 37 | if( vid==0 ) return 2; |
| 38 | vfile_check_signature(vid, 1); |
| 39 | return db_exists("SELECT 1 FROM vfile WHERE chnged" |
| 40 | " OR coalesce(origname!=pathname,0)"); |
| 41 | } |
| 42 | |
| 43 | /* |
| 44 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -33,11 +33,11 @@ | |
| 33 | int unsaved_changes(void){ |
| 34 | int vid; |
| 35 | db_must_be_within_tree(); |
| 36 | vid = db_lget_int("checkout",0); |
| 37 | if( vid==0 ) return 2; |
| 38 | vfile_check_signature(vid, 1, 0); |
| 39 | return db_exists("SELECT 1 FROM vfile WHERE chnged" |
| 40 | " OR coalesce(origname!=pathname,0)"); |
| 41 | } |
| 42 | |
| 43 | /* |
| 44 |
+1
-1
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -186,11 +186,11 @@ | ||
| 186 | 186 | int asNewFile; /* Treat non-existant files as empty files */ |
| 187 | 187 | |
| 188 | 188 | ignoreEolWs = (diffFlags & DIFF_NOEOLWS)!=0; |
| 189 | 189 | asNewFile = (diffFlags & DIFF_NEWFILE)!=0; |
| 190 | 190 | vid = db_lget_int("checkout", 0); |
| 191 | - vfile_check_signature(vid, 1); | |
| 191 | + vfile_check_signature(vid, 1, 0); | |
| 192 | 192 | blob_zero(&sql); |
| 193 | 193 | db_begin_transaction(); |
| 194 | 194 | if( zFrom ){ |
| 195 | 195 | int rid = name_to_rid(zFrom); |
| 196 | 196 | if( !is_a_version(rid) ){ |
| 197 | 197 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -186,11 +186,11 @@ | |
| 186 | int asNewFile; /* Treat non-existant files as empty files */ |
| 187 | |
| 188 | ignoreEolWs = (diffFlags & DIFF_NOEOLWS)!=0; |
| 189 | asNewFile = (diffFlags & DIFF_NEWFILE)!=0; |
| 190 | vid = db_lget_int("checkout", 0); |
| 191 | vfile_check_signature(vid, 1); |
| 192 | blob_zero(&sql); |
| 193 | db_begin_transaction(); |
| 194 | if( zFrom ){ |
| 195 | int rid = name_to_rid(zFrom); |
| 196 | if( !is_a_version(rid) ){ |
| 197 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -186,11 +186,11 @@ | |
| 186 | int asNewFile; /* Treat non-existant files as empty files */ |
| 187 | |
| 188 | ignoreEolWs = (diffFlags & DIFF_NOEOLWS)!=0; |
| 189 | asNewFile = (diffFlags & DIFF_NEWFILE)!=0; |
| 190 | vid = db_lget_int("checkout", 0); |
| 191 | vfile_check_signature(vid, 1, 0); |
| 192 | blob_zero(&sql); |
| 193 | db_begin_transaction(); |
| 194 | if( zFrom ){ |
| 195 | int rid = name_to_rid(zFrom); |
| 196 | if( !is_a_version(rid) ){ |
| 197 |
+1
-1
| --- src/finfo.c | ||
| +++ src/finfo.c | ||
| @@ -46,11 +46,11 @@ | ||
| 46 | 46 | db_must_be_within_tree(); |
| 47 | 47 | vid = db_lget_int("checkout", 0); |
| 48 | 48 | if( vid==0 ){ |
| 49 | 49 | fossil_panic("no checkout to finfo files in"); |
| 50 | 50 | } |
| 51 | - vfile_check_signature(vid, 1); | |
| 51 | + vfile_check_signature(vid, 1, 0); | |
| 52 | 52 | if (find_option("status","s",0)) { |
| 53 | 53 | Stmt q; |
| 54 | 54 | Blob line; |
| 55 | 55 | Blob fname; |
| 56 | 56 | |
| 57 | 57 |
| --- src/finfo.c | |
| +++ src/finfo.c | |
| @@ -46,11 +46,11 @@ | |
| 46 | db_must_be_within_tree(); |
| 47 | vid = db_lget_int("checkout", 0); |
| 48 | if( vid==0 ){ |
| 49 | fossil_panic("no checkout to finfo files in"); |
| 50 | } |
| 51 | vfile_check_signature(vid, 1); |
| 52 | if (find_option("status","s",0)) { |
| 53 | Stmt q; |
| 54 | Blob line; |
| 55 | Blob fname; |
| 56 | |
| 57 |
| --- src/finfo.c | |
| +++ src/finfo.c | |
| @@ -46,11 +46,11 @@ | |
| 46 | db_must_be_within_tree(); |
| 47 | vid = db_lget_int("checkout", 0); |
| 48 | if( vid==0 ){ |
| 49 | fossil_panic("no checkout to finfo files in"); |
| 50 | } |
| 51 | vfile_check_signature(vid, 1, 0); |
| 52 | if (find_option("status","s",0)) { |
| 53 | Stmt q; |
| 54 | Blob line; |
| 55 | Blob fname; |
| 56 | |
| 57 |
+1
-1
| --- src/merge.c | ||
| +++ src/merge.c | ||
| @@ -108,11 +108,11 @@ | ||
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | if( !is_a_version(pid) ){ |
| 111 | 111 | fossil_fatal("not a version: record #%d", pid); |
| 112 | 112 | } |
| 113 | - vfile_check_signature(vid, 1); | |
| 113 | + vfile_check_signature(vid, 1, 0); | |
| 114 | 114 | db_begin_transaction(); |
| 115 | 115 | undo_begin(); |
| 116 | 116 | load_vfile_from_rid(mid); |
| 117 | 117 | load_vfile_from_rid(pid); |
| 118 | 118 | |
| 119 | 119 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -108,11 +108,11 @@ | |
| 108 | } |
| 109 | } |
| 110 | if( !is_a_version(pid) ){ |
| 111 | fossil_fatal("not a version: record #%d", pid); |
| 112 | } |
| 113 | vfile_check_signature(vid, 1); |
| 114 | db_begin_transaction(); |
| 115 | undo_begin(); |
| 116 | load_vfile_from_rid(mid); |
| 117 | load_vfile_from_rid(pid); |
| 118 | |
| 119 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -108,11 +108,11 @@ | |
| 108 | } |
| 109 | } |
| 110 | if( !is_a_version(pid) ){ |
| 111 | fossil_fatal("not a version: record #%d", pid); |
| 112 | } |
| 113 | vfile_check_signature(vid, 1, 0); |
| 114 | db_begin_transaction(); |
| 115 | undo_begin(); |
| 116 | load_vfile_from_rid(mid); |
| 117 | load_vfile_from_rid(pid); |
| 118 | |
| 119 |
+2
-2
| --- src/update.c | ||
| +++ src/update.c | ||
| @@ -116,11 +116,11 @@ | ||
| 116 | 116 | " ORDER BY event.mtime DESC"); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | if( !verboseFlag && (tid==vid)) return; /* Nothing to update */ |
| 120 | 120 | db_begin_transaction(); |
| 121 | - vfile_check_signature(vid, 1); | |
| 121 | + vfile_check_signature(vid, 1, 0); | |
| 122 | 122 | if( !nochangeFlag ) undo_begin(); |
| 123 | 123 | load_vfile_from_rid(tid); |
| 124 | 124 | |
| 125 | 125 | /* |
| 126 | 126 | ** The record.fn field is used to match files against each other. The |
| @@ -405,11 +405,11 @@ | ||
| 405 | 405 | blob_reset(&fname); |
| 406 | 406 | } |
| 407 | 407 | }else{ |
| 408 | 408 | int vid; |
| 409 | 409 | vid = db_lget_int("checkout", 0); |
| 410 | - vfile_check_signature(vid, 0); | |
| 410 | + vfile_check_signature(vid, 0, 0); | |
| 411 | 411 | db_multi_exec( |
| 412 | 412 | "DELETE FROM vmerge;" |
| 413 | 413 | "INSERT INTO torevert " |
| 414 | 414 | "SELECT pathname" |
| 415 | 415 | " FROM vfile " |
| 416 | 416 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -116,11 +116,11 @@ | |
| 116 | " ORDER BY event.mtime DESC"); |
| 117 | } |
| 118 | |
| 119 | if( !verboseFlag && (tid==vid)) return; /* Nothing to update */ |
| 120 | db_begin_transaction(); |
| 121 | vfile_check_signature(vid, 1); |
| 122 | if( !nochangeFlag ) undo_begin(); |
| 123 | load_vfile_from_rid(tid); |
| 124 | |
| 125 | /* |
| 126 | ** The record.fn field is used to match files against each other. The |
| @@ -405,11 +405,11 @@ | |
| 405 | blob_reset(&fname); |
| 406 | } |
| 407 | }else{ |
| 408 | int vid; |
| 409 | vid = db_lget_int("checkout", 0); |
| 410 | vfile_check_signature(vid, 0); |
| 411 | db_multi_exec( |
| 412 | "DELETE FROM vmerge;" |
| 413 | "INSERT INTO torevert " |
| 414 | "SELECT pathname" |
| 415 | " FROM vfile " |
| 416 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -116,11 +116,11 @@ | |
| 116 | " ORDER BY event.mtime DESC"); |
| 117 | } |
| 118 | |
| 119 | if( !verboseFlag && (tid==vid)) return; /* Nothing to update */ |
| 120 | db_begin_transaction(); |
| 121 | vfile_check_signature(vid, 1, 0); |
| 122 | if( !nochangeFlag ) undo_begin(); |
| 123 | load_vfile_from_rid(tid); |
| 124 | |
| 125 | /* |
| 126 | ** The record.fn field is used to match files against each other. The |
| @@ -405,11 +405,11 @@ | |
| 405 | blob_reset(&fname); |
| 406 | } |
| 407 | }else{ |
| 408 | int vid; |
| 409 | vid = db_lget_int("checkout", 0); |
| 410 | vfile_check_signature(vid, 0, 0); |
| 411 | db_multi_exec( |
| 412 | "DELETE FROM vmerge;" |
| 413 | "INSERT INTO torevert " |
| 414 | "SELECT pathname" |
| 415 | " FROM vfile " |
| 416 |
+2
-2
| --- src/vfile.c | ||
| +++ src/vfile.c | ||
| @@ -136,15 +136,15 @@ | ||
| 136 | 136 | ** that has changed. |
| 137 | 137 | ** |
| 138 | 138 | ** If VFILE.DELETED is null or if VFILE.RID is zero, then we can assume |
| 139 | 139 | ** the file has changed without having the check the on-disk image. |
| 140 | 140 | */ |
| 141 | -void vfile_check_signature(int vid, int notFileIsFatal){ | |
| 141 | +void vfile_check_signature(int vid, int notFileIsFatal, int useSha1sum){ | |
| 142 | 142 | int nErr = 0; |
| 143 | 143 | Stmt q; |
| 144 | 144 | Blob fileCksum, origCksum; |
| 145 | - int checkMtime = db_get_boolean("mtime-changes", 1); | |
| 145 | + int checkMtime = useSha1sum==0 && db_get_boolean("mtime-changes", 1); | |
| 146 | 146 | |
| 147 | 147 | db_begin_transaction(); |
| 148 | 148 | db_prepare(&q, "SELECT id, %Q || pathname," |
| 149 | 149 | " vfile.mrid, deleted, chnged, uuid, mtime" |
| 150 | 150 | " FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid" |
| 151 | 151 |
| --- src/vfile.c | |
| +++ src/vfile.c | |
| @@ -136,15 +136,15 @@ | |
| 136 | ** that has changed. |
| 137 | ** |
| 138 | ** If VFILE.DELETED is null or if VFILE.RID is zero, then we can assume |
| 139 | ** the file has changed without having the check the on-disk image. |
| 140 | */ |
| 141 | void vfile_check_signature(int vid, int notFileIsFatal){ |
| 142 | int nErr = 0; |
| 143 | Stmt q; |
| 144 | Blob fileCksum, origCksum; |
| 145 | int checkMtime = db_get_boolean("mtime-changes", 1); |
| 146 | |
| 147 | db_begin_transaction(); |
| 148 | db_prepare(&q, "SELECT id, %Q || pathname," |
| 149 | " vfile.mrid, deleted, chnged, uuid, mtime" |
| 150 | " FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid" |
| 151 |
| --- src/vfile.c | |
| +++ src/vfile.c | |
| @@ -136,15 +136,15 @@ | |
| 136 | ** that has changed. |
| 137 | ** |
| 138 | ** If VFILE.DELETED is null or if VFILE.RID is zero, then we can assume |
| 139 | ** the file has changed without having the check the on-disk image. |
| 140 | */ |
| 141 | void vfile_check_signature(int vid, int notFileIsFatal, int useSha1sum){ |
| 142 | int nErr = 0; |
| 143 | Stmt q; |
| 144 | Blob fileCksum, origCksum; |
| 145 | int checkMtime = useSha1sum==0 && db_get_boolean("mtime-changes", 1); |
| 146 | |
| 147 | db_begin_transaction(); |
| 148 | db_prepare(&q, "SELECT id, %Q || pathname," |
| 149 | " vfile.mrid, deleted, chnged, uuid, mtime" |
| 150 | " FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid" |
| 151 |