Fossil SCM

Untested changes trying to get execute permission to be set correctly following "update", "merge", "stash", etc. Ticket [baf9b6b11e08c1d]. This is a big mess and is going to take some time to get right.

drh 2011-02-27 22:22 UTC trunk
Commit 081aefde567b6658e7eb519e38feda0636c9135e
4 files changed +8 -3 +15 -6 +9 -10 +12 -5
+8 -3
--- src/file.c
+++ src/file.c
@@ -178,26 +178,31 @@
178178
fclose(in);
179179
fclose(out);
180180
}
181181
182182
/*
183
-** Set or clear the execute bit on a file.
183
+** Set or clear the execute bit on a file. Return true if a change
184
+** occurred and false if this routine is a no-op.
184185
*/
185
-void file_setexe(const char *zFilename, int onoff){
186
+int file_setexe(const char *zFilename, int onoff){
187
+ int rc = 0;
186188
#if !defined(_WIN32)
187189
struct stat buf;
188
- if( stat(zFilename, &buf)!=0 ) return;
190
+ if( stat(zFilename, &buf)!=0 ) return 0;
189191
if( onoff ){
190192
if( (buf.st_mode & 0111)!=0111 ){
191193
chmod(zFilename, buf.st_mode | 0111);
194
+ rc = 1;
192195
}
193196
}else{
194197
if( (buf.st_mode & 0111)!=0 ){
195198
chmod(zFilename, buf.st_mode & ~0111);
199
+ rc = 1;
196200
}
197201
}
198202
#endif /* _WIN32 */
203
+ return rc;
199204
}
200205
201206
/*
202207
** Create the directory named in the argument, if it does not already
203208
** exist. If forceFlag is 1, delete any prior non-directory object
204209
--- src/file.c
+++ src/file.c
@@ -178,26 +178,31 @@
178 fclose(in);
179 fclose(out);
180 }
181
182 /*
183 ** Set or clear the execute bit on a file.
 
184 */
185 void file_setexe(const char *zFilename, int onoff){
 
186 #if !defined(_WIN32)
187 struct stat buf;
188 if( stat(zFilename, &buf)!=0 ) return;
189 if( onoff ){
190 if( (buf.st_mode & 0111)!=0111 ){
191 chmod(zFilename, buf.st_mode | 0111);
 
192 }
193 }else{
194 if( (buf.st_mode & 0111)!=0 ){
195 chmod(zFilename, buf.st_mode & ~0111);
 
196 }
197 }
198 #endif /* _WIN32 */
 
199 }
200
201 /*
202 ** Create the directory named in the argument, if it does not already
203 ** exist. If forceFlag is 1, delete any prior non-directory object
204
--- src/file.c
+++ src/file.c
@@ -178,26 +178,31 @@
178 fclose(in);
179 fclose(out);
180 }
181
182 /*
183 ** Set or clear the execute bit on a file. Return true if a change
184 ** occurred and false if this routine is a no-op.
185 */
186 int file_setexe(const char *zFilename, int onoff){
187 int rc = 0;
188 #if !defined(_WIN32)
189 struct stat buf;
190 if( stat(zFilename, &buf)!=0 ) return 0;
191 if( onoff ){
192 if( (buf.st_mode & 0111)!=0111 ){
193 chmod(zFilename, buf.st_mode | 0111);
194 rc = 1;
195 }
196 }else{
197 if( (buf.st_mode & 0111)!=0 ){
198 chmod(zFilename, buf.st_mode & ~0111);
199 rc = 1;
200 }
201 }
202 #endif /* _WIN32 */
203 return rc;
204 }
205
206 /*
207 ** Create the directory named in the argument, if it does not already
208 ** exist. If forceFlag is 1, delete any prior non-directory object
209
+15 -6
--- src/undo.c
+++ src/undo.c
@@ -30,27 +30,33 @@
3030
*/
3131
static void undo_one(const char *zPathname, int redoFlag){
3232
Stmt q;
3333
char *zFullname;
3434
db_prepare(&q,
35
- "SELECT content, existsflag FROM undo WHERE pathname=%Q AND redoflag=%d",
35
+ "SELECT content, existsflag, isExe FROM undo"
36
+ " WHERE pathname=%Q AND redoflag=%d",
3637
zPathname, redoFlag
3738
);
3839
if( db_step(&q)==SQLITE_ROW ){
3940
int old_exists;
4041
int new_exists;
42
+ int old_exe;
43
+ int new_exe;
4144
Blob current;
4245
Blob new;
4346
zFullname = mprintf("%s/%s", g.zLocalRoot, zPathname);
4447
new_exists = file_size(zFullname)>=0;
4548
if( new_exists ){
4649
blob_read_from_file(&current, zFullname);
50
+ new_exe = file_isexe(zFullname);
4751
}else{
4852
blob_zero(&current);
53
+ new_exe = 0;
4954
}
5055
blob_zero(&new);
5156
old_exists = db_column_int(&q, 1);
57
+ old_exe = db_column_int(&q, 2);
5258
if( old_exists ){
5359
db_ephemeral_blob(&q, 0, &new);
5460
}
5561
if( old_exists ){
5662
if( new_exists ){
@@ -57,21 +63,23 @@
5763
printf("%s %s\n", redoFlag ? "REDO" : "UNDO", zPathname);
5864
}else{
5965
printf("NEW %s\n", zPathname);
6066
}
6167
blob_write_to_file(&new, zFullname);
68
+ file_setexe(zFullname, old_exe);
6269
}else{
6370
printf("DELETE %s\n", zPathname);
6471
unlink(zFullname);
6572
}
6673
blob_reset(&new);
6774
free(zFullname);
6875
db_finalize(&q);
6976
db_prepare(&q,
70
- "UPDATE undo SET content=:c, existsflag=%d, redoflag=NOT redoflag"
77
+ "UPDATE undo SET content=:c, existsflag=%d, isExe=%d,"
78
+ " redoflag=NOT redoflag"
7179
" WHERE pathname=%Q",
72
- new_exists, zPathname
80
+ new_exists, new_exe, zPathname
7381
);
7482
if( new_exists ){
7583
db_bind_blob(&q, ":c", &current);
7684
}
7785
db_step(&q);
@@ -200,10 +208,11 @@
200208
static const char zSql[] =
201209
@ CREATE TABLE %s.undo(
202210
@ pathname TEXT UNIQUE, -- Name of the file
203211
@ redoflag BOOLEAN, -- 0 for undoable. 1 for redoable
204212
@ existsflag BOOLEAN, -- True if the file exists
213
+ @ isExe BOOLEAN, -- True if the file is executable
205214
@ content BLOB -- Saved content
206215
@ );
207216
@ CREATE TABLE %s.undo_vfile AS SELECT * FROM vfile;
208217
@ CREATE TABLE %s.undo_vmerge AS SELECT * FROM vmerge;
209218
;
@@ -246,13 +255,13 @@
246255
247256
if( !undoActive ) return;
248257
zFullname = mprintf("%s%s", g.zLocalRoot, zPathname);
249258
existsFlag = file_size(zFullname)>=0;
250259
db_prepare(&q,
251
- "INSERT OR IGNORE INTO undo(pathname,redoflag,existsflag,content)"
252
- " VALUES(%Q,0,%d,:c)",
253
- zPathname, existsFlag
260
+ "INSERT OR IGNORE INTO undo(pathname,redoflag,existsflag,isExe,content)"
261
+ " VALUES(%Q,0,%d,%d,:c)",
262
+ zPathname, existsFlag, file_isexe(zFullname)
254263
);
255264
if( existsFlag ){
256265
blob_read_from_file(&content, zFullname);
257266
db_bind_blob(&q, ":c", &content);
258267
}
259268
--- src/undo.c
+++ src/undo.c
@@ -30,27 +30,33 @@
30 */
31 static void undo_one(const char *zPathname, int redoFlag){
32 Stmt q;
33 char *zFullname;
34 db_prepare(&q,
35 "SELECT content, existsflag FROM undo WHERE pathname=%Q AND redoflag=%d",
 
36 zPathname, redoFlag
37 );
38 if( db_step(&q)==SQLITE_ROW ){
39 int old_exists;
40 int new_exists;
 
 
41 Blob current;
42 Blob new;
43 zFullname = mprintf("%s/%s", g.zLocalRoot, zPathname);
44 new_exists = file_size(zFullname)>=0;
45 if( new_exists ){
46 blob_read_from_file(&current, zFullname);
 
47 }else{
48 blob_zero(&current);
 
49 }
50 blob_zero(&new);
51 old_exists = db_column_int(&q, 1);
 
52 if( old_exists ){
53 db_ephemeral_blob(&q, 0, &new);
54 }
55 if( old_exists ){
56 if( new_exists ){
@@ -57,21 +63,23 @@
57 printf("%s %s\n", redoFlag ? "REDO" : "UNDO", zPathname);
58 }else{
59 printf("NEW %s\n", zPathname);
60 }
61 blob_write_to_file(&new, zFullname);
 
62 }else{
63 printf("DELETE %s\n", zPathname);
64 unlink(zFullname);
65 }
66 blob_reset(&new);
67 free(zFullname);
68 db_finalize(&q);
69 db_prepare(&q,
70 "UPDATE undo SET content=:c, existsflag=%d, redoflag=NOT redoflag"
 
71 " WHERE pathname=%Q",
72 new_exists, zPathname
73 );
74 if( new_exists ){
75 db_bind_blob(&q, ":c", &current);
76 }
77 db_step(&q);
@@ -200,10 +208,11 @@
200 static const char zSql[] =
201 @ CREATE TABLE %s.undo(
202 @ pathname TEXT UNIQUE, -- Name of the file
203 @ redoflag BOOLEAN, -- 0 for undoable. 1 for redoable
204 @ existsflag BOOLEAN, -- True if the file exists
 
205 @ content BLOB -- Saved content
206 @ );
207 @ CREATE TABLE %s.undo_vfile AS SELECT * FROM vfile;
208 @ CREATE TABLE %s.undo_vmerge AS SELECT * FROM vmerge;
209 ;
@@ -246,13 +255,13 @@
246
247 if( !undoActive ) return;
248 zFullname = mprintf("%s%s", g.zLocalRoot, zPathname);
249 existsFlag = file_size(zFullname)>=0;
250 db_prepare(&q,
251 "INSERT OR IGNORE INTO undo(pathname,redoflag,existsflag,content)"
252 " VALUES(%Q,0,%d,:c)",
253 zPathname, existsFlag
254 );
255 if( existsFlag ){
256 blob_read_from_file(&content, zFullname);
257 db_bind_blob(&q, ":c", &content);
258 }
259
--- src/undo.c
+++ src/undo.c
@@ -30,27 +30,33 @@
30 */
31 static void undo_one(const char *zPathname, int redoFlag){
32 Stmt q;
33 char *zFullname;
34 db_prepare(&q,
35 "SELECT content, existsflag, isExe FROM undo"
36 " WHERE pathname=%Q AND redoflag=%d",
37 zPathname, redoFlag
38 );
39 if( db_step(&q)==SQLITE_ROW ){
40 int old_exists;
41 int new_exists;
42 int old_exe;
43 int new_exe;
44 Blob current;
45 Blob new;
46 zFullname = mprintf("%s/%s", g.zLocalRoot, zPathname);
47 new_exists = file_size(zFullname)>=0;
48 if( new_exists ){
49 blob_read_from_file(&current, zFullname);
50 new_exe = file_isexe(zFullname);
51 }else{
52 blob_zero(&current);
53 new_exe = 0;
54 }
55 blob_zero(&new);
56 old_exists = db_column_int(&q, 1);
57 old_exe = db_column_int(&q, 2);
58 if( old_exists ){
59 db_ephemeral_blob(&q, 0, &new);
60 }
61 if( old_exists ){
62 if( new_exists ){
@@ -57,21 +63,23 @@
63 printf("%s %s\n", redoFlag ? "REDO" : "UNDO", zPathname);
64 }else{
65 printf("NEW %s\n", zPathname);
66 }
67 blob_write_to_file(&new, zFullname);
68 file_setexe(zFullname, old_exe);
69 }else{
70 printf("DELETE %s\n", zPathname);
71 unlink(zFullname);
72 }
73 blob_reset(&new);
74 free(zFullname);
75 db_finalize(&q);
76 db_prepare(&q,
77 "UPDATE undo SET content=:c, existsflag=%d, isExe=%d,"
78 " redoflag=NOT redoflag"
79 " WHERE pathname=%Q",
80 new_exists, new_exe, zPathname
81 );
82 if( new_exists ){
83 db_bind_blob(&q, ":c", &current);
84 }
85 db_step(&q);
@@ -200,10 +208,11 @@
208 static const char zSql[] =
209 @ CREATE TABLE %s.undo(
210 @ pathname TEXT UNIQUE, -- Name of the file
211 @ redoflag BOOLEAN, -- 0 for undoable. 1 for redoable
212 @ existsflag BOOLEAN, -- True if the file exists
213 @ isExe BOOLEAN, -- True if the file is executable
214 @ content BLOB -- Saved content
215 @ );
216 @ CREATE TABLE %s.undo_vfile AS SELECT * FROM vfile;
217 @ CREATE TABLE %s.undo_vmerge AS SELECT * FROM vmerge;
218 ;
@@ -246,13 +255,13 @@
255
256 if( !undoActive ) return;
257 zFullname = mprintf("%s%s", g.zLocalRoot, zPathname);
258 existsFlag = file_size(zFullname)>=0;
259 db_prepare(&q,
260 "INSERT OR IGNORE INTO undo(pathname,redoflag,existsflag,isExe,content)"
261 " VALUES(%Q,0,%d,%d,:c)",
262 zPathname, existsFlag, file_isexe(zFullname)
263 );
264 if( existsFlag ){
265 blob_read_from_file(&content, zFullname);
266 db_bind_blob(&q, ":c", &content);
267 }
268
+9 -10
--- src/update.c
+++ src/update.c
@@ -559,25 +559,24 @@
559559
zFile = db_column_text(&q, 0);
560560
errCode = historical_version_of_file(zRevision, zFile, &record, &isExe,2);
561561
if( errCode==2 ){
562562
fossil_warning("file not in repository: %s", zFile);
563563
}else{
564
+ sqlite3_int64 mtime;
564565
char *zFull = mprintf("%/%/", g.zLocalRoot, zFile);
565566
undo_save(zFile);
566567
blob_write_to_file(&record, zFull);
567568
file_setexe(zFull, isExe);
568569
printf("REVERTED: %s\n", zFile);
569
- if( zRevision==0 ){
570
- sqlite3_int64 mtime = file_mtime(zFull);
571
- db_multi_exec(
572
- "UPDATE vfile"
573
- " SET mtime=%lld, chnged=0, deleted=0, isexe=%d,"
574
- " pathname=coalesce(origname,pathname), origname=NULL"
575
- " WHERE pathname=%Q",
576
- mtime, isExe, zFile
577
- );
578
- }
570
+ mtime = file_mtime(zFull);
571
+ db_multi_exec(
572
+ "UPDATE vfile"
573
+ " SET mtime=%lld, chnged=0, deleted=0, isexe=%d,"
574
+ " pathname=coalesce(origname,pathname), origname=NULL"
575
+ " WHERE pathname=%Q",
576
+ mtime, isExe, zFile
577
+ );
579578
free(zFull);
580579
}
581580
blob_reset(&record);
582581
}
583582
db_finalize(&q);
584583
--- src/update.c
+++ src/update.c
@@ -559,25 +559,24 @@
559 zFile = db_column_text(&q, 0);
560 errCode = historical_version_of_file(zRevision, zFile, &record, &isExe,2);
561 if( errCode==2 ){
562 fossil_warning("file not in repository: %s", zFile);
563 }else{
 
564 char *zFull = mprintf("%/%/", g.zLocalRoot, zFile);
565 undo_save(zFile);
566 blob_write_to_file(&record, zFull);
567 file_setexe(zFull, isExe);
568 printf("REVERTED: %s\n", zFile);
569 if( zRevision==0 ){
570 sqlite3_int64 mtime = file_mtime(zFull);
571 db_multi_exec(
572 "UPDATE vfile"
573 " SET mtime=%lld, chnged=0, deleted=0, isexe=%d,"
574 " pathname=coalesce(origname,pathname), origname=NULL"
575 " WHERE pathname=%Q",
576 mtime, isExe, zFile
577 );
578 }
579 free(zFull);
580 }
581 blob_reset(&record);
582 }
583 db_finalize(&q);
584
--- src/update.c
+++ src/update.c
@@ -559,25 +559,24 @@
559 zFile = db_column_text(&q, 0);
560 errCode = historical_version_of_file(zRevision, zFile, &record, &isExe,2);
561 if( errCode==2 ){
562 fossil_warning("file not in repository: %s", zFile);
563 }else{
564 sqlite3_int64 mtime;
565 char *zFull = mprintf("%/%/", g.zLocalRoot, zFile);
566 undo_save(zFile);
567 blob_write_to_file(&record, zFull);
568 file_setexe(zFull, isExe);
569 printf("REVERTED: %s\n", zFile);
570 mtime = file_mtime(zFull);
571 db_multi_exec(
572 "UPDATE vfile"
573 " SET mtime=%lld, chnged=0, deleted=0, isexe=%d,"
574 " pathname=coalesce(origname,pathname), origname=NULL"
575 " WHERE pathname=%Q",
576 mtime, isExe, zFile
577 );
 
 
578 free(zFull);
579 }
580 blob_reset(&record);
581 }
582 db_finalize(&q);
583
+12 -5
--- src/vfile.c
+++ src/vfile.c
@@ -85,21 +85,22 @@
8585
db_begin_transaction();
8686
p = manifest_get(vid, CFTYPE_MANIFEST);
8787
if( p==0 ) return;
8888
db_multi_exec("DELETE FROM vfile WHERE vid=%d", vid);
8989
db_prepare(&ins,
90
- "INSERT INTO vfile(vid,rid,mrid,pathname) "
91
- " VALUES(:vid,:id,:id,:name)");
90
+ "INSERT INTO vfile(vid,isexe,rid,mrid,pathname) "
91
+ " VALUES(:vid,:isexe,:id,:id,:name)");
9292
db_bind_int(&ins, ":vid", vid);
9393
manifest_file_rewind(p);
9494
while( (pFile = manifest_file_next(p,0))!=0 ){
9595
if( pFile->zUuid==0 || uuid_is_shunned(pFile->zUuid) ) continue;
9696
rid = uuid_to_rid(pFile->zUuid, 0);
9797
if( rid==0 || content_size(rid, -1)<0 ){
9898
fossil_warning("content missing for %s", pFile->zName);
9999
continue;
100100
}
101
+ db_bind_int(&ins, ":isexe", manifest_file_mperm(pFile));
101102
db_bind_int(&ins, ":id", rid);
102103
db_bind_text(&ins, ":name", pFile->zName);
103104
db_step(&ins);
104105
db_reset(&ins);
105106
}
@@ -207,31 +208,36 @@
207208
Stmt q;
208209
Blob content;
209210
int nRepos = strlen(g.zLocalRoot);
210211
211212
if( vid>0 && id==0 ){
212
- db_prepare(&q, "SELECT id, %Q || pathname, mrid"
213
+ db_prepare(&q, "SELECT id, %Q || pathname, mrid, isexe"
213214
" FROM vfile"
214215
" WHERE vid=%d AND mrid>0",
215216
g.zLocalRoot, vid);
216217
}else{
217218
assert( vid==0 && id>0 );
218
- db_prepare(&q, "SELECT id, %Q || pathname, mrid"
219
+ db_prepare(&q, "SELECT id, %Q || pathname, mrid, isexe"
219220
" FROM vfile"
220221
" WHERE id=%d AND mrid>0",
221222
g.zLocalRoot, id);
222223
}
223224
while( db_step(&q)==SQLITE_ROW ){
224
- int id, rid;
225
+ int id, rid, isExe;
225226
const char *zName;
226227
227228
id = db_column_int(&q, 0);
228229
zName = db_column_text(&q, 1);
229230
rid = db_column_int(&q, 2);
231
+ isExe = db_column_int(&q, 3);
230232
content_get(rid, &content);
231233
if( file_is_the_same(&content, zName) ){
232234
blob_reset(&content);
235
+ if( file_setexe(zName, isExe) ){
236
+ db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d",
237
+ file_mtime(zName), id);
238
+ }
233239
continue;
234240
}
235241
if( promptFlag && file_size(zName)>=0 ){
236242
Blob ans;
237243
char *zMsg;
@@ -250,10 +256,11 @@
250256
continue;
251257
}
252258
}
253259
if( verbose ) printf("%s\n", &zName[nRepos]);
254260
blob_write_to_file(&content, zName);
261
+ file_setexe(zName, isExe);
255262
blob_reset(&content);
256263
db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d",
257264
file_mtime(zName), id);
258265
}
259266
db_finalize(&q);
260267
--- src/vfile.c
+++ src/vfile.c
@@ -85,21 +85,22 @@
85 db_begin_transaction();
86 p = manifest_get(vid, CFTYPE_MANIFEST);
87 if( p==0 ) return;
88 db_multi_exec("DELETE FROM vfile WHERE vid=%d", vid);
89 db_prepare(&ins,
90 "INSERT INTO vfile(vid,rid,mrid,pathname) "
91 " VALUES(:vid,:id,:id,:name)");
92 db_bind_int(&ins, ":vid", vid);
93 manifest_file_rewind(p);
94 while( (pFile = manifest_file_next(p,0))!=0 ){
95 if( pFile->zUuid==0 || uuid_is_shunned(pFile->zUuid) ) continue;
96 rid = uuid_to_rid(pFile->zUuid, 0);
97 if( rid==0 || content_size(rid, -1)<0 ){
98 fossil_warning("content missing for %s", pFile->zName);
99 continue;
100 }
 
101 db_bind_int(&ins, ":id", rid);
102 db_bind_text(&ins, ":name", pFile->zName);
103 db_step(&ins);
104 db_reset(&ins);
105 }
@@ -207,31 +208,36 @@
207 Stmt q;
208 Blob content;
209 int nRepos = strlen(g.zLocalRoot);
210
211 if( vid>0 && id==0 ){
212 db_prepare(&q, "SELECT id, %Q || pathname, mrid"
213 " FROM vfile"
214 " WHERE vid=%d AND mrid>0",
215 g.zLocalRoot, vid);
216 }else{
217 assert( vid==0 && id>0 );
218 db_prepare(&q, "SELECT id, %Q || pathname, mrid"
219 " FROM vfile"
220 " WHERE id=%d AND mrid>0",
221 g.zLocalRoot, id);
222 }
223 while( db_step(&q)==SQLITE_ROW ){
224 int id, rid;
225 const char *zName;
226
227 id = db_column_int(&q, 0);
228 zName = db_column_text(&q, 1);
229 rid = db_column_int(&q, 2);
 
230 content_get(rid, &content);
231 if( file_is_the_same(&content, zName) ){
232 blob_reset(&content);
 
 
 
 
233 continue;
234 }
235 if( promptFlag && file_size(zName)>=0 ){
236 Blob ans;
237 char *zMsg;
@@ -250,10 +256,11 @@
250 continue;
251 }
252 }
253 if( verbose ) printf("%s\n", &zName[nRepos]);
254 blob_write_to_file(&content, zName);
 
255 blob_reset(&content);
256 db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d",
257 file_mtime(zName), id);
258 }
259 db_finalize(&q);
260
--- src/vfile.c
+++ src/vfile.c
@@ -85,21 +85,22 @@
85 db_begin_transaction();
86 p = manifest_get(vid, CFTYPE_MANIFEST);
87 if( p==0 ) return;
88 db_multi_exec("DELETE FROM vfile WHERE vid=%d", vid);
89 db_prepare(&ins,
90 "INSERT INTO vfile(vid,isexe,rid,mrid,pathname) "
91 " VALUES(:vid,:isexe,:id,:id,:name)");
92 db_bind_int(&ins, ":vid", vid);
93 manifest_file_rewind(p);
94 while( (pFile = manifest_file_next(p,0))!=0 ){
95 if( pFile->zUuid==0 || uuid_is_shunned(pFile->zUuid) ) continue;
96 rid = uuid_to_rid(pFile->zUuid, 0);
97 if( rid==0 || content_size(rid, -1)<0 ){
98 fossil_warning("content missing for %s", pFile->zName);
99 continue;
100 }
101 db_bind_int(&ins, ":isexe", manifest_file_mperm(pFile));
102 db_bind_int(&ins, ":id", rid);
103 db_bind_text(&ins, ":name", pFile->zName);
104 db_step(&ins);
105 db_reset(&ins);
106 }
@@ -207,31 +208,36 @@
208 Stmt q;
209 Blob content;
210 int nRepos = strlen(g.zLocalRoot);
211
212 if( vid>0 && id==0 ){
213 db_prepare(&q, "SELECT id, %Q || pathname, mrid, isexe"
214 " FROM vfile"
215 " WHERE vid=%d AND mrid>0",
216 g.zLocalRoot, vid);
217 }else{
218 assert( vid==0 && id>0 );
219 db_prepare(&q, "SELECT id, %Q || pathname, mrid, isexe"
220 " FROM vfile"
221 " WHERE id=%d AND mrid>0",
222 g.zLocalRoot, id);
223 }
224 while( db_step(&q)==SQLITE_ROW ){
225 int id, rid, isExe;
226 const char *zName;
227
228 id = db_column_int(&q, 0);
229 zName = db_column_text(&q, 1);
230 rid = db_column_int(&q, 2);
231 isExe = db_column_int(&q, 3);
232 content_get(rid, &content);
233 if( file_is_the_same(&content, zName) ){
234 blob_reset(&content);
235 if( file_setexe(zName, isExe) ){
236 db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d",
237 file_mtime(zName), id);
238 }
239 continue;
240 }
241 if( promptFlag && file_size(zName)>=0 ){
242 Blob ans;
243 char *zMsg;
@@ -250,10 +256,11 @@
256 continue;
257 }
258 }
259 if( verbose ) printf("%s\n", &zName[nRepos]);
260 blob_write_to_file(&content, zName);
261 file_setexe(zName, isExe);
262 blob_reset(&content);
263 db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d",
264 file_mtime(zName), id);
265 }
266 db_finalize(&q);
267

Keyboard Shortcuts

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