Fossil SCM

Fail with an error if a file is outside the checkout tree.

drh 2008-02-08 16:24 trunk
Commit b3ec774ab7edcaa610aa216fd94cd5029650555c
+1 -3
--- src/checkin.c
+++ src/checkin.c
@@ -290,13 +290,11 @@
290290
blob_zero(&b);
291291
g.aCommitFile = malloc(sizeof(int)*(g.argc-1));
292292
293293
for(ii=2; ii<g.argc; ii++){
294294
int iId;
295
- if( !file_tree_name(g.argv[ii], &b) ){
296
- fossil_fatal("file is not in tree: %s", g.argv[ii]);
297
- }
295
+ file_tree_name(g.argv[ii], &b);
298296
iId = db_int(-1, "SELECT id FROM vfile WHERE pathname=%Q", blob_str(&b));
299297
if( iId<0 ){
300298
fossil_fatal("fossil knows nothing about: %s", g.argv[ii]);
301299
}
302300
g.aCommitFile[ii-2] = iId;
303301
--- src/checkin.c
+++ src/checkin.c
@@ -290,13 +290,11 @@
290 blob_zero(&b);
291 g.aCommitFile = malloc(sizeof(int)*(g.argc-1));
292
293 for(ii=2; ii<g.argc; ii++){
294 int iId;
295 if( !file_tree_name(g.argv[ii], &b) ){
296 fossil_fatal("file is not in tree: %s", g.argv[ii]);
297 }
298 iId = db_int(-1, "SELECT id FROM vfile WHERE pathname=%Q", blob_str(&b));
299 if( iId<0 ){
300 fossil_fatal("fossil knows nothing about: %s", g.argv[ii]);
301 }
302 g.aCommitFile[ii-2] = iId;
303
--- src/checkin.c
+++ src/checkin.c
@@ -290,13 +290,11 @@
290 blob_zero(&b);
291 g.aCommitFile = malloc(sizeof(int)*(g.argc-1));
292
293 for(ii=2; ii<g.argc; ii++){
294 int iId;
295 file_tree_name(g.argv[ii], &b);
 
 
296 iId = db_int(-1, "SELECT id FROM vfile WHERE pathname=%Q", blob_str(&b));
297 if( iId<0 ){
298 fossil_fatal("fossil knows nothing about: %s", g.argv[ii]);
299 }
300 g.aCommitFile[ii-2] = iId;
301
+1 -3
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -99,13 +99,11 @@
9999
}
100100
blob_zero(&cmd);
101101
blob_appendf(&cmd, "%s ", zExternalCommand);
102102
}
103103
zFile = g.argv[g.argc-1];
104
- if( !file_tree_name(zFile, &fname) ){
105
- fossil_panic("unknown file: %s", zFile);
106
- }
104
+ file_tree_name(zFile, &fname);
107105
108106
blob_zero(&vname);
109107
do{
110108
blob_reset(&vname);
111109
blob_appendf(&vname, "%s~%d", zFile, cnt++);
112110
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -99,13 +99,11 @@
99 }
100 blob_zero(&cmd);
101 blob_appendf(&cmd, "%s ", zExternalCommand);
102 }
103 zFile = g.argv[g.argc-1];
104 if( !file_tree_name(zFile, &fname) ){
105 fossil_panic("unknown file: %s", zFile);
106 }
107
108 blob_zero(&vname);
109 do{
110 blob_reset(&vname);
111 blob_appendf(&vname, "%s~%d", zFile, cnt++);
112
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -99,13 +99,11 @@
99 }
100 blob_zero(&cmd);
101 blob_appendf(&cmd, "%s ", zExternalCommand);
102 }
103 zFile = g.argv[g.argc-1];
104 file_tree_name(zFile, &fname);
 
 
105
106 blob_zero(&vname);
107 do{
108 blob_reset(&vname);
109 blob_appendf(&vname, "%s~%d", zFile, cnt++);
110
+3 -2
--- src/file.c
+++ src/file.c
@@ -284,12 +284,12 @@
284284
}
285285
}
286286
287287
/*
288288
** Compute a pathname for a file relative to the root of the local
289
-** tree. Return TRUE on success and FALSE if the file is not contained
290
-** in the local tree.
289
+** tree. Return TRUE on success. On failure, print and error
290
+** message and quit.
291291
**
292292
** The root of the tree is defined by the g.zLocalRoot variable.
293293
*/
294294
int file_tree_name(const char *zOrigName, Blob *pOut){
295295
int n;
@@ -297,10 +297,11 @@
297297
db_must_be_within_tree();
298298
file_canonical_name(zOrigName, &full);
299299
n = strlen(g.zLocalRoot);
300300
if( blob_size(&full)<=n || memcmp(g.zLocalRoot, blob_buffer(&full), n) ){
301301
blob_reset(&full);
302
+ fossil_fatal("file outside of checkout tree: %s", zOrigName);
302303
return 0;
303304
}
304305
blob_zero(pOut);
305306
blob_append(pOut, blob_buffer(&full)+n, blob_size(&full)-n);
306307
return 1;
307308
--- src/file.c
+++ src/file.c
@@ -284,12 +284,12 @@
284 }
285 }
286
287 /*
288 ** Compute a pathname for a file relative to the root of the local
289 ** tree. Return TRUE on success and FALSE if the file is not contained
290 ** in the local tree.
291 **
292 ** The root of the tree is defined by the g.zLocalRoot variable.
293 */
294 int file_tree_name(const char *zOrigName, Blob *pOut){
295 int n;
@@ -297,10 +297,11 @@
297 db_must_be_within_tree();
298 file_canonical_name(zOrigName, &full);
299 n = strlen(g.zLocalRoot);
300 if( blob_size(&full)<=n || memcmp(g.zLocalRoot, blob_buffer(&full), n) ){
301 blob_reset(&full);
 
302 return 0;
303 }
304 blob_zero(pOut);
305 blob_append(pOut, blob_buffer(&full)+n, blob_size(&full)-n);
306 return 1;
307
--- src/file.c
+++ src/file.c
@@ -284,12 +284,12 @@
284 }
285 }
286
287 /*
288 ** Compute a pathname for a file relative to the root of the local
289 ** tree. Return TRUE on success. On failure, print and error
290 ** message and quit.
291 **
292 ** The root of the tree is defined by the g.zLocalRoot variable.
293 */
294 int file_tree_name(const char *zOrigName, Blob *pOut){
295 int n;
@@ -297,10 +297,11 @@
297 db_must_be_within_tree();
298 file_canonical_name(zOrigName, &full);
299 n = strlen(g.zLocalRoot);
300 if( blob_size(&full)<=n || memcmp(g.zLocalRoot, blob_buffer(&full), n) ){
301 blob_reset(&full);
302 fossil_fatal("file outside of checkout tree: %s", zOrigName);
303 return 0;
304 }
305 blob_zero(pOut);
306 blob_append(pOut, blob_buffer(&full)+n, blob_size(&full)-n);
307 return 1;
308
+1 -3
--- src/update.c
+++ src/update.c
@@ -303,13 +303,11 @@
303303
}
304304
db_must_be_within_tree();
305305
306306
zFile = mprintf("%/", g.argv[g.argc-1]);
307307
308
- if( !file_tree_name(zFile, &fname) ){
309
- fossil_panic("unknown file: %s", zFile);
310
- }
308
+ file_tree_name(zFile, &fname);
311309
312310
if( access(zFile, 0) ) yesRevert = 1;
313311
if( yesRevert==0 ){
314312
char *prompt = mprintf("revert file %B? this will"
315313
" destroy local changes [y/N]? ",
316314
--- src/update.c
+++ src/update.c
@@ -303,13 +303,11 @@
303 }
304 db_must_be_within_tree();
305
306 zFile = mprintf("%/", g.argv[g.argc-1]);
307
308 if( !file_tree_name(zFile, &fname) ){
309 fossil_panic("unknown file: %s", zFile);
310 }
311
312 if( access(zFile, 0) ) yesRevert = 1;
313 if( yesRevert==0 ){
314 char *prompt = mprintf("revert file %B? this will"
315 " destroy local changes [y/N]? ",
316
--- src/update.c
+++ src/update.c
@@ -303,13 +303,11 @@
303 }
304 db_must_be_within_tree();
305
306 zFile = mprintf("%/", g.argv[g.argc-1]);
307
308 file_tree_name(zFile, &fname);
 
 
309
310 if( access(zFile, 0) ) yesRevert = 1;
311 if( yesRevert==0 ){
312 char *prompt = mprintf("revert file %B? this will"
313 " destroy local changes [y/N]? ",
314
-1
--- src/wiki.c
+++ src/wiki.c
@@ -596,6 +596,5 @@
596596
@ disables all wiki formatting rules through the matching
597597
@ &lt;/nowiki&gt; element.
598598
@ </ol>
599599
style_footer();
600600
}
601
-
602601
--- src/wiki.c
+++ src/wiki.c
@@ -596,6 +596,5 @@
596 @ disables all wiki formatting rules through the matching
597 @ &lt;/nowiki&gt; element.
598 @ </ol>
599 style_footer();
600 }
601
602
--- src/wiki.c
+++ src/wiki.c
@@ -596,6 +596,5 @@
596 @ disables all wiki formatting rules through the matching
597 @ &lt;/nowiki&gt; element.
598 @ </ol>
599 style_footer();
600 }
 
601

Keyboard Shortcuts

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