36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
**
** Make arrangements to add one or more files to the current checkout
** at the next commit.
*/
void add_cmd(void){
int i;
int vid;
db_must_be_within_tree();
vid = db_lget_int("checkout",0);
if( vid==0 ){
fossil_panic("no checkout to add to");
}
db_begin_transaction();
for(i=2; i<g.argc; i++){
char *zName;
char *zPath;
Blob pathname;
int isDir;
zName = mprintf("%/", g.argv[i]);
isDir = file_isdir(zName);
if( isDir==1 ) continue;
if( isDir==0 ){
fossil_fatal("not found: %s", zName);
}
if( isDir==2 && access(zName, R_OK) ){
fossil_fatal("cannot open %s", zName);
}
file_tree_name(zName, &pathname, 1);
zPath = blob_str(&pathname);
if( strcmp(zPath, "manifest")==0
|| strcmp(zPath, "_FOSSIL_")==0
|| strcmp(zPath, "manifest.uuid")==0
){
fossil_warning("cannot add %s", zPath);
}else{
if( !file_is_simple_pathname(zPath) ){
fossil_fatal("filename contains illegal characters: %s", zPath);
}
if( db_exists("SELECT 1 FROM vfile WHERE pathname=%Q", zPath) ){
|
>
>
>
>
>
|
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
**
** Make arrangements to add one or more files to the current checkout
** at the next commit.
*/
void add_cmd(void){
int i;
int vid;
Blob repo;
db_must_be_within_tree();
vid = db_lget_int("checkout",0);
if( vid==0 ){
fossil_panic("no checkout to add to");
}
db_begin_transaction();
if( !file_tree_name(g.zRepositoryName, &repo, 0) ){
blob_zero(&repo);
}
for(i=2; i<g.argc; i++){
char *zName;
char *zPath;
Blob pathname;
int isDir;
zName = mprintf("%/", g.argv[i]);
isDir = file_isdir(zName);
if( isDir==1 ) continue;
if( isDir==0 ){
fossil_fatal("not found: %s", zName);
}
if( isDir==2 && access(zName, R_OK) ){
fossil_fatal("cannot open %s", zName);
}
file_tree_name(zName, &pathname, 1);
zPath = blob_str(&pathname);
if( strcmp(zPath, "manifest")==0
|| strcmp(zPath, "_FOSSIL_")==0
|| strcmp(zPath, "manifest.uuid")==0
|| blob_compare(&pathname, &repo)==0
){
fossil_warning("cannot add %s", zPath);
}else{
if( !file_is_simple_pathname(zPath) ){
fossil_fatal("filename contains illegal characters: %s", zPath);
}
if( db_exists("SELECT 1 FROM vfile WHERE pathname=%Q", zPath) ){
|