Fossil SCM

Remove the restriction entirely for editing a comment only in the working check-out directory and choose an appropriate temporary file if no working check-out is available instead.

andybradford 2017-05-26 05:55 UTC amend-regress
Commit 74df777e34ab9829cd460859321b97526ffd337d40a8a24026e75f7f02621f95
2 files changed +8 -6 +7 -2
+8 -6
--- src/checkin.c
+++ src/checkin.c
@@ -1202,16 +1202,18 @@
12021202
"# Type \".\" on a line by itself when you are done:\n", -1);
12031203
zFile = mprintf("-");
12041204
}else{
12051205
Blob fname;
12061206
blob_zero(&fname);
1207
- if ( g.zRepositoryOption )
1208
- fossil_fatal("interactive edits must be done within an open check-out");
1209
- assert( g.zLocalRoot!=0 );
1210
- file_relative_name(g.zLocalRoot, &fname, 1);
1211
- zFile = db_text(0, "SELECT '%qci-comment-'||hex(randomblob(6))||'.txt'",
1212
- blob_str(&fname));
1207
+ if( g.zLocalRoot!=0 ){
1208
+ file_relative_name(g.zLocalRoot, &fname, 1);
1209
+ zFile = db_text(0, "SELECT '%qci-comment-'||hex(randomblob(6))||'.txt'",
1210
+ blob_str(&fname));
1211
+ }else{
1212
+ file_tempname(&fname, "ci-comment");
1213
+ zFile = db_text(0, "SELECT '%q'||'.txt'", blob_str(&fname));
1214
+ }
12131215
blob_reset(&fname);
12141216
}
12151217
#if defined(_WIN32)
12161218
blob_add_cr(pPrompt);
12171219
#endif
12181220
--- src/checkin.c
+++ src/checkin.c
@@ -1202,16 +1202,18 @@
1202 "# Type \".\" on a line by itself when you are done:\n", -1);
1203 zFile = mprintf("-");
1204 }else{
1205 Blob fname;
1206 blob_zero(&fname);
1207 if ( g.zRepositoryOption )
1208 fossil_fatal("interactive edits must be done within an open check-out");
1209 assert( g.zLocalRoot!=0 );
1210 file_relative_name(g.zLocalRoot, &fname, 1);
1211 zFile = db_text(0, "SELECT '%qci-comment-'||hex(randomblob(6))||'.txt'",
1212 blob_str(&fname));
 
 
1213 blob_reset(&fname);
1214 }
1215 #if defined(_WIN32)
1216 blob_add_cr(pPrompt);
1217 #endif
1218
--- src/checkin.c
+++ src/checkin.c
@@ -1202,16 +1202,18 @@
1202 "# Type \".\" on a line by itself when you are done:\n", -1);
1203 zFile = mprintf("-");
1204 }else{
1205 Blob fname;
1206 blob_zero(&fname);
1207 if( g.zLocalRoot!=0 ){
1208 file_relative_name(g.zLocalRoot, &fname, 1);
1209 zFile = db_text(0, "SELECT '%qci-comment-'||hex(randomblob(6))||'.txt'",
1210 blob_str(&fname));
1211 }else{
1212 file_tempname(&fname, "ci-comment");
1213 zFile = db_text(0, "SELECT '%q'||'.txt'", blob_str(&fname));
1214 }
1215 blob_reset(&fname);
1216 }
1217 #if defined(_WIN32)
1218 blob_add_cr(pPrompt);
1219 #endif
1220
+7 -2
--- src/file.c
+++ src/file.c
@@ -799,10 +799,11 @@
799799
** If the slash parameter is non-zero, the trailing slash, if any,
800800
** is retained.
801801
*/
802802
int file_simplify_name(char *z, int n, int slash){
803803
int i = 1, j;
804
+ assert( z!=0 );
804805
if( n<0 ) n = strlen(z);
805806
806807
/* On windows and cygwin convert all \ characters to /
807808
* and remove extended path prefix if present */
808809
#if defined(_WIN32) || defined(__CYGWIN__)
@@ -1388,11 +1389,12 @@
13881389
0, /* TEMP */
13891390
0, /* TMP */
13901391
".",
13911392
};
13921393
#else
1393
- static const char *const azDirs[] = {
1394
+ static const char *azDirs[] = {
1395
+ 0, /* TMPDIR */
13941396
"/var/tmp",
13951397
"/usr/tmp",
13961398
"/tmp",
13971399
"/temp",
13981400
".",
@@ -1414,12 +1416,13 @@
14141416
azDirs[0] = fossil_path_to_utf8(zTmpPath);
14151417
}
14161418
14171419
azDirs[1] = fossil_getenv("TEMP");
14181420
azDirs[2] = fossil_getenv("TMP");
1421
+#else
1422
+ azDirs[0] = fossil_getenv("TMPDIR");
14191423
#endif
1420
-
14211424
14221425
for(i=0; i<count(azDirs); i++){
14231426
if( azDirs[i]==0 ) continue;
14241427
if( !file_isdir(azDirs[i]) ) continue;
14251428
zDir = azDirs[i];
@@ -1439,10 +1442,12 @@
14391442
14401443
#if defined(_WIN32)
14411444
fossil_path_free((char *)azDirs[0]);
14421445
fossil_path_free((char *)azDirs[1]);
14431446
fossil_path_free((char *)azDirs[2]);
1447
+#else
1448
+ fossil_path_free((char *)azDirs[0]);
14441449
#endif
14451450
}
14461451
14471452
14481453
/*
14491454
--- src/file.c
+++ src/file.c
@@ -799,10 +799,11 @@
799 ** If the slash parameter is non-zero, the trailing slash, if any,
800 ** is retained.
801 */
802 int file_simplify_name(char *z, int n, int slash){
803 int i = 1, j;
 
804 if( n<0 ) n = strlen(z);
805
806 /* On windows and cygwin convert all \ characters to /
807 * and remove extended path prefix if present */
808 #if defined(_WIN32) || defined(__CYGWIN__)
@@ -1388,11 +1389,12 @@
1388 0, /* TEMP */
1389 0, /* TMP */
1390 ".",
1391 };
1392 #else
1393 static const char *const azDirs[] = {
 
1394 "/var/tmp",
1395 "/usr/tmp",
1396 "/tmp",
1397 "/temp",
1398 ".",
@@ -1414,12 +1416,13 @@
1414 azDirs[0] = fossil_path_to_utf8(zTmpPath);
1415 }
1416
1417 azDirs[1] = fossil_getenv("TEMP");
1418 azDirs[2] = fossil_getenv("TMP");
 
 
1419 #endif
1420
1421
1422 for(i=0; i<count(azDirs); i++){
1423 if( azDirs[i]==0 ) continue;
1424 if( !file_isdir(azDirs[i]) ) continue;
1425 zDir = azDirs[i];
@@ -1439,10 +1442,12 @@
1439
1440 #if defined(_WIN32)
1441 fossil_path_free((char *)azDirs[0]);
1442 fossil_path_free((char *)azDirs[1]);
1443 fossil_path_free((char *)azDirs[2]);
 
 
1444 #endif
1445 }
1446
1447
1448 /*
1449
--- src/file.c
+++ src/file.c
@@ -799,10 +799,11 @@
799 ** If the slash parameter is non-zero, the trailing slash, if any,
800 ** is retained.
801 */
802 int file_simplify_name(char *z, int n, int slash){
803 int i = 1, j;
804 assert( z!=0 );
805 if( n<0 ) n = strlen(z);
806
807 /* On windows and cygwin convert all \ characters to /
808 * and remove extended path prefix if present */
809 #if defined(_WIN32) || defined(__CYGWIN__)
@@ -1388,11 +1389,12 @@
1389 0, /* TEMP */
1390 0, /* TMP */
1391 ".",
1392 };
1393 #else
1394 static const char *azDirs[] = {
1395 0, /* TMPDIR */
1396 "/var/tmp",
1397 "/usr/tmp",
1398 "/tmp",
1399 "/temp",
1400 ".",
@@ -1414,12 +1416,13 @@
1416 azDirs[0] = fossil_path_to_utf8(zTmpPath);
1417 }
1418
1419 azDirs[1] = fossil_getenv("TEMP");
1420 azDirs[2] = fossil_getenv("TMP");
1421 #else
1422 azDirs[0] = fossil_getenv("TMPDIR");
1423 #endif
 
1424
1425 for(i=0; i<count(azDirs); i++){
1426 if( azDirs[i]==0 ) continue;
1427 if( !file_isdir(azDirs[i]) ) continue;
1428 zDir = azDirs[i];
@@ -1439,10 +1442,12 @@
1442
1443 #if defined(_WIN32)
1444 fossil_path_free((char *)azDirs[0]);
1445 fossil_path_free((char *)azDirs[1]);
1446 fossil_path_free((char *)azDirs[2]);
1447 #else
1448 fossil_path_free((char *)azDirs[0]);
1449 #endif
1450 }
1451
1452
1453 /*
1454

Keyboard Shortcuts

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