Index: src/checkin.c ================================================================== --- src/checkin.c +++ src/checkin.c @@ -1836,11 +1836,10 @@ " AND value=%Q", TAG_BRANCH, vid, sCiInfo.zBranch)) ){ fossil_fatal("cannot commit against a closed leaf"); } - if( useCksum ) vfile_aggregate_checksum_disk(vid, &cksum1); if( zComment ){ blob_zero(&comment); blob_append(&comment, zComment, -1); }else if( zComFile ){ blob_zero(&comment); @@ -1869,15 +1868,45 @@ }else{ db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment); db_end_transaction(0); db_begin_transaction(); } + + /* Step 0: If the repository does not have any artifacts yet + ** and a non-empty commit is being prepared, create an additional + ** empty check-in for compatibility with fossil<1.28. This + ** section can be removed when Fossil 1.27 is not used any more. + */ + + if( !db_exists("SELECT 1 FROM blob") && db_exists("SELECT 1 FROM vfile")){ + int rid; + const char *zDate; + Blob hash; + blob_zero(&manifest); + blob_appendf(&manifest, "C initial\\sempty\\scheck-in\n"); + zDate = date_in_standard_format(sCiInfo.zDateOvrd ? sCiInfo.zDateOvrd : "now"); + blob_appendf(&manifest, "D %s\n", zDate); + md5sum_init(); + /* The R-card is necessary here because without it + * fossil versions earlier than versions 1.27 would + * interpret this artifact as a "control". */ + blob_appendf(&manifest, "R %s\n", md5sum_finish(0)); + blob_appendf(&manifest, "T *branch * %F\n", sCiInfo.zBranch); + blob_appendf(&manifest, "T *sym-%F *\n", sCiInfo.zBranch); + blob_appendf(&manifest, "U %F\n", g.zLogin); + md5sum_blob(&manifest, &hash); + blob_appendf(&manifest, "Z %b\n", &hash); + blob_reset(&hash); + vid = content_put(&manifest); + manifest_crosslink(vid, &manifest, MC_NONE); + } /* Step 1: Insert records for all modified files into the blob ** table. If there were arguments passed to this command, only ** the identified files are inserted (if they have been modified). */ + if( useCksum ) vfile_aggregate_checksum_disk(vid, &cksum1); db_prepare(&q, "SELECT id, %Q || pathname, mrid, %s, chnged, %s, %s FROM vfile " "WHERE chnged==1 AND NOT deleted AND is_selected(id)", g.zLocalRoot, glob_expr("pathname", db_get("crnl-glob","")), Index: src/db.c ================================================================== --- src/db.c +++ src/db.c @@ -1666,10 +1666,11 @@ void create_repository_cmd(void){ char *zPassword; const char *zTemplate; /* Repository from which to copy settings */ const char *zDate; /* Date of the initial check-in */ const char *zDefaultUser; /* Optional name of the default user */ + int makeServerCodes = find_option("docker", 0, 0)==0 zTemplate = find_option("template",0,1); zDate = find_option("date-override",0,1); zDefaultUser = find_option("admin-user","A",1); /* We should be done with options.. */ @@ -1686,16 +1687,17 @@ db_create_repository(g.argv[2]); db_open_repository(g.argv[2]); db_open_config(0); if( zTemplate ) db_attach(zTemplate, "settingSrc"); db_begin_transaction(); - if( zDate==0 ) zDate = "now"; - db_initial_setup(zTemplate, zDate, zDefaultUser, 1); + db_initial_setup(zTemplate, zDate, zDefaultUser, makeServerCodes); db_end_transaction(0); if( zTemplate ) db_detach("settingSrc"); - fossil_print("project-id: %s\n", db_get("project-code", 0)); - fossil_print("server-id: %s\n", db_get("server-code", 0)); + if( makeServerCodes ){ + fossil_print("project-id: %s\n", db_get("project-code", 0)); + fossil_print("server-id: %s\n", db_get("server-code", 0)); + } zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin); fossil_print("admin-user: %s (initial password is \"%s\")\n", g.zLogin, zPassword); }