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.
Commit
74df777e34ab9829cd460859321b97526ffd337d40a8a24026e75f7f02621f95
Parent
afef5fb5fc49fdd…
2 files changed
+8
-6
+7
-2
+8
-6
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -1202,16 +1202,18 @@ | ||
| 1202 | 1202 | "# Type \".\" on a line by itself when you are done:\n", -1); |
| 1203 | 1203 | zFile = mprintf("-"); |
| 1204 | 1204 | }else{ |
| 1205 | 1205 | Blob fname; |
| 1206 | 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)); | |
| 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 | + } | |
| 1213 | 1215 | blob_reset(&fname); |
| 1214 | 1216 | } |
| 1215 | 1217 | #if defined(_WIN32) |
| 1216 | 1218 | blob_add_cr(pPrompt); |
| 1217 | 1219 | #endif |
| 1218 | 1220 |
| --- 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 @@ | ||
| 799 | 799 | ** If the slash parameter is non-zero, the trailing slash, if any, |
| 800 | 800 | ** is retained. |
| 801 | 801 | */ |
| 802 | 802 | int file_simplify_name(char *z, int n, int slash){ |
| 803 | 803 | int i = 1, j; |
| 804 | + assert( z!=0 ); | |
| 804 | 805 | if( n<0 ) n = strlen(z); |
| 805 | 806 | |
| 806 | 807 | /* On windows and cygwin convert all \ characters to / |
| 807 | 808 | * and remove extended path prefix if present */ |
| 808 | 809 | #if defined(_WIN32) || defined(__CYGWIN__) |
| @@ -1388,11 +1389,12 @@ | ||
| 1388 | 1389 | 0, /* TEMP */ |
| 1389 | 1390 | 0, /* TMP */ |
| 1390 | 1391 | ".", |
| 1391 | 1392 | }; |
| 1392 | 1393 | #else |
| 1393 | - static const char *const azDirs[] = { | |
| 1394 | + static const char *azDirs[] = { | |
| 1395 | + 0, /* TMPDIR */ | |
| 1394 | 1396 | "/var/tmp", |
| 1395 | 1397 | "/usr/tmp", |
| 1396 | 1398 | "/tmp", |
| 1397 | 1399 | "/temp", |
| 1398 | 1400 | ".", |
| @@ -1414,12 +1416,13 @@ | ||
| 1414 | 1416 | azDirs[0] = fossil_path_to_utf8(zTmpPath); |
| 1415 | 1417 | } |
| 1416 | 1418 | |
| 1417 | 1419 | azDirs[1] = fossil_getenv("TEMP"); |
| 1418 | 1420 | azDirs[2] = fossil_getenv("TMP"); |
| 1421 | +#else | |
| 1422 | + azDirs[0] = fossil_getenv("TMPDIR"); | |
| 1419 | 1423 | #endif |
| 1420 | - | |
| 1421 | 1424 | |
| 1422 | 1425 | for(i=0; i<count(azDirs); i++){ |
| 1423 | 1426 | if( azDirs[i]==0 ) continue; |
| 1424 | 1427 | if( !file_isdir(azDirs[i]) ) continue; |
| 1425 | 1428 | zDir = azDirs[i]; |
| @@ -1439,10 +1442,12 @@ | ||
| 1439 | 1442 | |
| 1440 | 1443 | #if defined(_WIN32) |
| 1441 | 1444 | fossil_path_free((char *)azDirs[0]); |
| 1442 | 1445 | fossil_path_free((char *)azDirs[1]); |
| 1443 | 1446 | fossil_path_free((char *)azDirs[2]); |
| 1447 | +#else | |
| 1448 | + fossil_path_free((char *)azDirs[0]); | |
| 1444 | 1449 | #endif |
| 1445 | 1450 | } |
| 1446 | 1451 | |
| 1447 | 1452 | |
| 1448 | 1453 | /* |
| 1449 | 1454 |
| --- 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 |