Fossil SCM

Add the "fossil unversioned edit UVFILE" command.

drh 2016-08-23 13:01 trunk
Commit 1d6b67822a7c595da71491fc775003359de5deef
+9 -3
--- src/content.c
+++ src/content.c
@@ -455,17 +455,23 @@
455455
ignoreDephantomizations = !onoff;
456456
}
457457
458458
/*
459459
** Make sure the g.rcvid global variable has been initialized.
460
+**
461
+** If the g.zIpAddr variable has not been set when this routine is
462
+** called, use zSrc as the source of content for the the rcvfrom
463
+** table entry.
460464
*/
461
-void content_rcvid_init(void){
465
+void content_rcvid_init(const char *zSrc){
462466
if( g.rcvid==0 ){
467
+ user_select();
468
+ if( g.zIpAddr ) zSrc = g.zIpAddr;
463469
db_multi_exec(
464470
"INSERT INTO rcvfrom(uid, mtime, nonce, ipaddr)"
465471
"VALUES(%d, julianday('now'), %Q, %Q)",
466
- g.userUid, g.zNonce, g.zIpAddr
472
+ g.userUid, g.zNonce, zSrc
467473
);
468474
g.rcvid = db_last_insert_rowid();
469475
}
470476
}
471477
@@ -544,11 +550,11 @@
544550
markAsUnclustered = 1;
545551
}
546552
db_finalize(&s1);
547553
548554
/* Construct a received-from ID if we do not already have one */
549
- content_rcvid_init();
555
+ content_rcvid_init(0);
550556
551557
if( nBlob ){
552558
cmpr = pBlob[0];
553559
}else{
554560
blob_compress(pBlob, &cmpr);
555561
--- src/content.c
+++ src/content.c
@@ -455,17 +455,23 @@
455 ignoreDephantomizations = !onoff;
456 }
457
458 /*
459 ** Make sure the g.rcvid global variable has been initialized.
 
 
 
 
460 */
461 void content_rcvid_init(void){
462 if( g.rcvid==0 ){
 
 
463 db_multi_exec(
464 "INSERT INTO rcvfrom(uid, mtime, nonce, ipaddr)"
465 "VALUES(%d, julianday('now'), %Q, %Q)",
466 g.userUid, g.zNonce, g.zIpAddr
467 );
468 g.rcvid = db_last_insert_rowid();
469 }
470 }
471
@@ -544,11 +550,11 @@
544 markAsUnclustered = 1;
545 }
546 db_finalize(&s1);
547
548 /* Construct a received-from ID if we do not already have one */
549 content_rcvid_init();
550
551 if( nBlob ){
552 cmpr = pBlob[0];
553 }else{
554 blob_compress(pBlob, &cmpr);
555
--- src/content.c
+++ src/content.c
@@ -455,17 +455,23 @@
455 ignoreDephantomizations = !onoff;
456 }
457
458 /*
459 ** Make sure the g.rcvid global variable has been initialized.
460 **
461 ** If the g.zIpAddr variable has not been set when this routine is
462 ** called, use zSrc as the source of content for the the rcvfrom
463 ** table entry.
464 */
465 void content_rcvid_init(const char *zSrc){
466 if( g.rcvid==0 ){
467 user_select();
468 if( g.zIpAddr ) zSrc = g.zIpAddr;
469 db_multi_exec(
470 "INSERT INTO rcvfrom(uid, mtime, nonce, ipaddr)"
471 "VALUES(%d, julianday('now'), %Q, %Q)",
472 g.userUid, g.zNonce, zSrc
473 );
474 g.rcvid = db_last_insert_rowid();
475 }
476 }
477
@@ -544,11 +550,11 @@
550 markAsUnclustered = 1;
551 }
552 db_finalize(&s1);
553
554 /* Construct a received-from ID if we do not already have one */
555 content_rcvid_init(0);
556
557 if( nBlob ){
558 cmpr = pBlob[0];
559 }else{
560 blob_compress(pBlob, &cmpr);
561
+79 -32
--- src/unversioned.c
+++ src/unversioned.c
@@ -101,10 +101,48 @@
101101
rc = 0;
102102
}
103103
db_finalize(&q);
104104
return rc;
105105
}
106
+
107
+/*
108
+** Write unversioned content into the database.
109
+*/
110
+static void unversioned_write(
111
+ const char *zUVFile, /* Name of the unversioned file */
112
+ Blob *pContent, /* File content */
113
+ sqlite3_int64 mtime /* Modification time */
114
+){
115
+ Stmt ins;
116
+ Blob compressed;
117
+ Blob hash;
118
+
119
+ db_prepare(&ins,
120
+ "REPLACE INTO unversioned(name,rcvid,mtime,hash,sz,encoding,content)"
121
+ " VALUES(:name,:rcvid,:mtime,:hash,:sz,:encoding,:content)"
122
+ );
123
+ sha1sum_blob(pContent, &hash);
124
+ blob_compress(pContent, &compressed);
125
+ db_bind_text(&ins, ":name", zUVFile);
126
+ db_bind_int(&ins, ":rcvid", g.rcvid);
127
+ db_bind_int64(&ins, ":mtime", mtime);
128
+ db_bind_text(&ins, ":hash", blob_str(&hash));
129
+ db_bind_int(&ins, ":sz", blob_size(pContent));
130
+ if( blob_size(&compressed) <= 0.8*blob_size(pContent) ){
131
+ db_bind_int(&ins, ":encoding", 1);
132
+ db_bind_blob(&ins, ":content", &compressed);
133
+ }else{
134
+ db_bind_int(&ins, ":encoding", 0);
135
+ db_bind_blob(&ins, ":content", pContent);
136
+ }
137
+ db_step(&ins);
138
+ blob_reset(&compressed);
139
+ blob_reset(&hash);
140
+ db_finalize(&ins);
141
+ db_unset("uv-hash", 0);
142
+}
143
+
106144
107145
/*
108146
** Check the status of unversioned file zName. Return an integer status
109147
** code as follows:
110148
**
@@ -157,10 +195,12 @@
157195
** Changes are not pushed to other repositories until
158196
** the next sync.
159197
**
160198
** cat FILE ... Concatenate the content of FILEs to stdout.
161199
**
200
+** edit FILE Bring up FILE in a text editor for modification.
201
+**
162202
** export FILE OUTPUT Write the content of FILE into OUTPUT on disk
163203
**
164204
** list | ls Show all unversioned files held in the local repository.
165205
**
166206
** revert ?URL? Restore the state of all unversioned files in the local
@@ -198,55 +238,27 @@
198238
}
199239
if( memcmp(zCmd, "add", nCmd)==0 ){
200240
const char *zIn;
201241
const char *zAs;
202242
Blob file;
203
- Blob hash;
204
- Blob compressed;
205
- Stmt ins;
206243
int i;
207244
208245
zAs = find_option("as",0,1);
209246
if( zAs && g.argc!=4 ) usage("add DISKFILE --as UVFILE");
210247
verify_all_options();
211248
db_begin_transaction();
212
- user_select();
213
- g.zIpAddr = "command-line";
214
- content_rcvid_init();
215
- db_prepare(&ins,
216
- "REPLACE INTO unversioned(name,rcvid,mtime,hash,sz,encoding,content)"
217
- " VALUES(:name,:rcvid,:mtime,:hash,:sz,:encoding,:content)"
218
- );
249
+ content_rcvid_init("#!fossil unversioned add");
219250
for(i=3; i<g.argc; i++){
220251
zIn = zAs ? zAs : g.argv[i];
221252
if( zIn[0]==0 || zIn[0]=='/' || !file_is_simple_pathname(zIn,1) ){
222253
fossil_fatal("'%Q' is not an acceptable filename", zIn);
223254
}
224255
blob_init(&file,0,0);
225256
blob_read_from_file(&file, g.argv[i]);
226
- sha1sum_blob(&file, &hash);
227
- blob_compress(&file, &compressed);
228
- db_bind_text(&ins, ":name", zIn);
229
- db_bind_int(&ins, ":rcvid", g.rcvid);
230
- db_bind_int64(&ins, ":mtime", mtime);
231
- db_bind_text(&ins, ":hash", blob_str(&hash));
232
- db_bind_int(&ins, ":sz", blob_size(&file));
233
- if( blob_size(&compressed) <= 0.8*blob_size(&file) ){
234
- db_bind_int(&ins, ":encoding", 1);
235
- db_bind_blob(&ins, ":content", &compressed);
236
- }else{
237
- db_bind_int(&ins, ":encoding", 0);
238
- db_bind_blob(&ins, ":content", &file);
239
- }
240
- db_step(&ins);
241
- db_reset(&ins);
242
- blob_reset(&compressed);
243
- blob_reset(&hash);
257
+ unversioned_write(zIn, &file, mtime);
244258
blob_reset(&file);
245259
}
246
- db_finalize(&ins);
247
- db_unset("uv-hash", 0);
248260
db_end_transaction(0);
249261
}else if( memcmp(zCmd, "cat", nCmd)==0 ){
250262
int i;
251263
verify_all_options();
252264
db_begin_transaction();
@@ -256,18 +268,53 @@
256268
blob_write_to_file(&content, "-");
257269
}
258270
blob_reset(&content);
259271
}
260272
db_end_transaction(0);
273
+ }else if( memcmp(zCmd, "edit", nCmd)==0 ){
274
+ const char *zEditor; /* Name of the text-editor command */
275
+ const char *zTFile; /* Temporary file */
276
+ const char *zUVFile; /* Name of the unversioned file */
277
+ char *zCmd; /* Command to run the text editor */
278
+ Blob content; /* Content of the unversioned file */
279
+
280
+ verify_all_options();
281
+ if( g.argc!=4) usage("edit UVFILE");
282
+ zUVFile = g.argv[3];
283
+ zEditor = fossil_text_editor();
284
+ if( zEditor==0 ) fossil_fatal("no text editor - set the VISUAL env variable");
285
+ zTFile = fossil_temp_filename();
286
+ if( zTFile==0 ) fossil_fatal("cannot find a temporary filename");
287
+ db_begin_transaction();
288
+ content_rcvid_init("#!fossil unversioned edit");
289
+ if( unversioned_content(zUVFile, &content) ){
290
+ fossil_fatal("no such uv-file: %Q", zUVFile);
291
+ }
292
+ if( looks_like_binary(&content) ){
293
+ fossil_fatal("cannot edit binary content");
294
+ }
295
+ blob_write_to_file(&content, zTFile);
296
+ zCmd = mprintf("%s \"%s\"", zEditor, zTFile);
297
+ if( fossil_system(zCmd) ){
298
+ fossil_fatal("editor aborted: %Q", zCmd);
299
+ }
300
+ fossil_free(zCmd);
301
+ blob_reset(&content);
302
+ blob_read_from_file(&content, zTFile);
303
+ file_delete(zTFile);
304
+ if( zMtime==0 ) mtime = time(0);
305
+ unversioned_write(zUVFile, &content, mtime);
306
+ db_end_transaction(0);
307
+ blob_reset(&content);
261308
}else if( memcmp(zCmd, "export", nCmd)==0 ){
262309
Blob content;
263310
verify_all_options();
264311
if( g.argc!=5 ) usage("export UVFILE OUTPUT");
265312
if( unversioned_content(g.argv[3], &content) ){
266313
fossil_fatal("no such uv-file: %Q", g.argv[3]);
267314
}
268
- blob_write_to_file(&content, g.argv[4]);
315
+ blob_write_to_file(&content, g.argv[4]);
269316
blob_reset(&content);
270317
}else if( memcmp(zCmd, "hash", nCmd)==0 ){ /* undocumented */
271318
/* Show the hash value used during uv sync */
272319
int debugFlag = find_option("debug",0,0)!=0;
273320
fossil_print("%s\n", unversioned_content_hash(debugFlag));
@@ -344,11 +391,11 @@
344391
);
345392
}
346393
db_unset("uv-hash", 0);
347394
db_end_transaction(0);
348395
}else{
349
- usage("add|cat|export|ls|revert|rm|sync|touch");
396
+ usage("add|cat|edit|export|ls|revert|rm|sync|touch");
350397
}
351398
}
352399
353400
/*
354401
** WEBPAGE: uvlist
355402
--- src/unversioned.c
+++ src/unversioned.c
@@ -101,10 +101,48 @@
101 rc = 0;
102 }
103 db_finalize(&q);
104 return rc;
105 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
107 /*
108 ** Check the status of unversioned file zName. Return an integer status
109 ** code as follows:
110 **
@@ -157,10 +195,12 @@
157 ** Changes are not pushed to other repositories until
158 ** the next sync.
159 **
160 ** cat FILE ... Concatenate the content of FILEs to stdout.
161 **
 
 
162 ** export FILE OUTPUT Write the content of FILE into OUTPUT on disk
163 **
164 ** list | ls Show all unversioned files held in the local repository.
165 **
166 ** revert ?URL? Restore the state of all unversioned files in the local
@@ -198,55 +238,27 @@
198 }
199 if( memcmp(zCmd, "add", nCmd)==0 ){
200 const char *zIn;
201 const char *zAs;
202 Blob file;
203 Blob hash;
204 Blob compressed;
205 Stmt ins;
206 int i;
207
208 zAs = find_option("as",0,1);
209 if( zAs && g.argc!=4 ) usage("add DISKFILE --as UVFILE");
210 verify_all_options();
211 db_begin_transaction();
212 user_select();
213 g.zIpAddr = "command-line";
214 content_rcvid_init();
215 db_prepare(&ins,
216 "REPLACE INTO unversioned(name,rcvid,mtime,hash,sz,encoding,content)"
217 " VALUES(:name,:rcvid,:mtime,:hash,:sz,:encoding,:content)"
218 );
219 for(i=3; i<g.argc; i++){
220 zIn = zAs ? zAs : g.argv[i];
221 if( zIn[0]==0 || zIn[0]=='/' || !file_is_simple_pathname(zIn,1) ){
222 fossil_fatal("'%Q' is not an acceptable filename", zIn);
223 }
224 blob_init(&file,0,0);
225 blob_read_from_file(&file, g.argv[i]);
226 sha1sum_blob(&file, &hash);
227 blob_compress(&file, &compressed);
228 db_bind_text(&ins, ":name", zIn);
229 db_bind_int(&ins, ":rcvid", g.rcvid);
230 db_bind_int64(&ins, ":mtime", mtime);
231 db_bind_text(&ins, ":hash", blob_str(&hash));
232 db_bind_int(&ins, ":sz", blob_size(&file));
233 if( blob_size(&compressed) <= 0.8*blob_size(&file) ){
234 db_bind_int(&ins, ":encoding", 1);
235 db_bind_blob(&ins, ":content", &compressed);
236 }else{
237 db_bind_int(&ins, ":encoding", 0);
238 db_bind_blob(&ins, ":content", &file);
239 }
240 db_step(&ins);
241 db_reset(&ins);
242 blob_reset(&compressed);
243 blob_reset(&hash);
244 blob_reset(&file);
245 }
246 db_finalize(&ins);
247 db_unset("uv-hash", 0);
248 db_end_transaction(0);
249 }else if( memcmp(zCmd, "cat", nCmd)==0 ){
250 int i;
251 verify_all_options();
252 db_begin_transaction();
@@ -256,18 +268,53 @@
256 blob_write_to_file(&content, "-");
257 }
258 blob_reset(&content);
259 }
260 db_end_transaction(0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261 }else if( memcmp(zCmd, "export", nCmd)==0 ){
262 Blob content;
263 verify_all_options();
264 if( g.argc!=5 ) usage("export UVFILE OUTPUT");
265 if( unversioned_content(g.argv[3], &content) ){
266 fossil_fatal("no such uv-file: %Q", g.argv[3]);
267 }
268 blob_write_to_file(&content, g.argv[4]);
269 blob_reset(&content);
270 }else if( memcmp(zCmd, "hash", nCmd)==0 ){ /* undocumented */
271 /* Show the hash value used during uv sync */
272 int debugFlag = find_option("debug",0,0)!=0;
273 fossil_print("%s\n", unversioned_content_hash(debugFlag));
@@ -344,11 +391,11 @@
344 );
345 }
346 db_unset("uv-hash", 0);
347 db_end_transaction(0);
348 }else{
349 usage("add|cat|export|ls|revert|rm|sync|touch");
350 }
351 }
352
353 /*
354 ** WEBPAGE: uvlist
355
--- src/unversioned.c
+++ src/unversioned.c
@@ -101,10 +101,48 @@
101 rc = 0;
102 }
103 db_finalize(&q);
104 return rc;
105 }
106
107 /*
108 ** Write unversioned content into the database.
109 */
110 static void unversioned_write(
111 const char *zUVFile, /* Name of the unversioned file */
112 Blob *pContent, /* File content */
113 sqlite3_int64 mtime /* Modification time */
114 ){
115 Stmt ins;
116 Blob compressed;
117 Blob hash;
118
119 db_prepare(&ins,
120 "REPLACE INTO unversioned(name,rcvid,mtime,hash,sz,encoding,content)"
121 " VALUES(:name,:rcvid,:mtime,:hash,:sz,:encoding,:content)"
122 );
123 sha1sum_blob(pContent, &hash);
124 blob_compress(pContent, &compressed);
125 db_bind_text(&ins, ":name", zUVFile);
126 db_bind_int(&ins, ":rcvid", g.rcvid);
127 db_bind_int64(&ins, ":mtime", mtime);
128 db_bind_text(&ins, ":hash", blob_str(&hash));
129 db_bind_int(&ins, ":sz", blob_size(pContent));
130 if( blob_size(&compressed) <= 0.8*blob_size(pContent) ){
131 db_bind_int(&ins, ":encoding", 1);
132 db_bind_blob(&ins, ":content", &compressed);
133 }else{
134 db_bind_int(&ins, ":encoding", 0);
135 db_bind_blob(&ins, ":content", pContent);
136 }
137 db_step(&ins);
138 blob_reset(&compressed);
139 blob_reset(&hash);
140 db_finalize(&ins);
141 db_unset("uv-hash", 0);
142 }
143
144
145 /*
146 ** Check the status of unversioned file zName. Return an integer status
147 ** code as follows:
148 **
@@ -157,10 +195,12 @@
195 ** Changes are not pushed to other repositories until
196 ** the next sync.
197 **
198 ** cat FILE ... Concatenate the content of FILEs to stdout.
199 **
200 ** edit FILE Bring up FILE in a text editor for modification.
201 **
202 ** export FILE OUTPUT Write the content of FILE into OUTPUT on disk
203 **
204 ** list | ls Show all unversioned files held in the local repository.
205 **
206 ** revert ?URL? Restore the state of all unversioned files in the local
@@ -198,55 +238,27 @@
238 }
239 if( memcmp(zCmd, "add", nCmd)==0 ){
240 const char *zIn;
241 const char *zAs;
242 Blob file;
 
 
 
243 int i;
244
245 zAs = find_option("as",0,1);
246 if( zAs && g.argc!=4 ) usage("add DISKFILE --as UVFILE");
247 verify_all_options();
248 db_begin_transaction();
249 content_rcvid_init("#!fossil unversioned add");
 
 
 
 
 
 
250 for(i=3; i<g.argc; i++){
251 zIn = zAs ? zAs : g.argv[i];
252 if( zIn[0]==0 || zIn[0]=='/' || !file_is_simple_pathname(zIn,1) ){
253 fossil_fatal("'%Q' is not an acceptable filename", zIn);
254 }
255 blob_init(&file,0,0);
256 blob_read_from_file(&file, g.argv[i]);
257 unversioned_write(zIn, &file, mtime);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258 blob_reset(&file);
259 }
 
 
260 db_end_transaction(0);
261 }else if( memcmp(zCmd, "cat", nCmd)==0 ){
262 int i;
263 verify_all_options();
264 db_begin_transaction();
@@ -256,18 +268,53 @@
268 blob_write_to_file(&content, "-");
269 }
270 blob_reset(&content);
271 }
272 db_end_transaction(0);
273 }else if( memcmp(zCmd, "edit", nCmd)==0 ){
274 const char *zEditor; /* Name of the text-editor command */
275 const char *zTFile; /* Temporary file */
276 const char *zUVFile; /* Name of the unversioned file */
277 char *zCmd; /* Command to run the text editor */
278 Blob content; /* Content of the unversioned file */
279
280 verify_all_options();
281 if( g.argc!=4) usage("edit UVFILE");
282 zUVFile = g.argv[3];
283 zEditor = fossil_text_editor();
284 if( zEditor==0 ) fossil_fatal("no text editor - set the VISUAL env variable");
285 zTFile = fossil_temp_filename();
286 if( zTFile==0 ) fossil_fatal("cannot find a temporary filename");
287 db_begin_transaction();
288 content_rcvid_init("#!fossil unversioned edit");
289 if( unversioned_content(zUVFile, &content) ){
290 fossil_fatal("no such uv-file: %Q", zUVFile);
291 }
292 if( looks_like_binary(&content) ){
293 fossil_fatal("cannot edit binary content");
294 }
295 blob_write_to_file(&content, zTFile);
296 zCmd = mprintf("%s \"%s\"", zEditor, zTFile);
297 if( fossil_system(zCmd) ){
298 fossil_fatal("editor aborted: %Q", zCmd);
299 }
300 fossil_free(zCmd);
301 blob_reset(&content);
302 blob_read_from_file(&content, zTFile);
303 file_delete(zTFile);
304 if( zMtime==0 ) mtime = time(0);
305 unversioned_write(zUVFile, &content, mtime);
306 db_end_transaction(0);
307 blob_reset(&content);
308 }else if( memcmp(zCmd, "export", nCmd)==0 ){
309 Blob content;
310 verify_all_options();
311 if( g.argc!=5 ) usage("export UVFILE OUTPUT");
312 if( unversioned_content(g.argv[3], &content) ){
313 fossil_fatal("no such uv-file: %Q", g.argv[3]);
314 }
315 blob_write_to_file(&content, g.argv[4]);
316 blob_reset(&content);
317 }else if( memcmp(zCmd, "hash", nCmd)==0 ){ /* undocumented */
318 /* Show the hash value used during uv sync */
319 int debugFlag = find_option("debug",0,0)!=0;
320 fossil_print("%s\n", unversioned_content_hash(debugFlag));
@@ -344,11 +391,11 @@
391 );
392 }
393 db_unset("uv-hash", 0);
394 db_end_transaction(0);
395 }else{
396 usage("add|cat|edit|export|ls|revert|rm|sync|touch");
397 }
398 }
399
400 /*
401 ** WEBPAGE: uvlist
402
+50
--- src/util.c
+++ src/util.c
@@ -341,5 +341,55 @@
341341
int fossil_all_whitespace(const char *z){
342342
if( z==0 ) return 1;
343343
while( fossil_isspace(z[0]) ){ z++; }
344344
return z[0]==0;
345345
}
346
+
347
+/*
348
+** Return the name of the users preferred text editor. Return NULL if
349
+** not found.
350
+**
351
+** Search algorithm:
352
+** (1) The local "editor" setting
353
+** (2) The global "editor" setting
354
+** (3) The VISUAL environment variable
355
+** (4) The EDITOR environment variable
356
+** (5) (Windows only:) "notepad.exe"
357
+*/
358
+const char *fossil_text_editor(void){
359
+ const char *zEditor = db_get("editor", 0);
360
+ if( zEditor==0 ){
361
+ zEditor = fossil_getenv("VISUAL");
362
+ }
363
+ if( zEditor==0 ){
364
+ zEditor = fossil_getenv("EDITOR");
365
+ }
366
+#if defined(_WIN32) || defined(__CYGWIN__)
367
+ if( zEditor==0 ){
368
+ zEditor = mprintf("%s\\notepad.exe", fossil_getenv("SYSTEMROOT"));
369
+#if defined(__CYGWIN__)
370
+ zEditor = fossil_utf8_to_path(zEditor, 0);
371
+ blob_add_cr(pPrompt);
372
+#endif
373
+ }
374
+#endif
375
+ return zEditor;
376
+}
377
+
378
+/*
379
+** Construct a temporary filename.
380
+**
381
+** The returned string is obtained from sqlite3_malloc() and must be
382
+** freed by the caller.
383
+*/
384
+char *fossil_temp_filename(void){
385
+ char *zTFile = 0;
386
+ sqlite3 *db;
387
+ if( g.db ){
388
+ db = g.db;
389
+ }else{
390
+ sqlite3_open("",&db);
391
+ }
392
+ sqlite3_file_control(db, 0, SQLITE_FCNTL_TEMPFILENAME, (void*)&zTFile);
393
+ if( g.db==0 ) sqlite3_close(db);
394
+ return zTFile;
395
+}
346396
--- src/util.c
+++ src/util.c
@@ -341,5 +341,55 @@
341 int fossil_all_whitespace(const char *z){
342 if( z==0 ) return 1;
343 while( fossil_isspace(z[0]) ){ z++; }
344 return z[0]==0;
345 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
346
--- src/util.c
+++ src/util.c
@@ -341,5 +341,55 @@
341 int fossil_all_whitespace(const char *z){
342 if( z==0 ) return 1;
343 while( fossil_isspace(z[0]) ){ z++; }
344 return z[0]==0;
345 }
346
347 /*
348 ** Return the name of the users preferred text editor. Return NULL if
349 ** not found.
350 **
351 ** Search algorithm:
352 ** (1) The local "editor" setting
353 ** (2) The global "editor" setting
354 ** (3) The VISUAL environment variable
355 ** (4) The EDITOR environment variable
356 ** (5) (Windows only:) "notepad.exe"
357 */
358 const char *fossil_text_editor(void){
359 const char *zEditor = db_get("editor", 0);
360 if( zEditor==0 ){
361 zEditor = fossil_getenv("VISUAL");
362 }
363 if( zEditor==0 ){
364 zEditor = fossil_getenv("EDITOR");
365 }
366 #if defined(_WIN32) || defined(__CYGWIN__)
367 if( zEditor==0 ){
368 zEditor = mprintf("%s\\notepad.exe", fossil_getenv("SYSTEMROOT"));
369 #if defined(__CYGWIN__)
370 zEditor = fossil_utf8_to_path(zEditor, 0);
371 blob_add_cr(pPrompt);
372 #endif
373 }
374 #endif
375 return zEditor;
376 }
377
378 /*
379 ** Construct a temporary filename.
380 **
381 ** The returned string is obtained from sqlite3_malloc() and must be
382 ** freed by the caller.
383 */
384 char *fossil_temp_filename(void){
385 char *zTFile = 0;
386 sqlite3 *db;
387 if( g.db ){
388 db = g.db;
389 }else{
390 sqlite3_open("",&db);
391 }
392 sqlite3_file_control(db, 0, SQLITE_FCNTL_TEMPFILENAME, (void*)&zTFile);
393 if( g.db==0 ) sqlite3_close(db);
394 return zTFile;
395 }
396
+1 -1
--- src/xfer.c
+++ src/xfer.c
@@ -347,11 +347,11 @@
347347
348348
/* The isWriter flag must be true in order to land the new file */
349349
if( !isWriter ) goto end_accept_unversioned_file;
350350
351351
/* Make sure we have a valid g.rcvid marker */
352
- content_rcvid_init();
352
+ content_rcvid_init(0);
353353
354354
/* Check to see if current content really should be overwritten. Ideally,
355355
** a uvfile card should never have been sent unless the overwrite should
356356
** occur. But do not trust the sender. Double-check.
357357
*/
358358
--- src/xfer.c
+++ src/xfer.c
@@ -347,11 +347,11 @@
347
348 /* The isWriter flag must be true in order to land the new file */
349 if( !isWriter ) goto end_accept_unversioned_file;
350
351 /* Make sure we have a valid g.rcvid marker */
352 content_rcvid_init();
353
354 /* Check to see if current content really should be overwritten. Ideally,
355 ** a uvfile card should never have been sent unless the overwrite should
356 ** occur. But do not trust the sender. Double-check.
357 */
358
--- src/xfer.c
+++ src/xfer.c
@@ -347,11 +347,11 @@
347
348 /* The isWriter flag must be true in order to land the new file */
349 if( !isWriter ) goto end_accept_unversioned_file;
350
351 /* Make sure we have a valid g.rcvid marker */
352 content_rcvid_init(0);
353
354 /* Check to see if current content really should be overwritten. Ideally,
355 ** a uvfile card should never have been sent unless the overwrite should
356 ** occur. But do not trust the sender. Double-check.
357 */
358

Keyboard Shortcuts

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