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.

drh 2010-12-08 21:00 trunk
Commit e154a4386b660f3c329bd3d73077636e4e3f72de
+13 -2
--- src/checkin.c
+++ src/checkin.c
@@ -102,18 +102,24 @@
102102
**
103103
** Usage: %fossil changes
104104
**
105105
** Report on the edit status of all files in the current checkout.
106106
** 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.
107112
*/
108113
void changes_cmd(void){
109114
Blob report;
110115
int vid;
116
+ int useSha1sum = find_option("sha1sum", 0, 0)!=0;
111117
db_must_be_within_tree();
112118
blob_zero(&report);
113119
vid = db_lget_int("checkout", 0);
114
- vfile_check_signature(vid, 0);
120
+ vfile_check_signature(vid, 0, useSha1sum);
115121
status_report(&report, "", 0);
116122
blob_write_to_file(&report, "-");
117123
}
118124
119125
/*
@@ -120,10 +126,15 @@
120126
** COMMAND: status
121127
**
122128
** Usage: %fossil status
123129
**
124130
** 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.
125136
*/
126137
void status_cmd(void){
127138
int vid;
128139
db_must_be_within_tree();
129140
/* 012345678901234 */
@@ -151,11 +162,11 @@
151162
int isBrief;
152163
153164
isBrief = find_option("l","l", 0)==0;
154165
db_must_be_within_tree();
155166
vid = db_lget_int("checkout", 0);
156
- vfile_check_signature(vid, 0);
167
+ vfile_check_signature(vid, 0, 0);
157168
db_prepare(&q,
158169
"SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)"
159170
" FROM vfile"
160171
" ORDER BY 1"
161172
);
162173
--- 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 @@
3333
int unsaved_changes(void){
3434
int vid;
3535
db_must_be_within_tree();
3636
vid = db_lget_int("checkout",0);
3737
if( vid==0 ) return 2;
38
- vfile_check_signature(vid, 1);
38
+ vfile_check_signature(vid, 1, 0);
3939
return db_exists("SELECT 1 FROM vfile WHERE chnged"
4040
" OR coalesce(origname!=pathname,0)");
4141
}
4242
4343
/*
4444
--- 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 @@
186186
int asNewFile; /* Treat non-existant files as empty files */
187187
188188
ignoreEolWs = (diffFlags & DIFF_NOEOLWS)!=0;
189189
asNewFile = (diffFlags & DIFF_NEWFILE)!=0;
190190
vid = db_lget_int("checkout", 0);
191
- vfile_check_signature(vid, 1);
191
+ vfile_check_signature(vid, 1, 0);
192192
blob_zero(&sql);
193193
db_begin_transaction();
194194
if( zFrom ){
195195
int rid = name_to_rid(zFrom);
196196
if( !is_a_version(rid) ){
197197
--- 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 @@
4646
db_must_be_within_tree();
4747
vid = db_lget_int("checkout", 0);
4848
if( vid==0 ){
4949
fossil_panic("no checkout to finfo files in");
5050
}
51
- vfile_check_signature(vid, 1);
51
+ vfile_check_signature(vid, 1, 0);
5252
if (find_option("status","s",0)) {
5353
Stmt q;
5454
Blob line;
5555
Blob fname;
5656
5757
--- 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 @@
108108
}
109109
}
110110
if( !is_a_version(pid) ){
111111
fossil_fatal("not a version: record #%d", pid);
112112
}
113
- vfile_check_signature(vid, 1);
113
+ vfile_check_signature(vid, 1, 0);
114114
db_begin_transaction();
115115
undo_begin();
116116
load_vfile_from_rid(mid);
117117
load_vfile_from_rid(pid);
118118
119119
--- 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 @@
116116
" ORDER BY event.mtime DESC");
117117
}
118118
119119
if( !verboseFlag && (tid==vid)) return; /* Nothing to update */
120120
db_begin_transaction();
121
- vfile_check_signature(vid, 1);
121
+ vfile_check_signature(vid, 1, 0);
122122
if( !nochangeFlag ) undo_begin();
123123
load_vfile_from_rid(tid);
124124
125125
/*
126126
** The record.fn field is used to match files against each other. The
@@ -405,11 +405,11 @@
405405
blob_reset(&fname);
406406
}
407407
}else{
408408
int vid;
409409
vid = db_lget_int("checkout", 0);
410
- vfile_check_signature(vid, 0);
410
+ vfile_check_signature(vid, 0, 0);
411411
db_multi_exec(
412412
"DELETE FROM vmerge;"
413413
"INSERT INTO torevert "
414414
"SELECT pathname"
415415
" FROM vfile "
416416
--- 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 @@
136136
** that has changed.
137137
**
138138
** If VFILE.DELETED is null or if VFILE.RID is zero, then we can assume
139139
** the file has changed without having the check the on-disk image.
140140
*/
141
-void vfile_check_signature(int vid, int notFileIsFatal){
141
+void vfile_check_signature(int vid, int notFileIsFatal, int useSha1sum){
142142
int nErr = 0;
143143
Stmt q;
144144
Blob fileCksum, origCksum;
145
- int checkMtime = db_get_boolean("mtime-changes", 1);
145
+ int checkMtime = useSha1sum==0 && db_get_boolean("mtime-changes", 1);
146146
147147
db_begin_transaction();
148148
db_prepare(&q, "SELECT id, %Q || pathname,"
149149
" vfile.mrid, deleted, chnged, uuid, mtime"
150150
" FROM vfile LEFT JOIN blob ON vfile.mrid=blob.rid"
151151
--- 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

Keyboard Shortcuts

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