Fossil SCM

Output appropriate error messages and abort if the date argument to the --date-override option is malformed. Ticket [dba59ec54423f19]

drh 2010-08-19 11:46 trunk
Commit e0248776d31daa4b7a57593cb48f4ddda7364bb5
2 files changed +18 -2 +2 -3
+18 -2
--- src/checkin.c
+++ src/checkin.c
@@ -518,10 +518,27 @@
518518
fossil_fatal("ancestor check-in [%.10s] (%s) is younger (clock skew?)",
519519
zUuid, zDate);
520520
}
521521
#endif
522522
}
523
+
524
+/*
525
+** zDate should be a valid date string. Convert this string into the
526
+** format YYYY-MM-DDTHH:MM:SS. If the string is not a valid date,
527
+** print a fatal error and quit.
528
+*/
529
+char *date_in_standard_format(const char *zInputDate){
530
+ char *zDate = db_text(0, "SELECT datetime(%Q)", zInputDate);
531
+ if( zDate[0]==0 ){
532
+ fossil_fatal("unrecognized date format (%s): use \"YYYY-MM-DD HH:MM:SS\"",
533
+ zInputDate);
534
+ }
535
+ assert( strlen(zDate)==19 );
536
+ assert( zDate[10]==' ' );
537
+ zDate[10] = 'T';
538
+ return zDate;
539
+}
523540
524541
/*
525542
** COMMAND: ci
526543
** COMMAND: commit
527544
**
@@ -739,12 +756,11 @@
739756
blob_zero(&manifest);
740757
if( blob_size(&comment)==0 ){
741758
blob_append(&comment, "(no comment)", -1);
742759
}
743760
blob_appendf(&manifest, "C %F\n", blob_str(&comment));
744
- zDate = db_text(0, "SELECT datetime('%q')", zDateOvrd ? zDateOvrd : "now");
745
- zDate[10] = 'T';
761
+ zDate = date_in_standard_format(zDateOvrd ? zDateOvrd : "now");
746762
blob_appendf(&manifest, "D %s\n", zDate);
747763
zDate[10] = ' ';
748764
db_prepare(&q,
749765
"SELECT pathname, uuid, origname, blob.rid, isexe"
750766
" FROM vfile JOIN blob ON vfile.mrid=blob.rid"
751767
--- src/checkin.c
+++ src/checkin.c
@@ -518,10 +518,27 @@
518 fossil_fatal("ancestor check-in [%.10s] (%s) is younger (clock skew?)",
519 zUuid, zDate);
520 }
521 #endif
522 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
523
524 /*
525 ** COMMAND: ci
526 ** COMMAND: commit
527 **
@@ -739,12 +756,11 @@
739 blob_zero(&manifest);
740 if( blob_size(&comment)==0 ){
741 blob_append(&comment, "(no comment)", -1);
742 }
743 blob_appendf(&manifest, "C %F\n", blob_str(&comment));
744 zDate = db_text(0, "SELECT datetime('%q')", zDateOvrd ? zDateOvrd : "now");
745 zDate[10] = 'T';
746 blob_appendf(&manifest, "D %s\n", zDate);
747 zDate[10] = ' ';
748 db_prepare(&q,
749 "SELECT pathname, uuid, origname, blob.rid, isexe"
750 " FROM vfile JOIN blob ON vfile.mrid=blob.rid"
751
--- src/checkin.c
+++ src/checkin.c
@@ -518,10 +518,27 @@
518 fossil_fatal("ancestor check-in [%.10s] (%s) is younger (clock skew?)",
519 zUuid, zDate);
520 }
521 #endif
522 }
523
524 /*
525 ** zDate should be a valid date string. Convert this string into the
526 ** format YYYY-MM-DDTHH:MM:SS. If the string is not a valid date,
527 ** print a fatal error and quit.
528 */
529 char *date_in_standard_format(const char *zInputDate){
530 char *zDate = db_text(0, "SELECT datetime(%Q)", zInputDate);
531 if( zDate[0]==0 ){
532 fossil_fatal("unrecognized date format (%s): use \"YYYY-MM-DD HH:MM:SS\"",
533 zInputDate);
534 }
535 assert( strlen(zDate)==19 );
536 assert( zDate[10]==' ' );
537 zDate[10] = 'T';
538 return zDate;
539 }
540
541 /*
542 ** COMMAND: ci
543 ** COMMAND: commit
544 **
@@ -739,12 +756,11 @@
756 blob_zero(&manifest);
757 if( blob_size(&comment)==0 ){
758 blob_append(&comment, "(no comment)", -1);
759 }
760 blob_appendf(&manifest, "C %F\n", blob_str(&comment));
761 zDate = date_in_standard_format(zDateOvrd ? zDateOvrd : "now");
 
762 blob_appendf(&manifest, "D %s\n", zDate);
763 zDate[10] = ' ';
764 db_prepare(&q,
765 "SELECT pathname, uuid, origname, blob.rid, isexe"
766 " FROM vfile JOIN blob ON vfile.mrid=blob.rid"
767
+2 -3
--- src/db.c
+++ src/db.c
@@ -134,16 +134,16 @@
134134
if( busy || g.db==0 ) return;
135135
busy = 1;
136136
undo_rollback();
137137
if( nBegin ){
138138
sqlite3_exec(g.db, "ROLLBACK", 0, 0, 0);
139
+ nBegin = 0;
139140
if( isNewRepo ){
140141
db_close();
141142
unlink(g.zRepositoryName);
142143
}
143144
}
144
- nBegin = 0;
145145
busy = 0;
146146
}
147147
148148
/*
149149
** Install a commit hook. Hooks are installed in sequence order.
@@ -1005,12 +1005,11 @@
10051005
10061006
if( zInitialDate ){
10071007
int rid;
10081008
blob_zero(&manifest);
10091009
blob_appendf(&manifest, "C initial\\sempty\\scheck-in\n");
1010
- zDate = db_text(0, "SELECT datetime(%Q)", zInitialDate);
1011
- zDate[10]='T';
1010
+ zDate = date_in_standard_format(zInitialDate);
10121011
blob_appendf(&manifest, "D %s\n", zDate);
10131012
blob_appendf(&manifest, "P\n");
10141013
md5sum_init();
10151014
blob_appendf(&manifest, "R %s\n", md5sum_finish(0));
10161015
blob_appendf(&manifest, "T *branch * trunk\n");
10171016
--- src/db.c
+++ src/db.c
@@ -134,16 +134,16 @@
134 if( busy || g.db==0 ) return;
135 busy = 1;
136 undo_rollback();
137 if( nBegin ){
138 sqlite3_exec(g.db, "ROLLBACK", 0, 0, 0);
 
139 if( isNewRepo ){
140 db_close();
141 unlink(g.zRepositoryName);
142 }
143 }
144 nBegin = 0;
145 busy = 0;
146 }
147
148 /*
149 ** Install a commit hook. Hooks are installed in sequence order.
@@ -1005,12 +1005,11 @@
1005
1006 if( zInitialDate ){
1007 int rid;
1008 blob_zero(&manifest);
1009 blob_appendf(&manifest, "C initial\\sempty\\scheck-in\n");
1010 zDate = db_text(0, "SELECT datetime(%Q)", zInitialDate);
1011 zDate[10]='T';
1012 blob_appendf(&manifest, "D %s\n", zDate);
1013 blob_appendf(&manifest, "P\n");
1014 md5sum_init();
1015 blob_appendf(&manifest, "R %s\n", md5sum_finish(0));
1016 blob_appendf(&manifest, "T *branch * trunk\n");
1017
--- src/db.c
+++ src/db.c
@@ -134,16 +134,16 @@
134 if( busy || g.db==0 ) return;
135 busy = 1;
136 undo_rollback();
137 if( nBegin ){
138 sqlite3_exec(g.db, "ROLLBACK", 0, 0, 0);
139 nBegin = 0;
140 if( isNewRepo ){
141 db_close();
142 unlink(g.zRepositoryName);
143 }
144 }
 
145 busy = 0;
146 }
147
148 /*
149 ** Install a commit hook. Hooks are installed in sequence order.
@@ -1005,12 +1005,11 @@
1005
1006 if( zInitialDate ){
1007 int rid;
1008 blob_zero(&manifest);
1009 blob_appendf(&manifest, "C initial\\sempty\\scheck-in\n");
1010 zDate = date_in_standard_format(zInitialDate);
 
1011 blob_appendf(&manifest, "D %s\n", zDate);
1012 blob_appendf(&manifest, "P\n");
1013 md5sum_init();
1014 blob_appendf(&manifest, "R %s\n", md5sum_finish(0));
1015 blob_appendf(&manifest, "T *branch * trunk\n");
1016

Keyboard Shortcuts

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