Fossil SCM

modified fix for [c8c0b78c84], which no longer causes "Usage" printouts to use the full fossil path, even though the command line didn't use the full path

jan.nijtmans 2012-09-24 09:03 trunk
Commit dacc6946157383da12b3cf650eea6a3e671b3a64
+1 -1
--- src/allrepo.c
+++ src/allrepo.c
@@ -147,11 +147,11 @@
147147
}else{
148148
fossil_fatal("\"all\" subcommand should be one of: "
149149
"changes ignore list ls push pull rebuild sync");
150150
}
151151
verify_all_options();
152
- zFossil = quoteFilename(fossil_nameofexe());
152
+ zFossil = quoteFilename(g.nameOfExe);
153153
if( useCheckouts ){
154154
db_prepare(&q,
155155
"SELECT substr(name, 7) COLLATE nocase, max(rowid)"
156156
" FROM global_config"
157157
" WHERE substr(name, 1, 6)=='ckout:'"
158158
--- src/allrepo.c
+++ src/allrepo.c
@@ -147,11 +147,11 @@
147 }else{
148 fossil_fatal("\"all\" subcommand should be one of: "
149 "changes ignore list ls push pull rebuild sync");
150 }
151 verify_all_options();
152 zFossil = quoteFilename(fossil_nameofexe());
153 if( useCheckouts ){
154 db_prepare(&q,
155 "SELECT substr(name, 7) COLLATE nocase, max(rowid)"
156 " FROM global_config"
157 " WHERE substr(name, 1, 6)=='ckout:'"
158
--- src/allrepo.c
+++ src/allrepo.c
@@ -147,11 +147,11 @@
147 }else{
148 fossil_fatal("\"all\" subcommand should be one of: "
149 "changes ignore list ls push pull rebuild sync");
150 }
151 verify_all_options();
152 zFossil = quoteFilename(g.nameOfExe);
153 if( useCheckouts ){
154 db_prepare(&q,
155 "SELECT substr(name, 7) COLLATE nocase, max(rowid)"
156 " FROM global_config"
157 " WHERE substr(name, 1, 6)=='ckout:'"
158
+7 -7
--- src/branch.c
+++ src/branch.c
@@ -40,23 +40,23 @@
4040
Manifest *pParent; /* Parsed parent manifest */
4141
Blob mcksum; /* Self-checksum on the manifest */
4242
const char *zDateOvrd; /* Override date string */
4343
const char *zUserOvrd; /* Override user name */
4444
int isPrivate = 0; /* True if the branch should be private */
45
-
45
+
4646
noSign = find_option("nosign","",0)!=0;
4747
zColor = find_option("bgcolor","c",1);
4848
isPrivate = find_option("private",0,0)!=0;
4949
zDateOvrd = find_option("date-override",0,1);
5050
zUserOvrd = find_option("user-override",0,1);
5151
verify_all_options();
5252
if( g.argc<5 ){
5353
usage("new BRANCH-NAME BASIS ?OPTIONS?");
5454
}
55
- db_find_and_open_repository(0, 0);
55
+ db_find_and_open_repository(0, 0);
5656
noSign = db_get_int("omitsign", 0)|noSign;
57
-
57
+
5858
/* fossil branch new name */
5959
zBranch = g.argv[3];
6060
if( zBranch==0 || zBranch[0]==0 ){
6161
fossil_panic("branch name cannot be empty");
6262
}
@@ -132,11 +132,11 @@
132132
while( db_step(&q)==SQLITE_ROW ){
133133
const char *zTag = db_column_text(&q, 0);
134134
blob_appendf(&branch, "T -%F *\n", zTag);
135135
}
136136
db_finalize(&q);
137
-
137
+
138138
blob_appendf(&branch, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin);
139139
md5sum_blob(&branch, &mcksum);
140140
blob_appendf(&branch, "Z %b\n", &mcksum);
141141
if( !noSign && clearsign(&branch, &branch) ){
142142
Blob ans;
@@ -165,18 +165,18 @@
165165
"\n"
166166
"Note: the local check-out has not been updated to the new\n"
167167
" branch. To begin working on the new branch, do this:\n"
168168
"\n"
169169
" %s update %s\n",
170
- fossil_nameofexe(), zBranch
170
+ g.argv[0], zBranch
171171
);
172172
}
173173
174174
175175
/* Commit */
176176
db_end_transaction(0);
177
-
177
+
178178
/* Do an autosync push, if requested */
179179
if( !isPrivate ) autosync(AUTOSYNC_PUSH);
180180
}
181181
182182
/*
@@ -381,11 +381,11 @@
381381
** to the end of the line.
382382
*/
383383
static void brtimeline_extra(int rid){
384384
Stmt q;
385385
if( !g.perm.Hyperlink ) return;
386
- db_prepare(&q,
386
+ db_prepare(&q,
387387
"SELECT substr(tagname,5) FROM tagxref, tag"
388388
" WHERE tagxref.rid=%d"
389389
" AND tagxref.tagid=tag.tagid"
390390
" AND tagxref.tagtype>0"
391391
" AND tag.tagname GLOB 'sym-*'",
392392
--- src/branch.c
+++ src/branch.c
@@ -40,23 +40,23 @@
40 Manifest *pParent; /* Parsed parent manifest */
41 Blob mcksum; /* Self-checksum on the manifest */
42 const char *zDateOvrd; /* Override date string */
43 const char *zUserOvrd; /* Override user name */
44 int isPrivate = 0; /* True if the branch should be private */
45
46 noSign = find_option("nosign","",0)!=0;
47 zColor = find_option("bgcolor","c",1);
48 isPrivate = find_option("private",0,0)!=0;
49 zDateOvrd = find_option("date-override",0,1);
50 zUserOvrd = find_option("user-override",0,1);
51 verify_all_options();
52 if( g.argc<5 ){
53 usage("new BRANCH-NAME BASIS ?OPTIONS?");
54 }
55 db_find_and_open_repository(0, 0);
56 noSign = db_get_int("omitsign", 0)|noSign;
57
58 /* fossil branch new name */
59 zBranch = g.argv[3];
60 if( zBranch==0 || zBranch[0]==0 ){
61 fossil_panic("branch name cannot be empty");
62 }
@@ -132,11 +132,11 @@
132 while( db_step(&q)==SQLITE_ROW ){
133 const char *zTag = db_column_text(&q, 0);
134 blob_appendf(&branch, "T -%F *\n", zTag);
135 }
136 db_finalize(&q);
137
138 blob_appendf(&branch, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin);
139 md5sum_blob(&branch, &mcksum);
140 blob_appendf(&branch, "Z %b\n", &mcksum);
141 if( !noSign && clearsign(&branch, &branch) ){
142 Blob ans;
@@ -165,18 +165,18 @@
165 "\n"
166 "Note: the local check-out has not been updated to the new\n"
167 " branch. To begin working on the new branch, do this:\n"
168 "\n"
169 " %s update %s\n",
170 fossil_nameofexe(), zBranch
171 );
172 }
173
174
175 /* Commit */
176 db_end_transaction(0);
177
178 /* Do an autosync push, if requested */
179 if( !isPrivate ) autosync(AUTOSYNC_PUSH);
180 }
181
182 /*
@@ -381,11 +381,11 @@
381 ** to the end of the line.
382 */
383 static void brtimeline_extra(int rid){
384 Stmt q;
385 if( !g.perm.Hyperlink ) return;
386 db_prepare(&q,
387 "SELECT substr(tagname,5) FROM tagxref, tag"
388 " WHERE tagxref.rid=%d"
389 " AND tagxref.tagid=tag.tagid"
390 " AND tagxref.tagtype>0"
391 " AND tag.tagname GLOB 'sym-*'",
392
--- src/branch.c
+++ src/branch.c
@@ -40,23 +40,23 @@
40 Manifest *pParent; /* Parsed parent manifest */
41 Blob mcksum; /* Self-checksum on the manifest */
42 const char *zDateOvrd; /* Override date string */
43 const char *zUserOvrd; /* Override user name */
44 int isPrivate = 0; /* True if the branch should be private */
45
46 noSign = find_option("nosign","",0)!=0;
47 zColor = find_option("bgcolor","c",1);
48 isPrivate = find_option("private",0,0)!=0;
49 zDateOvrd = find_option("date-override",0,1);
50 zUserOvrd = find_option("user-override",0,1);
51 verify_all_options();
52 if( g.argc<5 ){
53 usage("new BRANCH-NAME BASIS ?OPTIONS?");
54 }
55 db_find_and_open_repository(0, 0);
56 noSign = db_get_int("omitsign", 0)|noSign;
57
58 /* fossil branch new name */
59 zBranch = g.argv[3];
60 if( zBranch==0 || zBranch[0]==0 ){
61 fossil_panic("branch name cannot be empty");
62 }
@@ -132,11 +132,11 @@
132 while( db_step(&q)==SQLITE_ROW ){
133 const char *zTag = db_column_text(&q, 0);
134 blob_appendf(&branch, "T -%F *\n", zTag);
135 }
136 db_finalize(&q);
137
138 blob_appendf(&branch, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin);
139 md5sum_blob(&branch, &mcksum);
140 blob_appendf(&branch, "Z %b\n", &mcksum);
141 if( !noSign && clearsign(&branch, &branch) ){
142 Blob ans;
@@ -165,18 +165,18 @@
165 "\n"
166 "Note: the local check-out has not been updated to the new\n"
167 " branch. To begin working on the new branch, do this:\n"
168 "\n"
169 " %s update %s\n",
170 g.argv[0], zBranch
171 );
172 }
173
174
175 /* Commit */
176 db_end_transaction(0);
177
178 /* Do an autosync push, if requested */
179 if( !isPrivate ) autosync(AUTOSYNC_PUSH);
180 }
181
182 /*
@@ -381,11 +381,11 @@
381 ** to the end of the line.
382 */
383 static void brtimeline_extra(int rid){
384 Stmt q;
385 if( !g.perm.Hyperlink ) return;
386 db_prepare(&q,
387 "SELECT substr(tagname,5) FROM tagxref, tag"
388 " WHERE tagxref.rid=%d"
389 " AND tagxref.tagid=tag.tagid"
390 " AND tagxref.tagtype>0"
391 " AND tag.tagname GLOB 'sym-*'",
392
+15 -15
--- src/configure.c
+++ src/configure.c
@@ -66,11 +66,11 @@
6666
};
6767
6868
6969
/*
7070
** The following is a list of settings that we are willing to
71
-** transfer.
71
+** transfer.
7272
**
7373
** Setting names that begin with an alphabetic characters refer to
7474
** single entries in the CONFIG table. Setting names that begin with
7575
** "@" are for special processing.
7676
*/
@@ -222,28 +222,28 @@
222222
void configure_render_special_name(const char *zName, Blob *pOut){
223223
Stmt q;
224224
if( fossil_strcmp(zName, "@shun")==0 ){
225225
db_prepare(&q, "SELECT uuid FROM shun");
226226
while( db_step(&q)==SQLITE_ROW ){
227
- blob_appendf(pOut, "INSERT OR IGNORE INTO shun VALUES('%s');\n",
227
+ blob_appendf(pOut, "INSERT OR IGNORE INTO shun VALUES('%s');\n",
228228
db_column_text(&q, 0)
229229
);
230230
}
231231
db_finalize(&q);
232232
}else if( fossil_strcmp(zName, "@reportfmt")==0 ){
233233
db_prepare(&q, "SELECT title, cols, sqlcode FROM reportfmt");
234234
while( db_step(&q)==SQLITE_ROW ){
235235
blob_appendf(pOut, "INSERT INTO _xfer_reportfmt(title,cols,sqlcode)"
236
- " VALUES(%Q,%Q,%Q);\n",
236
+ " VALUES(%Q,%Q,%Q);\n",
237237
db_column_text(&q, 0),
238238
db_column_text(&q, 1),
239239
db_column_text(&q, 2)
240240
);
241241
}
242242
db_finalize(&q);
243243
}else if( fossil_strcmp(zName, "@user")==0 ){
244
- db_prepare(&q,
244
+ db_prepare(&q,
245245
"SELECT login, CASE WHEN length(pw)==40 THEN pw END,"
246246
" cap, info, quote(photo) FROM user");
247247
while( db_step(&q)==SQLITE_ROW ){
248248
blob_appendf(pOut, "INSERT INTO _xfer_user(login,pw,cap,info,photo)"
249249
" VALUES(%Q,%Q,%Q,%Q,%s);\n",
@@ -274,11 +274,11 @@
274274
** config_is_reset(int)
275275
** config_reset(int)
276276
**
277277
** The config_is_reset() function takes the integer valued argument and
278278
** ANDs it against the static variable "configHasBeenReset" below. The
279
-** function returns TRUE or FALSE depending on the result depending on
279
+** function returns TRUE or FALSE depending on the result depending on
280280
** whether or not the corresponding configuration table has been reset. The
281281
** config_reset() function adds the bits to "configHasBeenReset" that
282282
** are given in the argument.
283283
**
284284
** These functions are used below in the WHEN clause of a trigger to
@@ -337,11 +337,11 @@
337337
@ SELECT rn,owner,title,cols,sqlcode FROM reportfmt;
338338
@ INSERT INTO _xfer_user
339339
@ SELECT uid,login,pw,cap,cookie,ipaddr,cexpire,info,photo FROM user;
340340
;
341341
db_multi_exec(zSQL1);
342
-
342
+
343343
/* When the replace flag is set, add triggers that run the first time
344344
** that new data is seen. The triggers run only once and delete all the
345345
** existing data.
346346
*/
347347
if( replaceFlag ){
@@ -441,11 +441,11 @@
441441
** transferred. pContent is a string that consist of alternating Fossil
442442
** and SQL tokens. The First token is a timestamp in seconds since 1970.
443443
** The second token is a primary key for the table identified by zName. If
444444
** The entry with the corresponding primary key exists and has a more recent
445445
** mtime, then nothing happens. If the entry does not exist or if it has
446
-** an older mtime, then the content described by subsequent token pairs is
446
+** an older mtime, then the content described by subsequent token pairs is
447447
** inserted. The first element of each token pair is a column name and
448448
** the second is its value.
449449
**
450450
** In overview, we have:
451451
**
@@ -519,11 +519,11 @@
519519
thisMask = configure_is_exportable(azToken[1]);
520520
}else{
521521
thisMask = configure_is_exportable(aType[ii].zName);
522522
}
523523
if( (thisMask & groupMask)==0 ) return;
524
-
524
+
525525
blob_zero(&sql);
526526
if( groupMask & CONFIGSET_OVERWRITE ){
527527
if( (thisMask & configHasBeenReset)==0 && aType[ii].zName[0]!='/' ){
528528
db_multi_exec("DELETE FROM %s", &aType[ii].zName[1]);
529529
configHasBeenReset |= thisMask;
@@ -606,11 +606,11 @@
606606
blob_reset(&content);
607607
blob_seek(pIn, 1, BLOB_SEEK_CUR);
608608
}
609609
}
610610
}
611
-
611
+
612612
613613
/*
614614
** Send "config" cards using the new format for all elements of a group
615615
** that have recently changed.
616616
**
@@ -756,11 +756,11 @@
756756
sqlite3_int64 iStart, /* Start date */
757757
const char *zFilename /* Write into this file */
758758
){
759759
Blob out;
760760
blob_zero(&out);
761
- blob_appendf(&out,
761
+ blob_appendf(&out,
762762
"# The \"%s\" configuration exported from\n"
763763
"# repository \"%s\"\n"
764764
"# on %s\n",
765765
zMask, g.zRepositoryName,
766766
db_text(0, "SELECT datetime('now')")
@@ -817,11 +817,11 @@
817817
** Restore the configuration to the default. AREA as above.
818818
**
819819
** %fossil configuration sync AREA ?URL?
820820
**
821821
** Synchronize configuration changes in the local repository with
822
-** the remote repository at URL.
822
+** the remote repository at URL.
823823
**
824824
** Options:
825825
** -R|--repository FILE Extract info from repository FILE
826826
**
827827
** See also: settings, unset
@@ -852,11 +852,11 @@
852852
}else{
853853
iStart = 0;
854854
}
855855
export_config(mask, g.argv[3], iStart, g.argv[4]);
856856
}else
857
- if( strncmp(zMethod, "import", n)==0
857
+ if( strncmp(zMethod, "import", n)==0
858858
|| strncmp(zMethod, "merge", n)==0 ){
859859
Blob in;
860860
int groupMask;
861861
if( g.argc!=4 ) usage(mprintf("%s FILENAME",zMethod));
862862
blob_read_from_file(&in, g.argv[3]);
@@ -915,11 +915,11 @@
915915
if( strncmp(zMethod, "reset", n)==0 ){
916916
int mask, i;
917917
char *zBackup;
918918
if( g.argc!=4 ) usage("reset AREA");
919919
mask = configure_name_to_mask(g.argv[3], 1);
920
- zBackup = db_text(0,
920
+ zBackup = db_text(0,
921921
"SELECT strftime('config-backup-%%Y%%m%%d%%H%%M%%f','now')");
922922
db_begin_transaction();
923923
export_config(mask, g.argv[3], 0, zBackup);
924924
for(i=0; i<count(aConfig); i++){
925925
const char *zName = aConfig[i].zName;
@@ -937,13 +937,13 @@
937937
db_multi_exec("DELETE FROM reportfmt");
938938
}
939939
}
940940
db_end_transaction(0);
941941
fossil_print("Configuration reset to factory defaults.\n");
942
- fossil_print("To recover, use: %s %s import %s\n",
943
- fossil_nameofexe(), g.argv[1], zBackup);
942
+ fossil_print("To recover, use: %s %s import %s\n",
943
+ g.argv[0], g.argv[1], zBackup);
944944
}else
945945
{
946946
fossil_fatal("METHOD should be one of:"
947947
" export import merge pull push reset");
948948
}
949949
}
950950
--- src/configure.c
+++ src/configure.c
@@ -66,11 +66,11 @@
66 };
67
68
69 /*
70 ** The following is a list of settings that we are willing to
71 ** transfer.
72 **
73 ** Setting names that begin with an alphabetic characters refer to
74 ** single entries in the CONFIG table. Setting names that begin with
75 ** "@" are for special processing.
76 */
@@ -222,28 +222,28 @@
222 void configure_render_special_name(const char *zName, Blob *pOut){
223 Stmt q;
224 if( fossil_strcmp(zName, "@shun")==0 ){
225 db_prepare(&q, "SELECT uuid FROM shun");
226 while( db_step(&q)==SQLITE_ROW ){
227 blob_appendf(pOut, "INSERT OR IGNORE INTO shun VALUES('%s');\n",
228 db_column_text(&q, 0)
229 );
230 }
231 db_finalize(&q);
232 }else if( fossil_strcmp(zName, "@reportfmt")==0 ){
233 db_prepare(&q, "SELECT title, cols, sqlcode FROM reportfmt");
234 while( db_step(&q)==SQLITE_ROW ){
235 blob_appendf(pOut, "INSERT INTO _xfer_reportfmt(title,cols,sqlcode)"
236 " VALUES(%Q,%Q,%Q);\n",
237 db_column_text(&q, 0),
238 db_column_text(&q, 1),
239 db_column_text(&q, 2)
240 );
241 }
242 db_finalize(&q);
243 }else if( fossil_strcmp(zName, "@user")==0 ){
244 db_prepare(&q,
245 "SELECT login, CASE WHEN length(pw)==40 THEN pw END,"
246 " cap, info, quote(photo) FROM user");
247 while( db_step(&q)==SQLITE_ROW ){
248 blob_appendf(pOut, "INSERT INTO _xfer_user(login,pw,cap,info,photo)"
249 " VALUES(%Q,%Q,%Q,%Q,%s);\n",
@@ -274,11 +274,11 @@
274 ** config_is_reset(int)
275 ** config_reset(int)
276 **
277 ** The config_is_reset() function takes the integer valued argument and
278 ** ANDs it against the static variable "configHasBeenReset" below. The
279 ** function returns TRUE or FALSE depending on the result depending on
280 ** whether or not the corresponding configuration table has been reset. The
281 ** config_reset() function adds the bits to "configHasBeenReset" that
282 ** are given in the argument.
283 **
284 ** These functions are used below in the WHEN clause of a trigger to
@@ -337,11 +337,11 @@
337 @ SELECT rn,owner,title,cols,sqlcode FROM reportfmt;
338 @ INSERT INTO _xfer_user
339 @ SELECT uid,login,pw,cap,cookie,ipaddr,cexpire,info,photo FROM user;
340 ;
341 db_multi_exec(zSQL1);
342
343 /* When the replace flag is set, add triggers that run the first time
344 ** that new data is seen. The triggers run only once and delete all the
345 ** existing data.
346 */
347 if( replaceFlag ){
@@ -441,11 +441,11 @@
441 ** transferred. pContent is a string that consist of alternating Fossil
442 ** and SQL tokens. The First token is a timestamp in seconds since 1970.
443 ** The second token is a primary key for the table identified by zName. If
444 ** The entry with the corresponding primary key exists and has a more recent
445 ** mtime, then nothing happens. If the entry does not exist or if it has
446 ** an older mtime, then the content described by subsequent token pairs is
447 ** inserted. The first element of each token pair is a column name and
448 ** the second is its value.
449 **
450 ** In overview, we have:
451 **
@@ -519,11 +519,11 @@
519 thisMask = configure_is_exportable(azToken[1]);
520 }else{
521 thisMask = configure_is_exportable(aType[ii].zName);
522 }
523 if( (thisMask & groupMask)==0 ) return;
524
525 blob_zero(&sql);
526 if( groupMask & CONFIGSET_OVERWRITE ){
527 if( (thisMask & configHasBeenReset)==0 && aType[ii].zName[0]!='/' ){
528 db_multi_exec("DELETE FROM %s", &aType[ii].zName[1]);
529 configHasBeenReset |= thisMask;
@@ -606,11 +606,11 @@
606 blob_reset(&content);
607 blob_seek(pIn, 1, BLOB_SEEK_CUR);
608 }
609 }
610 }
611
612
613 /*
614 ** Send "config" cards using the new format for all elements of a group
615 ** that have recently changed.
616 **
@@ -756,11 +756,11 @@
756 sqlite3_int64 iStart, /* Start date */
757 const char *zFilename /* Write into this file */
758 ){
759 Blob out;
760 blob_zero(&out);
761 blob_appendf(&out,
762 "# The \"%s\" configuration exported from\n"
763 "# repository \"%s\"\n"
764 "# on %s\n",
765 zMask, g.zRepositoryName,
766 db_text(0, "SELECT datetime('now')")
@@ -817,11 +817,11 @@
817 ** Restore the configuration to the default. AREA as above.
818 **
819 ** %fossil configuration sync AREA ?URL?
820 **
821 ** Synchronize configuration changes in the local repository with
822 ** the remote repository at URL.
823 **
824 ** Options:
825 ** -R|--repository FILE Extract info from repository FILE
826 **
827 ** See also: settings, unset
@@ -852,11 +852,11 @@
852 }else{
853 iStart = 0;
854 }
855 export_config(mask, g.argv[3], iStart, g.argv[4]);
856 }else
857 if( strncmp(zMethod, "import", n)==0
858 || strncmp(zMethod, "merge", n)==0 ){
859 Blob in;
860 int groupMask;
861 if( g.argc!=4 ) usage(mprintf("%s FILENAME",zMethod));
862 blob_read_from_file(&in, g.argv[3]);
@@ -915,11 +915,11 @@
915 if( strncmp(zMethod, "reset", n)==0 ){
916 int mask, i;
917 char *zBackup;
918 if( g.argc!=4 ) usage("reset AREA");
919 mask = configure_name_to_mask(g.argv[3], 1);
920 zBackup = db_text(0,
921 "SELECT strftime('config-backup-%%Y%%m%%d%%H%%M%%f','now')");
922 db_begin_transaction();
923 export_config(mask, g.argv[3], 0, zBackup);
924 for(i=0; i<count(aConfig); i++){
925 const char *zName = aConfig[i].zName;
@@ -937,13 +937,13 @@
937 db_multi_exec("DELETE FROM reportfmt");
938 }
939 }
940 db_end_transaction(0);
941 fossil_print("Configuration reset to factory defaults.\n");
942 fossil_print("To recover, use: %s %s import %s\n",
943 fossil_nameofexe(), g.argv[1], zBackup);
944 }else
945 {
946 fossil_fatal("METHOD should be one of:"
947 " export import merge pull push reset");
948 }
949 }
950
--- src/configure.c
+++ src/configure.c
@@ -66,11 +66,11 @@
66 };
67
68
69 /*
70 ** The following is a list of settings that we are willing to
71 ** transfer.
72 **
73 ** Setting names that begin with an alphabetic characters refer to
74 ** single entries in the CONFIG table. Setting names that begin with
75 ** "@" are for special processing.
76 */
@@ -222,28 +222,28 @@
222 void configure_render_special_name(const char *zName, Blob *pOut){
223 Stmt q;
224 if( fossil_strcmp(zName, "@shun")==0 ){
225 db_prepare(&q, "SELECT uuid FROM shun");
226 while( db_step(&q)==SQLITE_ROW ){
227 blob_appendf(pOut, "INSERT OR IGNORE INTO shun VALUES('%s');\n",
228 db_column_text(&q, 0)
229 );
230 }
231 db_finalize(&q);
232 }else if( fossil_strcmp(zName, "@reportfmt")==0 ){
233 db_prepare(&q, "SELECT title, cols, sqlcode FROM reportfmt");
234 while( db_step(&q)==SQLITE_ROW ){
235 blob_appendf(pOut, "INSERT INTO _xfer_reportfmt(title,cols,sqlcode)"
236 " VALUES(%Q,%Q,%Q);\n",
237 db_column_text(&q, 0),
238 db_column_text(&q, 1),
239 db_column_text(&q, 2)
240 );
241 }
242 db_finalize(&q);
243 }else if( fossil_strcmp(zName, "@user")==0 ){
244 db_prepare(&q,
245 "SELECT login, CASE WHEN length(pw)==40 THEN pw END,"
246 " cap, info, quote(photo) FROM user");
247 while( db_step(&q)==SQLITE_ROW ){
248 blob_appendf(pOut, "INSERT INTO _xfer_user(login,pw,cap,info,photo)"
249 " VALUES(%Q,%Q,%Q,%Q,%s);\n",
@@ -274,11 +274,11 @@
274 ** config_is_reset(int)
275 ** config_reset(int)
276 **
277 ** The config_is_reset() function takes the integer valued argument and
278 ** ANDs it against the static variable "configHasBeenReset" below. The
279 ** function returns TRUE or FALSE depending on the result depending on
280 ** whether or not the corresponding configuration table has been reset. The
281 ** config_reset() function adds the bits to "configHasBeenReset" that
282 ** are given in the argument.
283 **
284 ** These functions are used below in the WHEN clause of a trigger to
@@ -337,11 +337,11 @@
337 @ SELECT rn,owner,title,cols,sqlcode FROM reportfmt;
338 @ INSERT INTO _xfer_user
339 @ SELECT uid,login,pw,cap,cookie,ipaddr,cexpire,info,photo FROM user;
340 ;
341 db_multi_exec(zSQL1);
342
343 /* When the replace flag is set, add triggers that run the first time
344 ** that new data is seen. The triggers run only once and delete all the
345 ** existing data.
346 */
347 if( replaceFlag ){
@@ -441,11 +441,11 @@
441 ** transferred. pContent is a string that consist of alternating Fossil
442 ** and SQL tokens. The First token is a timestamp in seconds since 1970.
443 ** The second token is a primary key for the table identified by zName. If
444 ** The entry with the corresponding primary key exists and has a more recent
445 ** mtime, then nothing happens. If the entry does not exist or if it has
446 ** an older mtime, then the content described by subsequent token pairs is
447 ** inserted. The first element of each token pair is a column name and
448 ** the second is its value.
449 **
450 ** In overview, we have:
451 **
@@ -519,11 +519,11 @@
519 thisMask = configure_is_exportable(azToken[1]);
520 }else{
521 thisMask = configure_is_exportable(aType[ii].zName);
522 }
523 if( (thisMask & groupMask)==0 ) return;
524
525 blob_zero(&sql);
526 if( groupMask & CONFIGSET_OVERWRITE ){
527 if( (thisMask & configHasBeenReset)==0 && aType[ii].zName[0]!='/' ){
528 db_multi_exec("DELETE FROM %s", &aType[ii].zName[1]);
529 configHasBeenReset |= thisMask;
@@ -606,11 +606,11 @@
606 blob_reset(&content);
607 blob_seek(pIn, 1, BLOB_SEEK_CUR);
608 }
609 }
610 }
611
612
613 /*
614 ** Send "config" cards using the new format for all elements of a group
615 ** that have recently changed.
616 **
@@ -756,11 +756,11 @@
756 sqlite3_int64 iStart, /* Start date */
757 const char *zFilename /* Write into this file */
758 ){
759 Blob out;
760 blob_zero(&out);
761 blob_appendf(&out,
762 "# The \"%s\" configuration exported from\n"
763 "# repository \"%s\"\n"
764 "# on %s\n",
765 zMask, g.zRepositoryName,
766 db_text(0, "SELECT datetime('now')")
@@ -817,11 +817,11 @@
817 ** Restore the configuration to the default. AREA as above.
818 **
819 ** %fossil configuration sync AREA ?URL?
820 **
821 ** Synchronize configuration changes in the local repository with
822 ** the remote repository at URL.
823 **
824 ** Options:
825 ** -R|--repository FILE Extract info from repository FILE
826 **
827 ** See also: settings, unset
@@ -852,11 +852,11 @@
852 }else{
853 iStart = 0;
854 }
855 export_config(mask, g.argv[3], iStart, g.argv[4]);
856 }else
857 if( strncmp(zMethod, "import", n)==0
858 || strncmp(zMethod, "merge", n)==0 ){
859 Blob in;
860 int groupMask;
861 if( g.argc!=4 ) usage(mprintf("%s FILENAME",zMethod));
862 blob_read_from_file(&in, g.argv[3]);
@@ -915,11 +915,11 @@
915 if( strncmp(zMethod, "reset", n)==0 ){
916 int mask, i;
917 char *zBackup;
918 if( g.argc!=4 ) usage("reset AREA");
919 mask = configure_name_to_mask(g.argv[3], 1);
920 zBackup = db_text(0,
921 "SELECT strftime('config-backup-%%Y%%m%%d%%H%%M%%f','now')");
922 db_begin_transaction();
923 export_config(mask, g.argv[3], 0, zBackup);
924 for(i=0; i<count(aConfig); i++){
925 const char *zName = aConfig[i].zName;
@@ -937,13 +937,13 @@
937 db_multi_exec("DELETE FROM reportfmt");
938 }
939 }
940 db_end_transaction(0);
941 fossil_print("Configuration reset to factory defaults.\n");
942 fossil_print("To recover, use: %s %s import %s\n",
943 g.argv[0], g.argv[1], zBackup);
944 }else
945 {
946 fossil_fatal("METHOD should be one of:"
947 " export import merge pull push reset");
948 }
949 }
950
+17 -17
--- src/db.c
+++ src/db.c
@@ -65,11 +65,11 @@
6565
*/
6666
static void db_err(const char *zFormat, ...){
6767
va_list ap;
6868
char *z;
6969
int rc = 1;
70
- static const char zRebuildMsg[] =
70
+ static const char zRebuildMsg[] =
7171
"If you have recently updated your fossil executable, you might\n"
7272
"need to run \"fossil all rebuild\" to bring the repository\n"
7373
"schemas up to date.\n";
7474
va_start(ap, zFormat);
7575
z = vmprintf(zFormat, ap);
@@ -92,11 +92,11 @@
9292
g.cgiOutput = 0;
9393
cgi_printf("<h1>Database Error</h1>\n"
9494
"<pre>%h</pre><p>%s</p>", z, zRebuildMsg);
9595
cgi_reply();
9696
}else{
97
- fprintf(stderr, "%s: %s\n\n%s", fossil_nameofexe(), z, zRebuildMsg);
97
+ fprintf(stderr, "%s: %s\n\n%s", g.argv[0], z, zRebuildMsg);
9898
}
9999
free(z);
100100
db_force_rollback();
101101
fossil_exit(rc);
102102
}
@@ -695,11 +695,11 @@
695695
zVfs
696696
);
697697
if( rc!=SQLITE_OK ){
698698
db_err(sqlite3_errmsg(db));
699699
}
700
- sqlite3_busy_timeout(db, 5000);
700
+ sqlite3_busy_timeout(db, 5000);
701701
sqlite3_wal_autocheckpoint(db, 1); /* Set to checkpoint frequently */
702702
sqlite3_create_function(db, "now", 0, SQLITE_ANY, 0, db_now_function, 0, 0);
703703
return db;
704704
}
705705
@@ -832,34 +832,34 @@
832832
if( lsize%1024!=0 || lsize<4096 ) return 0;
833833
db_open_or_attach(zDbName, "localdb");
834834
835835
/* If the "isexe" column is missing from the vfile table, then
836836
** add it now. This code added on 2010-03-06. After all users have
837
- ** upgraded, this code can be safely deleted.
837
+ ** upgraded, this code can be safely deleted.
838838
*/
839839
if( !db_local_column_exists("vfile", "isexe") ){
840840
db_multi_exec("ALTER TABLE vfile ADD COLUMN isexe BOOLEAN DEFAULT 0");
841841
}
842842
843843
/* If "islink"/"isLink" columns are missing from tables, then
844844
** add them now. This code added on 2011-01-17 and 2011-08-27.
845
- ** After all users have upgraded, this code can be safely deleted.
845
+ ** After all users have upgraded, this code can be safely deleted.
846846
*/
847847
if( !db_local_column_exists("vfile", "islink") ){
848848
db_multi_exec("ALTER TABLE vfile ADD COLUMN islink BOOLEAN DEFAULT 0");
849849
}
850
-
850
+
851851
if( !db_local_column_exists("stashfile", "isLink") &&
852852
db_local_table_exists("stashfile") ){
853853
db_multi_exec("ALTER TABLE stashfile ADD COLUMN isLink BOOLEAN DEFAULT 0");
854854
}
855855
856856
if( !db_local_column_exists("undo", "isLink") &&
857857
db_local_table_exists("undo") ){
858858
db_multi_exec("ALTER TABLE undo ADD COLUMN isLink BOOLEAN DEFAULT 0");
859859
}
860
-
860
+
861861
if( !db_local_column_exists("undo_vfile", "islink") &&
862862
db_local_table_exists("undo_vfile") ){
863863
db_multi_exec("ALTER TABLE undo_vfile ADD COLUMN islink BOOLEAN DEFAULT 0");
864864
}
865865
return 1;
@@ -871,11 +871,11 @@
871871
** that contains a valid repository database.
872872
**
873873
** For legacy, also look for ".fos". The use of ".fos" is deprecated
874874
** since "fos" has negative connotations in Hungarian, we are told.
875875
**
876
-** If no valid _FOSSIL_ or .fos file is found, we move up one level and
876
+** If no valid _FOSSIL_ or .fos file is found, we move up one level and
877877
** try again. Once the file is found, the g.zLocalRoot variable is set
878878
** to the root of the repository tree and this routine returns 1. If
879879
** no database is found, then this routine return 0.
880880
**
881881
** This routine always opens the user database regardless of whether or
@@ -883,12 +883,12 @@
883883
** is found, it is attached to the open database connection too.
884884
*/
885885
int db_open_local(void){
886886
int i, n;
887887
char zPwd[2000];
888
- static const char *aDbName[] = { "/_FOSSIL_", "/.fslckout", "/.fos" };
889
-
888
+ static const char *const aDbName[] = { "/_FOSSIL_", "/.fslckout", "/.fos" };
889
+
890890
if( g.localOpen) return 1;
891891
file_getcwd(zPwd, sizeof(zPwd)-20);
892892
n = strlen(zPwd);
893893
if( n==1 && zPwd[0]=='/' ) zPwd[0] = '.';
894894
while( n>0 ){
@@ -1397,11 +1397,11 @@
13971397
db_end_transaction(0);
13981398
if( zTemplate ) db_detach("settingSrc");
13991399
fossil_print("project-id: %s\n", db_get("project-code", 0));
14001400
fossil_print("server-id: %s\n", db_get("server-code", 0));
14011401
zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
1402
- fossil_print("admin-user: %s (initial password is \"%s\")\n",
1402
+ fossil_print("admin-user: %s (initial password is \"%s\")\n",
14031403
g.zLogin, zPassword);
14041404
}
14051405
14061406
/*
14071407
** SQL functions for debugging.
@@ -1443,11 +1443,11 @@
14431443
}
14441444
}
14451445
14461446
/*
14471447
** Implement the cgi() SQL function. cgi() takes a an argument which is
1448
-** a name of CGI query parameter. The value of that parameter is returned,
1448
+** a name of CGI query parameter. The value of that parameter is returned,
14491449
** if available. optional second argument will be returned if the first
14501450
** doesn't exist as a CGI parameter.
14511451
*/
14521452
static void db_sql_cgi(sqlite3_context *context, int argc, sqlite3_value **argv){
14531453
const char* zP;
@@ -1638,11 +1638,11 @@
16381638
struct _cacheEntry {
16391639
struct _cacheEntry *next;
16401640
const char *zName, *zValue;
16411641
} *cacheEntry = 0;
16421642
static struct _cacheEntry *cache = 0;
1643
-
1643
+
16441644
/* Look up name in cache */
16451645
cacheEntry = cache;
16461646
while( cacheEntry!=0 ){
16471647
if( fossil_strcmp(cacheEntry->zName, zName)==0 ){
16481648
zVersionedSetting = fossil_strdup(cacheEntry->zValue);
@@ -1865,11 +1865,11 @@
18651865
"REPLACE INTO global_config(name, value)"
18661866
"VALUES('ckout:%q','%q');",
18671867
blob_str(&localRoot), blob_str(&full)
18681868
);
18691869
db_swap_connections();
1870
- db_optional_sql("repository",
1870
+ db_optional_sql("repository",
18711871
"REPLACE INTO config(name,value,mtime)"
18721872
"VALUES('ckout:%q',1,now())",
18731873
blob_str(&localRoot)
18741874
);
18751875
blob_reset(&localRoot);
@@ -2064,11 +2064,11 @@
20642064
** The "unset" command clears a property setting.
20652065
**
20662066
**
20672067
** allow-symlinks If enabled, don't follow symlinks, and instead treat
20682068
** (versionable) them as symlinks on Unix. Has no effect on Windows
2069
-** (existing links in repository created on Unix become
2069
+** (existing links in repository created on Unix become
20702070
** plain-text files with link destination path inside).
20712071
** Default: off
20722072
**
20732073
** auto-captcha If enabled, the Login page provides a button to
20742074
** fill in the captcha password. Default: on
@@ -2212,11 +2212,11 @@
22122212
** and "firefox" on Unix.
22132213
**
22142214
** Options:
22152215
** --global set or unset the given property globally instead of
22162216
** setting or unsetting it for the open repository only.
2217
-**
2217
+**
22182218
** See also: configuration
22192219
*/
22202220
void setting_cmd(void){
22212221
int i;
22222222
int globalFlag = find_option("global","g",0)!=0;
@@ -2300,11 +2300,11 @@
23002300
** Print the approximate span of time from now to TIMESTAMP.
23012301
*/
23022302
void test_timespan_cmd(void){
23032303
double rDiff;
23042304
if( g.argc!=3 ) usage("TIMESTAMP");
2305
- sqlite3_open(":memory:", &g.db);
2305
+ sqlite3_open(":memory:", &g.db);
23062306
rDiff = db_double(0.0, "SELECT julianday('now') - julianday(%Q)", g.argv[2]);
23072307
fossil_print("Time differences: %s\n", db_timespan_name(rDiff));
23082308
sqlite3_close(g.db);
23092309
g.db = 0;
23102310
}
23112311
--- src/db.c
+++ src/db.c
@@ -65,11 +65,11 @@
65 */
66 static void db_err(const char *zFormat, ...){
67 va_list ap;
68 char *z;
69 int rc = 1;
70 static const char zRebuildMsg[] =
71 "If you have recently updated your fossil executable, you might\n"
72 "need to run \"fossil all rebuild\" to bring the repository\n"
73 "schemas up to date.\n";
74 va_start(ap, zFormat);
75 z = vmprintf(zFormat, ap);
@@ -92,11 +92,11 @@
92 g.cgiOutput = 0;
93 cgi_printf("<h1>Database Error</h1>\n"
94 "<pre>%h</pre><p>%s</p>", z, zRebuildMsg);
95 cgi_reply();
96 }else{
97 fprintf(stderr, "%s: %s\n\n%s", fossil_nameofexe(), z, zRebuildMsg);
98 }
99 free(z);
100 db_force_rollback();
101 fossil_exit(rc);
102 }
@@ -695,11 +695,11 @@
695 zVfs
696 );
697 if( rc!=SQLITE_OK ){
698 db_err(sqlite3_errmsg(db));
699 }
700 sqlite3_busy_timeout(db, 5000);
701 sqlite3_wal_autocheckpoint(db, 1); /* Set to checkpoint frequently */
702 sqlite3_create_function(db, "now", 0, SQLITE_ANY, 0, db_now_function, 0, 0);
703 return db;
704 }
705
@@ -832,34 +832,34 @@
832 if( lsize%1024!=0 || lsize<4096 ) return 0;
833 db_open_or_attach(zDbName, "localdb");
834
835 /* If the "isexe" column is missing from the vfile table, then
836 ** add it now. This code added on 2010-03-06. After all users have
837 ** upgraded, this code can be safely deleted.
838 */
839 if( !db_local_column_exists("vfile", "isexe") ){
840 db_multi_exec("ALTER TABLE vfile ADD COLUMN isexe BOOLEAN DEFAULT 0");
841 }
842
843 /* If "islink"/"isLink" columns are missing from tables, then
844 ** add them now. This code added on 2011-01-17 and 2011-08-27.
845 ** After all users have upgraded, this code can be safely deleted.
846 */
847 if( !db_local_column_exists("vfile", "islink") ){
848 db_multi_exec("ALTER TABLE vfile ADD COLUMN islink BOOLEAN DEFAULT 0");
849 }
850
851 if( !db_local_column_exists("stashfile", "isLink") &&
852 db_local_table_exists("stashfile") ){
853 db_multi_exec("ALTER TABLE stashfile ADD COLUMN isLink BOOLEAN DEFAULT 0");
854 }
855
856 if( !db_local_column_exists("undo", "isLink") &&
857 db_local_table_exists("undo") ){
858 db_multi_exec("ALTER TABLE undo ADD COLUMN isLink BOOLEAN DEFAULT 0");
859 }
860
861 if( !db_local_column_exists("undo_vfile", "islink") &&
862 db_local_table_exists("undo_vfile") ){
863 db_multi_exec("ALTER TABLE undo_vfile ADD COLUMN islink BOOLEAN DEFAULT 0");
864 }
865 return 1;
@@ -871,11 +871,11 @@
871 ** that contains a valid repository database.
872 **
873 ** For legacy, also look for ".fos". The use of ".fos" is deprecated
874 ** since "fos" has negative connotations in Hungarian, we are told.
875 **
876 ** If no valid _FOSSIL_ or .fos file is found, we move up one level and
877 ** try again. Once the file is found, the g.zLocalRoot variable is set
878 ** to the root of the repository tree and this routine returns 1. If
879 ** no database is found, then this routine return 0.
880 **
881 ** This routine always opens the user database regardless of whether or
@@ -883,12 +883,12 @@
883 ** is found, it is attached to the open database connection too.
884 */
885 int db_open_local(void){
886 int i, n;
887 char zPwd[2000];
888 static const char *aDbName[] = { "/_FOSSIL_", "/.fslckout", "/.fos" };
889
890 if( g.localOpen) return 1;
891 file_getcwd(zPwd, sizeof(zPwd)-20);
892 n = strlen(zPwd);
893 if( n==1 && zPwd[0]=='/' ) zPwd[0] = '.';
894 while( n>0 ){
@@ -1397,11 +1397,11 @@
1397 db_end_transaction(0);
1398 if( zTemplate ) db_detach("settingSrc");
1399 fossil_print("project-id: %s\n", db_get("project-code", 0));
1400 fossil_print("server-id: %s\n", db_get("server-code", 0));
1401 zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
1402 fossil_print("admin-user: %s (initial password is \"%s\")\n",
1403 g.zLogin, zPassword);
1404 }
1405
1406 /*
1407 ** SQL functions for debugging.
@@ -1443,11 +1443,11 @@
1443 }
1444 }
1445
1446 /*
1447 ** Implement the cgi() SQL function. cgi() takes a an argument which is
1448 ** a name of CGI query parameter. The value of that parameter is returned,
1449 ** if available. optional second argument will be returned if the first
1450 ** doesn't exist as a CGI parameter.
1451 */
1452 static void db_sql_cgi(sqlite3_context *context, int argc, sqlite3_value **argv){
1453 const char* zP;
@@ -1638,11 +1638,11 @@
1638 struct _cacheEntry {
1639 struct _cacheEntry *next;
1640 const char *zName, *zValue;
1641 } *cacheEntry = 0;
1642 static struct _cacheEntry *cache = 0;
1643
1644 /* Look up name in cache */
1645 cacheEntry = cache;
1646 while( cacheEntry!=0 ){
1647 if( fossil_strcmp(cacheEntry->zName, zName)==0 ){
1648 zVersionedSetting = fossil_strdup(cacheEntry->zValue);
@@ -1865,11 +1865,11 @@
1865 "REPLACE INTO global_config(name, value)"
1866 "VALUES('ckout:%q','%q');",
1867 blob_str(&localRoot), blob_str(&full)
1868 );
1869 db_swap_connections();
1870 db_optional_sql("repository",
1871 "REPLACE INTO config(name,value,mtime)"
1872 "VALUES('ckout:%q',1,now())",
1873 blob_str(&localRoot)
1874 );
1875 blob_reset(&localRoot);
@@ -2064,11 +2064,11 @@
2064 ** The "unset" command clears a property setting.
2065 **
2066 **
2067 ** allow-symlinks If enabled, don't follow symlinks, and instead treat
2068 ** (versionable) them as symlinks on Unix. Has no effect on Windows
2069 ** (existing links in repository created on Unix become
2070 ** plain-text files with link destination path inside).
2071 ** Default: off
2072 **
2073 ** auto-captcha If enabled, the Login page provides a button to
2074 ** fill in the captcha password. Default: on
@@ -2212,11 +2212,11 @@
2212 ** and "firefox" on Unix.
2213 **
2214 ** Options:
2215 ** --global set or unset the given property globally instead of
2216 ** setting or unsetting it for the open repository only.
2217 **
2218 ** See also: configuration
2219 */
2220 void setting_cmd(void){
2221 int i;
2222 int globalFlag = find_option("global","g",0)!=0;
@@ -2300,11 +2300,11 @@
2300 ** Print the approximate span of time from now to TIMESTAMP.
2301 */
2302 void test_timespan_cmd(void){
2303 double rDiff;
2304 if( g.argc!=3 ) usage("TIMESTAMP");
2305 sqlite3_open(":memory:", &g.db);
2306 rDiff = db_double(0.0, "SELECT julianday('now') - julianday(%Q)", g.argv[2]);
2307 fossil_print("Time differences: %s\n", db_timespan_name(rDiff));
2308 sqlite3_close(g.db);
2309 g.db = 0;
2310 }
2311
--- src/db.c
+++ src/db.c
@@ -65,11 +65,11 @@
65 */
66 static void db_err(const char *zFormat, ...){
67 va_list ap;
68 char *z;
69 int rc = 1;
70 static const char zRebuildMsg[] =
71 "If you have recently updated your fossil executable, you might\n"
72 "need to run \"fossil all rebuild\" to bring the repository\n"
73 "schemas up to date.\n";
74 va_start(ap, zFormat);
75 z = vmprintf(zFormat, ap);
@@ -92,11 +92,11 @@
92 g.cgiOutput = 0;
93 cgi_printf("<h1>Database Error</h1>\n"
94 "<pre>%h</pre><p>%s</p>", z, zRebuildMsg);
95 cgi_reply();
96 }else{
97 fprintf(stderr, "%s: %s\n\n%s", g.argv[0], z, zRebuildMsg);
98 }
99 free(z);
100 db_force_rollback();
101 fossil_exit(rc);
102 }
@@ -695,11 +695,11 @@
695 zVfs
696 );
697 if( rc!=SQLITE_OK ){
698 db_err(sqlite3_errmsg(db));
699 }
700 sqlite3_busy_timeout(db, 5000);
701 sqlite3_wal_autocheckpoint(db, 1); /* Set to checkpoint frequently */
702 sqlite3_create_function(db, "now", 0, SQLITE_ANY, 0, db_now_function, 0, 0);
703 return db;
704 }
705
@@ -832,34 +832,34 @@
832 if( lsize%1024!=0 || lsize<4096 ) return 0;
833 db_open_or_attach(zDbName, "localdb");
834
835 /* If the "isexe" column is missing from the vfile table, then
836 ** add it now. This code added on 2010-03-06. After all users have
837 ** upgraded, this code can be safely deleted.
838 */
839 if( !db_local_column_exists("vfile", "isexe") ){
840 db_multi_exec("ALTER TABLE vfile ADD COLUMN isexe BOOLEAN DEFAULT 0");
841 }
842
843 /* If "islink"/"isLink" columns are missing from tables, then
844 ** add them now. This code added on 2011-01-17 and 2011-08-27.
845 ** After all users have upgraded, this code can be safely deleted.
846 */
847 if( !db_local_column_exists("vfile", "islink") ){
848 db_multi_exec("ALTER TABLE vfile ADD COLUMN islink BOOLEAN DEFAULT 0");
849 }
850
851 if( !db_local_column_exists("stashfile", "isLink") &&
852 db_local_table_exists("stashfile") ){
853 db_multi_exec("ALTER TABLE stashfile ADD COLUMN isLink BOOLEAN DEFAULT 0");
854 }
855
856 if( !db_local_column_exists("undo", "isLink") &&
857 db_local_table_exists("undo") ){
858 db_multi_exec("ALTER TABLE undo ADD COLUMN isLink BOOLEAN DEFAULT 0");
859 }
860
861 if( !db_local_column_exists("undo_vfile", "islink") &&
862 db_local_table_exists("undo_vfile") ){
863 db_multi_exec("ALTER TABLE undo_vfile ADD COLUMN islink BOOLEAN DEFAULT 0");
864 }
865 return 1;
@@ -871,11 +871,11 @@
871 ** that contains a valid repository database.
872 **
873 ** For legacy, also look for ".fos". The use of ".fos" is deprecated
874 ** since "fos" has negative connotations in Hungarian, we are told.
875 **
876 ** If no valid _FOSSIL_ or .fos file is found, we move up one level and
877 ** try again. Once the file is found, the g.zLocalRoot variable is set
878 ** to the root of the repository tree and this routine returns 1. If
879 ** no database is found, then this routine return 0.
880 **
881 ** This routine always opens the user database regardless of whether or
@@ -883,12 +883,12 @@
883 ** is found, it is attached to the open database connection too.
884 */
885 int db_open_local(void){
886 int i, n;
887 char zPwd[2000];
888 static const char *const aDbName[] = { "/_FOSSIL_", "/.fslckout", "/.fos" };
889
890 if( g.localOpen) return 1;
891 file_getcwd(zPwd, sizeof(zPwd)-20);
892 n = strlen(zPwd);
893 if( n==1 && zPwd[0]=='/' ) zPwd[0] = '.';
894 while( n>0 ){
@@ -1397,11 +1397,11 @@
1397 db_end_transaction(0);
1398 if( zTemplate ) db_detach("settingSrc");
1399 fossil_print("project-id: %s\n", db_get("project-code", 0));
1400 fossil_print("server-id: %s\n", db_get("server-code", 0));
1401 zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
1402 fossil_print("admin-user: %s (initial password is \"%s\")\n",
1403 g.zLogin, zPassword);
1404 }
1405
1406 /*
1407 ** SQL functions for debugging.
@@ -1443,11 +1443,11 @@
1443 }
1444 }
1445
1446 /*
1447 ** Implement the cgi() SQL function. cgi() takes a an argument which is
1448 ** a name of CGI query parameter. The value of that parameter is returned,
1449 ** if available. optional second argument will be returned if the first
1450 ** doesn't exist as a CGI parameter.
1451 */
1452 static void db_sql_cgi(sqlite3_context *context, int argc, sqlite3_value **argv){
1453 const char* zP;
@@ -1638,11 +1638,11 @@
1638 struct _cacheEntry {
1639 struct _cacheEntry *next;
1640 const char *zName, *zValue;
1641 } *cacheEntry = 0;
1642 static struct _cacheEntry *cache = 0;
1643
1644 /* Look up name in cache */
1645 cacheEntry = cache;
1646 while( cacheEntry!=0 ){
1647 if( fossil_strcmp(cacheEntry->zName, zName)==0 ){
1648 zVersionedSetting = fossil_strdup(cacheEntry->zValue);
@@ -1865,11 +1865,11 @@
1865 "REPLACE INTO global_config(name, value)"
1866 "VALUES('ckout:%q','%q');",
1867 blob_str(&localRoot), blob_str(&full)
1868 );
1869 db_swap_connections();
1870 db_optional_sql("repository",
1871 "REPLACE INTO config(name,value,mtime)"
1872 "VALUES('ckout:%q',1,now())",
1873 blob_str(&localRoot)
1874 );
1875 blob_reset(&localRoot);
@@ -2064,11 +2064,11 @@
2064 ** The "unset" command clears a property setting.
2065 **
2066 **
2067 ** allow-symlinks If enabled, don't follow symlinks, and instead treat
2068 ** (versionable) them as symlinks on Unix. Has no effect on Windows
2069 ** (existing links in repository created on Unix become
2070 ** plain-text files with link destination path inside).
2071 ** Default: off
2072 **
2073 ** auto-captcha If enabled, the Login page provides a button to
2074 ** fill in the captcha password. Default: on
@@ -2212,11 +2212,11 @@
2212 ** and "firefox" on Unix.
2213 **
2214 ** Options:
2215 ** --global set or unset the given property globally instead of
2216 ** setting or unsetting it for the open repository only.
2217 **
2218 ** See also: configuration
2219 */
2220 void setting_cmd(void){
2221 int i;
2222 int globalFlag = find_option("global","g",0)!=0;
@@ -2300,11 +2300,11 @@
2300 ** Print the approximate span of time from now to TIMESTAMP.
2301 */
2302 void test_timespan_cmd(void){
2303 double rDiff;
2304 if( g.argc!=3 ) usage("TIMESTAMP");
2305 sqlite3_open(":memory:", &g.db);
2306 rDiff = db_double(0.0, "SELECT julianday('now') - julianday(%Q)", g.argv[2]);
2307 fossil_print("Time differences: %s\n", db_timespan_name(rDiff));
2308 sqlite3_close(g.db);
2309 g.db = 0;
2310 }
2311
--- src/http_transport.c
+++ src/http_transport.c
@@ -301,11 +301,11 @@
301301
fprintf(sshOut, "\n\n");
302302
}else if( g.urlIsFile ){
303303
char *zCmd;
304304
fclose(transport.pFile);
305305
zCmd = mprintf("\"%s\" http \"%s\" \"%s\" \"%s\" 127.0.0.1 --localauth",
306
- fossil_nameofexe(), g.urlName, transport.zOutFile, transport.zInFile
306
+ g.nameOfExe, g.urlName, transport.zOutFile, transport.zInFile
307307
);
308308
fossil_system(zCmd);
309309
free(zCmd);
310310
transport.pFile = fopen(transport.zInFile, "rb");
311311
}
312312
--- src/http_transport.c
+++ src/http_transport.c
@@ -301,11 +301,11 @@
301 fprintf(sshOut, "\n\n");
302 }else if( g.urlIsFile ){
303 char *zCmd;
304 fclose(transport.pFile);
305 zCmd = mprintf("\"%s\" http \"%s\" \"%s\" \"%s\" 127.0.0.1 --localauth",
306 fossil_nameofexe(), g.urlName, transport.zOutFile, transport.zInFile
307 );
308 fossil_system(zCmd);
309 free(zCmd);
310 transport.pFile = fopen(transport.zInFile, "rb");
311 }
312
--- src/http_transport.c
+++ src/http_transport.c
@@ -301,11 +301,11 @@
301 fprintf(sshOut, "\n\n");
302 }else if( g.urlIsFile ){
303 char *zCmd;
304 fclose(transport.pFile);
305 zCmd = mprintf("\"%s\" http \"%s\" \"%s\" \"%s\" 127.0.0.1 --localauth",
306 g.nameOfExe, g.urlName, transport.zOutFile, transport.zInFile
307 );
308 fossil_system(zCmd);
309 free(zCmd);
310 transport.pFile = fopen(transport.zInFile, "rb");
311 }
312
+20 -20
--- src/json.c
+++ src/json.c
@@ -13,11 +13,11 @@
1313
** Author contact information:
1414
** [email protected]
1515
** http://www.hwaci.com/drh/
1616
**
1717
*******************************************************************************
18
-**
18
+**
1919
** Code for the JSON API.
2020
**
2121
** For notes regarding the public JSON interface, please see:
2222
**
2323
** https://docs.google.com/document/d/1fXViveNhDbiXgCuE7QDXQOKeFzf2qNUkBEgiUvoqFN4/edit
@@ -74,11 +74,11 @@
7474
getrusage(RUSAGE_SELF, &sBegin);
7575
}
7676
7777
/* Return the difference of two time_structs in milliseconds */
7878
static double timeDiff(struct timeval *pStart, struct timeval *pEnd){
79
- return ((pEnd->tv_usec - pStart->tv_usec)*0.001 +
79
+ return ((pEnd->tv_usec - pStart->tv_usec)*0.001 +
8080
(double)((pEnd->tv_sec - pStart->tv_sec)*1000.0));
8181
}
8282
8383
/*
8484
** Print the timing results.
@@ -128,11 +128,11 @@
128128
if( NULL != hinstLib ){
129129
getProcessTimesAddr = (GETPROCTIMES) GetProcAddress(hinstLib, "GetProcessTimes");
130130
if( NULL != getProcessTimesAddr ){
131131
return 1;
132132
}
133
- FreeLibrary(hinstLib);
133
+ FreeLibrary(hinstLib);
134134
}
135135
}
136136
}
137137
return 0;
138138
}
@@ -170,11 +170,11 @@
170170
#define BEGIN_TIMER beginTimer()
171171
#define END_TIMER endTimer()
172172
#define HAS_TIMER hasTimer()
173173
174174
#else
175
-#define BEGIN_TIMER
175
+#define BEGIN_TIMER
176176
#define END_TIMER 0.0
177177
#define HAS_TIMER 0
178178
#endif
179179
180180
/*
@@ -212,11 +212,11 @@
212212
C(ALLOC,"Resource allocation failed");
213213
C(NYI,"Not yet implemented");
214214
C(PANIC,"x");
215215
C(MANIFEST_READ_FAILED,"Reading artifact manifest failed");
216216
C(FILE_OPEN_FAILED,"Opening file failed");
217
-
217
+
218218
C(AUTH,"Authentication error");
219219
C(MISSING_AUTH,"Authentication info missing from request");
220220
C(DENIED,"Access denied");
221221
C(WRONG_MODE,"Request not allowed (wrong operation mode)");
222222
C(LOGIN_FAILED,"Login failed");
@@ -348,11 +348,11 @@
348348
if( 0 != rc ){
349349
cson_value_free( v );
350350
}
351351
assert( (0==rc) && "Adding item to GC failed." );
352352
if(0!=rc){
353
- fprintf(stderr,"%s: FATAL: alloc error.\n", fossil_nameofexe())
353
+ fprintf(stderr,"%s: FATAL: alloc error.\n", g.argv[0])
354354
/* reminder: allocation error is the only reasonable cause of
355355
error here, provided g.json.gc.a and v are not NULL.
356356
*/
357357
;
358358
fossil_exit(1)/*not fossil_panic() b/c it might land us somewhere
@@ -384,11 +384,11 @@
384384
va_start(vargs,fmt);
385385
zStr = vmprintf(fmt,vargs);
386386
va_end(vargs);
387387
v = cson_value_new_string(zStr, strlen(zStr));
388388
free(zStr);
389
- return v;
389
+ return v;
390390
}
391391
392392
cson_value * json_new_int( int v ){
393393
return cson_value_new_integer((cson_int_t)v);
394394
}
@@ -673,11 +673,11 @@
673673
? "application/javascript; charset=utf-8"
674674
: "application/javascript";
675675
}else{
676676
/*
677677
Content-type
678
-
678
+
679679
If the browser does not sent an ACCEPT for application/json
680680
then we fall back to text/plain.
681681
*/
682682
char const * cstr;
683683
cstr = PD("HTTP_ACCEPT",NULL);
@@ -1117,11 +1117,11 @@
11171117
if( stdin != inFile ){
11181118
fclose(inFile);
11191119
}
11201120
break;
11211121
}
1122
-
1122
+
11231123
/* g.json.reqPayload exists only to simplify some of our access to
11241124
the request payload. We currently only use this in the context of
11251125
Object payloads, not Arrays, strings, etc.
11261126
*/
11271127
g.json.reqPayload.v = cson_object_get( g.json.post.o, FossilJsonKeys.payload );
@@ -1146,11 +1146,11 @@
11461146
json_string_split(cmd, '/', 0, g.json.cmd.a);
11471147
g.json.cmd.commandStr = cmd;
11481148
}
11491149
}
11501150
1151
-
1151
+
11521152
if(!g.json.jsonp){
11531153
g.json.jsonp = json_find_option_cstr("jsonp",NULL,NULL);
11541154
}
11551155
if(!g.isHTTP){
11561156
g.json.errorDetailParanoia = 0 /*disable error code dumb-down for CLI mode*/;
@@ -1447,11 +1447,11 @@
14471447
VAL(param, g.json.param.v);
14481448
VAL(POST, g.json.post.v);
14491449
VAL(warnings, cson_array_value(g.json.warnings));
14501450
/*cson_output_opt outOpt;*/
14511451
1452
-
1452
+
14531453
#undef INT
14541454
#undef CSTR
14551455
#undef VAL
14561456
return cson_object_value(pay);
14571457
}
@@ -1495,11 +1495,11 @@
14951495
cson_value_free(tmp); \
14961496
tmp = NULL; \
14971497
goto cleanup; \
14981498
}while(0)
14991499
1500
-
1500
+
15011501
tmp = json_new_string(MANIFEST_UUID);
15021502
SET("fossil");
15031503
15041504
tmp = json_new_timestamp(-1);
15051505
SET(FossilJsonKeys.timestamp);
@@ -1524,11 +1524,11 @@
15241524
tmp = json_new_string(g.json.cmd.commandStr);
15251525
}else{
15261526
tmp = json_response_command_path();
15271527
}
15281528
SET("command");
1529
-
1529
+
15301530
tmp = json_getenv(FossilJsonKeys.requestId);
15311531
if( tmp ) cson_object_set( o, FossilJsonKeys.requestId, tmp );
15321532
15331533
if(0){/* these are only intended for my own testing...*/
15341534
if(g.json.cmd.v){
@@ -1561,11 +1561,11 @@
15611561
}
15621562
if(g.json.warnings){
15631563
tmp = cson_array_value(g.json.warnings);
15641564
SET("warnings");
15651565
}
1566
-
1566
+
15671567
/* Only add the payload to SUCCESS responses. Else delete it. */
15681568
if( NULL != payload ){
15691569
if( resultCode ){
15701570
cson_value_free(payload);
15711571
payload = NULL;
@@ -1578,11 +1578,11 @@
15781578
if(json_find_option_bool("debugFossilG","json-debug-g",NULL,0)
15791579
&&(g.perm.Admin||g.perm.Setup)){
15801580
tmp = json_g_to_json();
15811581
SET("g");
15821582
}
1583
-
1583
+
15841584
#undef SET
15851585
goto ok;
15861586
cleanup:
15871587
cson_value_free(v);
15881588
v = NULL;
@@ -1628,11 +1628,11 @@
16281628
if(!resp){
16291629
/* about the only error case here is out-of-memory. DO NOT
16301630
call fossil_panic() here because that calls this function.
16311631
*/
16321632
fprintf(stderr, "%s: Fatal error: could not allocate "
1633
- "response object.\n", fossil_nameofexe());
1633
+ "response object.\n", g.argv[0]);
16341634
fossil_exit(1);
16351635
}
16361636
if( g.isHTTP ){
16371637
if(alsoOutput){
16381638
json_send_response(resp);
@@ -1701,11 +1701,11 @@
17011701
colNamesV = cson_sqlite3_column_names(pStmt->pStmt);
17021702
assert(NULL != colNamesV);
17031703
/*Why? cson_value_add_reference(colNamesV) avoids an ownership problem*/;
17041704
colNames = cson_value_get_array(colNamesV);
17051705
assert(NULL != colNames);
1706
- }
1706
+ }
17071707
row = cson_sqlite3_row_to_object2(pStmt->pStmt, colNames);
17081708
if(!row && !warnMsg){
17091709
warnMsg = "Could not convert at least one result row to JSON.";
17101710
continue;
17111711
}
@@ -1720,11 +1720,11 @@
17201720
}
17211721
cson_value_free(colNamesV);
17221722
if(warnMsg){
17231723
json_warn( FSL_JSON_W_ROW_TO_JSON_FAILED, warnMsg );
17241724
}
1725
- return cson_array_value(a);
1725
+ return cson_array_value(a);
17261726
}
17271727
17281728
/*
17291729
** Works just like json_stmt_to_array_of_obj(), but each row in the
17301730
** result set is represented as an Array of values instead of an
@@ -1809,11 +1809,11 @@
18091809
if(*tags){
18101810
v = json_string_split2(tags,',',0);
18111811
}
18121812
free(tags);
18131813
}
1814
- return v;
1814
+ return v;
18151815
}
18161816
18171817
/*
18181818
** Returns a "new" value representing the boolean value of zVal
18191819
** (false if zVal is NULL). Note that cson does not really allocate
@@ -1859,11 +1859,11 @@
18591859
C(ALLOC);
18601860
C(NYI);
18611861
C(PANIC);
18621862
C(MANIFEST_READ_FAILED);
18631863
C(FILE_OPEN_FAILED);
1864
-
1864
+
18651865
C(AUTH);
18661866
C(MISSING_AUTH);
18671867
C(DENIED);
18681868
C(WRONG_MODE);
18691869
C(LOGIN_FAILED);
18701870
--- src/json.c
+++ src/json.c
@@ -13,11 +13,11 @@
13 ** Author contact information:
14 ** [email protected]
15 ** http://www.hwaci.com/drh/
16 **
17 *******************************************************************************
18 **
19 ** Code for the JSON API.
20 **
21 ** For notes regarding the public JSON interface, please see:
22 **
23 ** https://docs.google.com/document/d/1fXViveNhDbiXgCuE7QDXQOKeFzf2qNUkBEgiUvoqFN4/edit
@@ -74,11 +74,11 @@
74 getrusage(RUSAGE_SELF, &sBegin);
75 }
76
77 /* Return the difference of two time_structs in milliseconds */
78 static double timeDiff(struct timeval *pStart, struct timeval *pEnd){
79 return ((pEnd->tv_usec - pStart->tv_usec)*0.001 +
80 (double)((pEnd->tv_sec - pStart->tv_sec)*1000.0));
81 }
82
83 /*
84 ** Print the timing results.
@@ -128,11 +128,11 @@
128 if( NULL != hinstLib ){
129 getProcessTimesAddr = (GETPROCTIMES) GetProcAddress(hinstLib, "GetProcessTimes");
130 if( NULL != getProcessTimesAddr ){
131 return 1;
132 }
133 FreeLibrary(hinstLib);
134 }
135 }
136 }
137 return 0;
138 }
@@ -170,11 +170,11 @@
170 #define BEGIN_TIMER beginTimer()
171 #define END_TIMER endTimer()
172 #define HAS_TIMER hasTimer()
173
174 #else
175 #define BEGIN_TIMER
176 #define END_TIMER 0.0
177 #define HAS_TIMER 0
178 #endif
179
180 /*
@@ -212,11 +212,11 @@
212 C(ALLOC,"Resource allocation failed");
213 C(NYI,"Not yet implemented");
214 C(PANIC,"x");
215 C(MANIFEST_READ_FAILED,"Reading artifact manifest failed");
216 C(FILE_OPEN_FAILED,"Opening file failed");
217
218 C(AUTH,"Authentication error");
219 C(MISSING_AUTH,"Authentication info missing from request");
220 C(DENIED,"Access denied");
221 C(WRONG_MODE,"Request not allowed (wrong operation mode)");
222 C(LOGIN_FAILED,"Login failed");
@@ -348,11 +348,11 @@
348 if( 0 != rc ){
349 cson_value_free( v );
350 }
351 assert( (0==rc) && "Adding item to GC failed." );
352 if(0!=rc){
353 fprintf(stderr,"%s: FATAL: alloc error.\n", fossil_nameofexe())
354 /* reminder: allocation error is the only reasonable cause of
355 error here, provided g.json.gc.a and v are not NULL.
356 */
357 ;
358 fossil_exit(1)/*not fossil_panic() b/c it might land us somewhere
@@ -384,11 +384,11 @@
384 va_start(vargs,fmt);
385 zStr = vmprintf(fmt,vargs);
386 va_end(vargs);
387 v = cson_value_new_string(zStr, strlen(zStr));
388 free(zStr);
389 return v;
390 }
391
392 cson_value * json_new_int( int v ){
393 return cson_value_new_integer((cson_int_t)v);
394 }
@@ -673,11 +673,11 @@
673 ? "application/javascript; charset=utf-8"
674 : "application/javascript";
675 }else{
676 /*
677 Content-type
678
679 If the browser does not sent an ACCEPT for application/json
680 then we fall back to text/plain.
681 */
682 char const * cstr;
683 cstr = PD("HTTP_ACCEPT",NULL);
@@ -1117,11 +1117,11 @@
1117 if( stdin != inFile ){
1118 fclose(inFile);
1119 }
1120 break;
1121 }
1122
1123 /* g.json.reqPayload exists only to simplify some of our access to
1124 the request payload. We currently only use this in the context of
1125 Object payloads, not Arrays, strings, etc.
1126 */
1127 g.json.reqPayload.v = cson_object_get( g.json.post.o, FossilJsonKeys.payload );
@@ -1146,11 +1146,11 @@
1146 json_string_split(cmd, '/', 0, g.json.cmd.a);
1147 g.json.cmd.commandStr = cmd;
1148 }
1149 }
1150
1151
1152 if(!g.json.jsonp){
1153 g.json.jsonp = json_find_option_cstr("jsonp",NULL,NULL);
1154 }
1155 if(!g.isHTTP){
1156 g.json.errorDetailParanoia = 0 /*disable error code dumb-down for CLI mode*/;
@@ -1447,11 +1447,11 @@
1447 VAL(param, g.json.param.v);
1448 VAL(POST, g.json.post.v);
1449 VAL(warnings, cson_array_value(g.json.warnings));
1450 /*cson_output_opt outOpt;*/
1451
1452
1453 #undef INT
1454 #undef CSTR
1455 #undef VAL
1456 return cson_object_value(pay);
1457 }
@@ -1495,11 +1495,11 @@
1495 cson_value_free(tmp); \
1496 tmp = NULL; \
1497 goto cleanup; \
1498 }while(0)
1499
1500
1501 tmp = json_new_string(MANIFEST_UUID);
1502 SET("fossil");
1503
1504 tmp = json_new_timestamp(-1);
1505 SET(FossilJsonKeys.timestamp);
@@ -1524,11 +1524,11 @@
1524 tmp = json_new_string(g.json.cmd.commandStr);
1525 }else{
1526 tmp = json_response_command_path();
1527 }
1528 SET("command");
1529
1530 tmp = json_getenv(FossilJsonKeys.requestId);
1531 if( tmp ) cson_object_set( o, FossilJsonKeys.requestId, tmp );
1532
1533 if(0){/* these are only intended for my own testing...*/
1534 if(g.json.cmd.v){
@@ -1561,11 +1561,11 @@
1561 }
1562 if(g.json.warnings){
1563 tmp = cson_array_value(g.json.warnings);
1564 SET("warnings");
1565 }
1566
1567 /* Only add the payload to SUCCESS responses. Else delete it. */
1568 if( NULL != payload ){
1569 if( resultCode ){
1570 cson_value_free(payload);
1571 payload = NULL;
@@ -1578,11 +1578,11 @@
1578 if(json_find_option_bool("debugFossilG","json-debug-g",NULL,0)
1579 &&(g.perm.Admin||g.perm.Setup)){
1580 tmp = json_g_to_json();
1581 SET("g");
1582 }
1583
1584 #undef SET
1585 goto ok;
1586 cleanup:
1587 cson_value_free(v);
1588 v = NULL;
@@ -1628,11 +1628,11 @@
1628 if(!resp){
1629 /* about the only error case here is out-of-memory. DO NOT
1630 call fossil_panic() here because that calls this function.
1631 */
1632 fprintf(stderr, "%s: Fatal error: could not allocate "
1633 "response object.\n", fossil_nameofexe());
1634 fossil_exit(1);
1635 }
1636 if( g.isHTTP ){
1637 if(alsoOutput){
1638 json_send_response(resp);
@@ -1701,11 +1701,11 @@
1701 colNamesV = cson_sqlite3_column_names(pStmt->pStmt);
1702 assert(NULL != colNamesV);
1703 /*Why? cson_value_add_reference(colNamesV) avoids an ownership problem*/;
1704 colNames = cson_value_get_array(colNamesV);
1705 assert(NULL != colNames);
1706 }
1707 row = cson_sqlite3_row_to_object2(pStmt->pStmt, colNames);
1708 if(!row && !warnMsg){
1709 warnMsg = "Could not convert at least one result row to JSON.";
1710 continue;
1711 }
@@ -1720,11 +1720,11 @@
1720 }
1721 cson_value_free(colNamesV);
1722 if(warnMsg){
1723 json_warn( FSL_JSON_W_ROW_TO_JSON_FAILED, warnMsg );
1724 }
1725 return cson_array_value(a);
1726 }
1727
1728 /*
1729 ** Works just like json_stmt_to_array_of_obj(), but each row in the
1730 ** result set is represented as an Array of values instead of an
@@ -1809,11 +1809,11 @@
1809 if(*tags){
1810 v = json_string_split2(tags,',',0);
1811 }
1812 free(tags);
1813 }
1814 return v;
1815 }
1816
1817 /*
1818 ** Returns a "new" value representing the boolean value of zVal
1819 ** (false if zVal is NULL). Note that cson does not really allocate
@@ -1859,11 +1859,11 @@
1859 C(ALLOC);
1860 C(NYI);
1861 C(PANIC);
1862 C(MANIFEST_READ_FAILED);
1863 C(FILE_OPEN_FAILED);
1864
1865 C(AUTH);
1866 C(MISSING_AUTH);
1867 C(DENIED);
1868 C(WRONG_MODE);
1869 C(LOGIN_FAILED);
1870
--- src/json.c
+++ src/json.c
@@ -13,11 +13,11 @@
13 ** Author contact information:
14 ** [email protected]
15 ** http://www.hwaci.com/drh/
16 **
17 *******************************************************************************
18 **
19 ** Code for the JSON API.
20 **
21 ** For notes regarding the public JSON interface, please see:
22 **
23 ** https://docs.google.com/document/d/1fXViveNhDbiXgCuE7QDXQOKeFzf2qNUkBEgiUvoqFN4/edit
@@ -74,11 +74,11 @@
74 getrusage(RUSAGE_SELF, &sBegin);
75 }
76
77 /* Return the difference of two time_structs in milliseconds */
78 static double timeDiff(struct timeval *pStart, struct timeval *pEnd){
79 return ((pEnd->tv_usec - pStart->tv_usec)*0.001 +
80 (double)((pEnd->tv_sec - pStart->tv_sec)*1000.0));
81 }
82
83 /*
84 ** Print the timing results.
@@ -128,11 +128,11 @@
128 if( NULL != hinstLib ){
129 getProcessTimesAddr = (GETPROCTIMES) GetProcAddress(hinstLib, "GetProcessTimes");
130 if( NULL != getProcessTimesAddr ){
131 return 1;
132 }
133 FreeLibrary(hinstLib);
134 }
135 }
136 }
137 return 0;
138 }
@@ -170,11 +170,11 @@
170 #define BEGIN_TIMER beginTimer()
171 #define END_TIMER endTimer()
172 #define HAS_TIMER hasTimer()
173
174 #else
175 #define BEGIN_TIMER
176 #define END_TIMER 0.0
177 #define HAS_TIMER 0
178 #endif
179
180 /*
@@ -212,11 +212,11 @@
212 C(ALLOC,"Resource allocation failed");
213 C(NYI,"Not yet implemented");
214 C(PANIC,"x");
215 C(MANIFEST_READ_FAILED,"Reading artifact manifest failed");
216 C(FILE_OPEN_FAILED,"Opening file failed");
217
218 C(AUTH,"Authentication error");
219 C(MISSING_AUTH,"Authentication info missing from request");
220 C(DENIED,"Access denied");
221 C(WRONG_MODE,"Request not allowed (wrong operation mode)");
222 C(LOGIN_FAILED,"Login failed");
@@ -348,11 +348,11 @@
348 if( 0 != rc ){
349 cson_value_free( v );
350 }
351 assert( (0==rc) && "Adding item to GC failed." );
352 if(0!=rc){
353 fprintf(stderr,"%s: FATAL: alloc error.\n", g.argv[0])
354 /* reminder: allocation error is the only reasonable cause of
355 error here, provided g.json.gc.a and v are not NULL.
356 */
357 ;
358 fossil_exit(1)/*not fossil_panic() b/c it might land us somewhere
@@ -384,11 +384,11 @@
384 va_start(vargs,fmt);
385 zStr = vmprintf(fmt,vargs);
386 va_end(vargs);
387 v = cson_value_new_string(zStr, strlen(zStr));
388 free(zStr);
389 return v;
390 }
391
392 cson_value * json_new_int( int v ){
393 return cson_value_new_integer((cson_int_t)v);
394 }
@@ -673,11 +673,11 @@
673 ? "application/javascript; charset=utf-8"
674 : "application/javascript";
675 }else{
676 /*
677 Content-type
678
679 If the browser does not sent an ACCEPT for application/json
680 then we fall back to text/plain.
681 */
682 char const * cstr;
683 cstr = PD("HTTP_ACCEPT",NULL);
@@ -1117,11 +1117,11 @@
1117 if( stdin != inFile ){
1118 fclose(inFile);
1119 }
1120 break;
1121 }
1122
1123 /* g.json.reqPayload exists only to simplify some of our access to
1124 the request payload. We currently only use this in the context of
1125 Object payloads, not Arrays, strings, etc.
1126 */
1127 g.json.reqPayload.v = cson_object_get( g.json.post.o, FossilJsonKeys.payload );
@@ -1146,11 +1146,11 @@
1146 json_string_split(cmd, '/', 0, g.json.cmd.a);
1147 g.json.cmd.commandStr = cmd;
1148 }
1149 }
1150
1151
1152 if(!g.json.jsonp){
1153 g.json.jsonp = json_find_option_cstr("jsonp",NULL,NULL);
1154 }
1155 if(!g.isHTTP){
1156 g.json.errorDetailParanoia = 0 /*disable error code dumb-down for CLI mode*/;
@@ -1447,11 +1447,11 @@
1447 VAL(param, g.json.param.v);
1448 VAL(POST, g.json.post.v);
1449 VAL(warnings, cson_array_value(g.json.warnings));
1450 /*cson_output_opt outOpt;*/
1451
1452
1453 #undef INT
1454 #undef CSTR
1455 #undef VAL
1456 return cson_object_value(pay);
1457 }
@@ -1495,11 +1495,11 @@
1495 cson_value_free(tmp); \
1496 tmp = NULL; \
1497 goto cleanup; \
1498 }while(0)
1499
1500
1501 tmp = json_new_string(MANIFEST_UUID);
1502 SET("fossil");
1503
1504 tmp = json_new_timestamp(-1);
1505 SET(FossilJsonKeys.timestamp);
@@ -1524,11 +1524,11 @@
1524 tmp = json_new_string(g.json.cmd.commandStr);
1525 }else{
1526 tmp = json_response_command_path();
1527 }
1528 SET("command");
1529
1530 tmp = json_getenv(FossilJsonKeys.requestId);
1531 if( tmp ) cson_object_set( o, FossilJsonKeys.requestId, tmp );
1532
1533 if(0){/* these are only intended for my own testing...*/
1534 if(g.json.cmd.v){
@@ -1561,11 +1561,11 @@
1561 }
1562 if(g.json.warnings){
1563 tmp = cson_array_value(g.json.warnings);
1564 SET("warnings");
1565 }
1566
1567 /* Only add the payload to SUCCESS responses. Else delete it. */
1568 if( NULL != payload ){
1569 if( resultCode ){
1570 cson_value_free(payload);
1571 payload = NULL;
@@ -1578,11 +1578,11 @@
1578 if(json_find_option_bool("debugFossilG","json-debug-g",NULL,0)
1579 &&(g.perm.Admin||g.perm.Setup)){
1580 tmp = json_g_to_json();
1581 SET("g");
1582 }
1583
1584 #undef SET
1585 goto ok;
1586 cleanup:
1587 cson_value_free(v);
1588 v = NULL;
@@ -1628,11 +1628,11 @@
1628 if(!resp){
1629 /* about the only error case here is out-of-memory. DO NOT
1630 call fossil_panic() here because that calls this function.
1631 */
1632 fprintf(stderr, "%s: Fatal error: could not allocate "
1633 "response object.\n", g.argv[0]);
1634 fossil_exit(1);
1635 }
1636 if( g.isHTTP ){
1637 if(alsoOutput){
1638 json_send_response(resp);
@@ -1701,11 +1701,11 @@
1701 colNamesV = cson_sqlite3_column_names(pStmt->pStmt);
1702 assert(NULL != colNamesV);
1703 /*Why? cson_value_add_reference(colNamesV) avoids an ownership problem*/;
1704 colNames = cson_value_get_array(colNamesV);
1705 assert(NULL != colNames);
1706 }
1707 row = cson_sqlite3_row_to_object2(pStmt->pStmt, colNames);
1708 if(!row && !warnMsg){
1709 warnMsg = "Could not convert at least one result row to JSON.";
1710 continue;
1711 }
@@ -1720,11 +1720,11 @@
1720 }
1721 cson_value_free(colNamesV);
1722 if(warnMsg){
1723 json_warn( FSL_JSON_W_ROW_TO_JSON_FAILED, warnMsg );
1724 }
1725 return cson_array_value(a);
1726 }
1727
1728 /*
1729 ** Works just like json_stmt_to_array_of_obj(), but each row in the
1730 ** result set is represented as an Array of values instead of an
@@ -1809,11 +1809,11 @@
1809 if(*tags){
1810 v = json_string_split2(tags,',',0);
1811 }
1812 free(tags);
1813 }
1814 return v;
1815 }
1816
1817 /*
1818 ** Returns a "new" value representing the boolean value of zVal
1819 ** (false if zVal is NULL). Note that cson does not really allocate
@@ -1859,11 +1859,11 @@
1859 C(ALLOC);
1860 C(NYI);
1861 C(PANIC);
1862 C(MANIFEST_READ_FAILED);
1863 C(FILE_OPEN_FAILED);
1864
1865 C(AUTH);
1866 C(MISSING_AUTH);
1867 C(DENIED);
1868 C(WRONG_MODE);
1869 C(LOGIN_FAILED);
1870
+5 -9
--- src/main.c
+++ src/main.c
@@ -99,10 +99,11 @@
9999
/*
100100
** All global variables are in this structure.
101101
*/
102102
struct Global {
103103
int argc; char **argv; /* Command-line arguments to the program */
104
+ char *nameOfExe; /* Full path of executable. */
104105
int isConst; /* True if the output is unchanging */
105106
sqlite3 *db; /* The connection to the databases */
106107
sqlite3 *dbConfig; /* Separate connection for global_config table */
107108
int useAttach; /* True if global_config is attached to repository */
108109
int configOpen; /* True if the config database is open */
@@ -477,12 +478,14 @@
477478
g.argc = argc;
478479
g.argv = argv;
479480
#ifdef _WIN32
480481
parse_windows_command_line(&g.argc, &g.argv);
481482
GetModuleFileNameW(NULL, buf, MAX_PATH);
482
- g.argv[0] = fossil_unicode_to_utf8(buf);
483
- for(i=1; i<g.argc; i++) g.argv[i] = fossil_unicode_to_utf8(g.argv[i]);
483
+ g.nameOfExe = fossil_unicode_to_utf8(buf);
484
+ for(i=0; i<g.argc; i++) g.argv[i] = fossil_unicode_to_utf8(g.argv[i]);
485
+#else
486
+ g.nameOfExe = g.argv[0];
484487
#endif
485488
for(i=1; i<g.argc-1; i++){
486489
z = g.argv[i];
487490
if( z[0]!='-' ) continue;
488491
z++;
@@ -651,17 +654,10 @@
651654
** or a panic. If additional "recursive-fatal" errors occur while
652655
** shutting down, the recursive errors are silently ignored.
653656
*/
654657
static int mainInFatalError = 0;
655658
656
-/*
657
-** Return the name of the current executable.
658
-*/
659
-const char *fossil_nameofexe(void){
660
- return g.argv[0];
661
-}
662
-
663659
/*
664660
** Exit. Take care to close the database first.
665661
*/
666662
NORETURN void fossil_exit(int rc){
667663
db_close(1);
668664
--- src/main.c
+++ src/main.c
@@ -99,10 +99,11 @@
99 /*
100 ** All global variables are in this structure.
101 */
102 struct Global {
103 int argc; char **argv; /* Command-line arguments to the program */
 
104 int isConst; /* True if the output is unchanging */
105 sqlite3 *db; /* The connection to the databases */
106 sqlite3 *dbConfig; /* Separate connection for global_config table */
107 int useAttach; /* True if global_config is attached to repository */
108 int configOpen; /* True if the config database is open */
@@ -477,12 +478,14 @@
477 g.argc = argc;
478 g.argv = argv;
479 #ifdef _WIN32
480 parse_windows_command_line(&g.argc, &g.argv);
481 GetModuleFileNameW(NULL, buf, MAX_PATH);
482 g.argv[0] = fossil_unicode_to_utf8(buf);
483 for(i=1; i<g.argc; i++) g.argv[i] = fossil_unicode_to_utf8(g.argv[i]);
 
 
484 #endif
485 for(i=1; i<g.argc-1; i++){
486 z = g.argv[i];
487 if( z[0]!='-' ) continue;
488 z++;
@@ -651,17 +654,10 @@
651 ** or a panic. If additional "recursive-fatal" errors occur while
652 ** shutting down, the recursive errors are silently ignored.
653 */
654 static int mainInFatalError = 0;
655
656 /*
657 ** Return the name of the current executable.
658 */
659 const char *fossil_nameofexe(void){
660 return g.argv[0];
661 }
662
663 /*
664 ** Exit. Take care to close the database first.
665 */
666 NORETURN void fossil_exit(int rc){
667 db_close(1);
668
--- src/main.c
+++ src/main.c
@@ -99,10 +99,11 @@
99 /*
100 ** All global variables are in this structure.
101 */
102 struct Global {
103 int argc; char **argv; /* Command-line arguments to the program */
104 char *nameOfExe; /* Full path of executable. */
105 int isConst; /* True if the output is unchanging */
106 sqlite3 *db; /* The connection to the databases */
107 sqlite3 *dbConfig; /* Separate connection for global_config table */
108 int useAttach; /* True if global_config is attached to repository */
109 int configOpen; /* True if the config database is open */
@@ -477,12 +478,14 @@
478 g.argc = argc;
479 g.argv = argv;
480 #ifdef _WIN32
481 parse_windows_command_line(&g.argc, &g.argv);
482 GetModuleFileNameW(NULL, buf, MAX_PATH);
483 g.nameOfExe = fossil_unicode_to_utf8(buf);
484 for(i=0; i<g.argc; i++) g.argv[i] = fossil_unicode_to_utf8(g.argv[i]);
485 #else
486 g.nameOfExe = g.argv[0];
487 #endif
488 for(i=1; i<g.argc-1; i++){
489 z = g.argv[i];
490 if( z[0]!='-' ) continue;
491 z++;
@@ -651,17 +654,10 @@
654 ** or a panic. If additional "recursive-fatal" errors occur while
655 ** shutting down, the recursive errors are silently ignored.
656 */
657 static int mainInFatalError = 0;
658
 
 
 
 
 
 
 
659 /*
660 ** Exit. Take care to close the database first.
661 */
662 NORETURN void fossil_exit(int rc){
663 db_close(1);
664
+2 -2
--- src/winhttp.c
+++ src/winhttp.c
@@ -109,11 +109,11 @@
109109
wanted -= got;
110110
}
111111
fclose(out);
112112
out = 0;
113113
sqlite3_snprintf(sizeof(zCmd), zCmd, "\"%s\" http \"%s\" %s %s %s --nossl%s",
114
- fossil_nameofexe(), g.zRepositoryName, zRequestFName, zReplyFName,
114
+ g.nameOfExe, g.zRepositoryName, zRequestFName, zReplyFName,
115115
inet_ntoa(p->addr.sin_addr), p->zOptions
116116
);
117117
fossil_system(zCmd);
118118
in = fossil_fopen(zReplyFName, "rb");
119119
if( in ){
@@ -614,11 +614,11 @@
614614
db_open_repository(zRepository);
615615
}
616616
db_close(0);
617617
/* Build the fully-qualified path to the service binary file. */
618618
blob_zero(&binPath);
619
- blob_appendf(&binPath, "\"%s\" server", fossil_nameofexe());
619
+ blob_appendf(&binPath, "\"%s\" server", g.nameOfExe);
620620
if( zPort ) blob_appendf(&binPath, " --port %s", zPort);
621621
if( zNotFound ) blob_appendf(&binPath, " --notfound \"%s\"", zNotFound);
622622
if( zLocalAuth ) blob_append(&binPath, " --localauth", -1);
623623
blob_appendf(&binPath, " \"%s\"", g.zRepositoryName);
624624
/* Create the service. */
625625
--- src/winhttp.c
+++ src/winhttp.c
@@ -109,11 +109,11 @@
109 wanted -= got;
110 }
111 fclose(out);
112 out = 0;
113 sqlite3_snprintf(sizeof(zCmd), zCmd, "\"%s\" http \"%s\" %s %s %s --nossl%s",
114 fossil_nameofexe(), g.zRepositoryName, zRequestFName, zReplyFName,
115 inet_ntoa(p->addr.sin_addr), p->zOptions
116 );
117 fossil_system(zCmd);
118 in = fossil_fopen(zReplyFName, "rb");
119 if( in ){
@@ -614,11 +614,11 @@
614 db_open_repository(zRepository);
615 }
616 db_close(0);
617 /* Build the fully-qualified path to the service binary file. */
618 blob_zero(&binPath);
619 blob_appendf(&binPath, "\"%s\" server", fossil_nameofexe());
620 if( zPort ) blob_appendf(&binPath, " --port %s", zPort);
621 if( zNotFound ) blob_appendf(&binPath, " --notfound \"%s\"", zNotFound);
622 if( zLocalAuth ) blob_append(&binPath, " --localauth", -1);
623 blob_appendf(&binPath, " \"%s\"", g.zRepositoryName);
624 /* Create the service. */
625
--- src/winhttp.c
+++ src/winhttp.c
@@ -109,11 +109,11 @@
109 wanted -= got;
110 }
111 fclose(out);
112 out = 0;
113 sqlite3_snprintf(sizeof(zCmd), zCmd, "\"%s\" http \"%s\" %s %s %s --nossl%s",
114 g.nameOfExe, g.zRepositoryName, zRequestFName, zReplyFName,
115 inet_ntoa(p->addr.sin_addr), p->zOptions
116 );
117 fossil_system(zCmd);
118 in = fossil_fopen(zReplyFName, "rb");
119 if( in ){
@@ -614,11 +614,11 @@
614 db_open_repository(zRepository);
615 }
616 db_close(0);
617 /* Build the fully-qualified path to the service binary file. */
618 blob_zero(&binPath);
619 blob_appendf(&binPath, "\"%s\" server", g.nameOfExe);
620 if( zPort ) blob_appendf(&binPath, " --port %s", zPort);
621 if( zNotFound ) blob_appendf(&binPath, " --notfound \"%s\"", zNotFound);
622 if( zLocalAuth ) blob_append(&binPath, " --localauth", -1);
623 blob_appendf(&binPath, " \"%s\"", g.zRepositoryName);
624 /* Create the service. */
625

Keyboard Shortcuts

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