Fossil SCM

When generating the "manifest" file in a checkout because "fossil setting manifest" is turned on, add an extra line of text to the end of the file to prevent the file from being interpreted as a valid control artifact in case the complete source tree is imported into another unrelated Fossil project.

drh 2014-09-23 16:02 trunk
Commit 1dd4be80ca809afacbd4ddac15b69a2d41464b9f
+3 -2
--- src/checkout.c
+++ src/checkout.c
@@ -137,14 +137,15 @@
137137
138138
if( db_get_boolean("manifest",0) ){
139139
blob_zero(&manifest);
140140
content_get(vid, &manifest);
141141
zManFile = mprintf("%smanifest", g.zLocalRoot);
142
- blob_write_to_file(&manifest, zManFile);
143
- free(zManFile);
144142
blob_zero(&hash);
145143
sha1sum_blob(&manifest, &hash);
144
+ sterilize_manifest(&manifest);
145
+ blob_write_to_file(&manifest, zManFile);
146
+ free(zManFile);
146147
zManFile = mprintf("%smanifest.uuid", g.zLocalRoot);
147148
blob_append(&hash, "\n", 1);
148149
blob_write_to_file(&hash, zManFile);
149150
free(zManFile);
150151
blob_reset(&hash);
151152
--- src/checkout.c
+++ src/checkout.c
@@ -137,14 +137,15 @@
137
138 if( db_get_boolean("manifest",0) ){
139 blob_zero(&manifest);
140 content_get(vid, &manifest);
141 zManFile = mprintf("%smanifest", g.zLocalRoot);
142 blob_write_to_file(&manifest, zManFile);
143 free(zManFile);
144 blob_zero(&hash);
145 sha1sum_blob(&manifest, &hash);
 
 
 
146 zManFile = mprintf("%smanifest.uuid", g.zLocalRoot);
147 blob_append(&hash, "\n", 1);
148 blob_write_to_file(&hash, zManFile);
149 free(zManFile);
150 blob_reset(&hash);
151
--- src/checkout.c
+++ src/checkout.c
@@ -137,14 +137,15 @@
137
138 if( db_get_boolean("manifest",0) ){
139 blob_zero(&manifest);
140 content_get(vid, &manifest);
141 zManFile = mprintf("%smanifest", g.zLocalRoot);
 
 
142 blob_zero(&hash);
143 sha1sum_blob(&manifest, &hash);
144 sterilize_manifest(&manifest);
145 blob_write_to_file(&manifest, zManFile);
146 free(zManFile);
147 zManFile = mprintf("%smanifest.uuid", g.zLocalRoot);
148 blob_append(&hash, "\n", 1);
149 blob_write_to_file(&hash, zManFile);
150 free(zManFile);
151 blob_reset(&hash);
152
--- src/manifest.c
+++ src/manifest.c
@@ -1641,10 +1641,48 @@
16411641
blob_str(&comment), blob_str(&brief)
16421642
);
16431643
blob_reset(&comment);
16441644
blob_reset(&brief);
16451645
}
1646
+
1647
+/*
1648
+** Add an extra line of text to the end of a manifest to prevent it being
1649
+** recognized as a valid manifest.
1650
+**
1651
+** This routine is called prior to writing out the text of a manifest as
1652
+** the "manifest" file in the root of a repository when
1653
+** "fossil setting manifest on" is enabled. That way, if the files of
1654
+** the project are imported into a different Fossil project, the manifest
1655
+** file will not be interpreted as a control artifact in that other project.
1656
+**
1657
+** Normally it is sufficient to simply append the extra line of text.
1658
+** However, if the manifest is PGP signed then the extra line has to be
1659
+** inserted before the PGP signature (thus invalidating the signature).
1660
+*/
1661
+void sterilize_manifest(Blob *p){
1662
+ char *z, *zOrig;
1663
+ int n, nOrig;
1664
+ static const char zExtraLine[] =
1665
+ "# Remove this line to create a well-formed manifest.\n";
1666
+
1667
+ z = zOrig = blob_materialize(p);
1668
+ n = nOrig = blob_size(p);
1669
+ remove_pgp_signature(&z, &n);
1670
+ if( z==zOrig ){
1671
+ blob_append(p, zExtraLine, -1);
1672
+ }else{
1673
+ int iEnd;
1674
+ Blob copy;
1675
+ memcpy(&copy, p, sizeof(copy));
1676
+ blob_init(p, 0, 0);
1677
+ iEnd = (int)(&z[n] - zOrig);
1678
+ blob_append(p, zOrig, iEnd);
1679
+ blob_append(p, zExtraLine, -1);
1680
+ blob_append(p, &zOrig[iEnd], -1);
1681
+ blob_zero(&copy);
1682
+ }
1683
+}
16461684
16471685
/*
16481686
** This is the comparison function used to sort the tag array.
16491687
*/
16501688
static int tag_compare(const void *a, const void *b){
16511689
--- src/manifest.c
+++ src/manifest.c
@@ -1641,10 +1641,48 @@
1641 blob_str(&comment), blob_str(&brief)
1642 );
1643 blob_reset(&comment);
1644 blob_reset(&brief);
1645 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1646
1647 /*
1648 ** This is the comparison function used to sort the tag array.
1649 */
1650 static int tag_compare(const void *a, const void *b){
1651
--- src/manifest.c
+++ src/manifest.c
@@ -1641,10 +1641,48 @@
1641 blob_str(&comment), blob_str(&brief)
1642 );
1643 blob_reset(&comment);
1644 blob_reset(&brief);
1645 }
1646
1647 /*
1648 ** Add an extra line of text to the end of a manifest to prevent it being
1649 ** recognized as a valid manifest.
1650 **
1651 ** This routine is called prior to writing out the text of a manifest as
1652 ** the "manifest" file in the root of a repository when
1653 ** "fossil setting manifest on" is enabled. That way, if the files of
1654 ** the project are imported into a different Fossil project, the manifest
1655 ** file will not be interpreted as a control artifact in that other project.
1656 **
1657 ** Normally it is sufficient to simply append the extra line of text.
1658 ** However, if the manifest is PGP signed then the extra line has to be
1659 ** inserted before the PGP signature (thus invalidating the signature).
1660 */
1661 void sterilize_manifest(Blob *p){
1662 char *z, *zOrig;
1663 int n, nOrig;
1664 static const char zExtraLine[] =
1665 "# Remove this line to create a well-formed manifest.\n";
1666
1667 z = zOrig = blob_materialize(p);
1668 n = nOrig = blob_size(p);
1669 remove_pgp_signature(&z, &n);
1670 if( z==zOrig ){
1671 blob_append(p, zExtraLine, -1);
1672 }else{
1673 int iEnd;
1674 Blob copy;
1675 memcpy(&copy, p, sizeof(copy));
1676 blob_init(p, 0, 0);
1677 iEnd = (int)(&z[n] - zOrig);
1678 blob_append(p, zOrig, iEnd);
1679 blob_append(p, zExtraLine, -1);
1680 blob_append(p, &zOrig[iEnd], -1);
1681 blob_zero(&copy);
1682 }
1683 }
1684
1685 /*
1686 ** This is the comparison function used to sort the tag array.
1687 */
1688 static int tag_compare(const void *a, const void *b){
1689
+2 -1
--- src/tar.c
+++ src/tar.c
@@ -492,12 +492,13 @@
492492
mTime = (pManifest->rDate - 2440587.5)*86400.0;
493493
tar_begin(mTime);
494494
if( db_get_boolean("manifest", 0) ){
495495
blob_append(&filename, "manifest", -1);
496496
zName = blob_str(&filename);
497
- tar_add_file(zName, &mfile, 0, mTime);
498497
sha1sum_blob(&mfile, &hash);
498
+ sterilize_manifest(&mfile);
499
+ tar_add_file(zName, &mfile, 0, mTime);
499500
blob_reset(&mfile);
500501
blob_append(&hash, "\n", 1);
501502
blob_resize(&filename, nPrefix);
502503
blob_append(&filename, "manifest.uuid", -1);
503504
zName = blob_str(&filename);
504505
--- src/tar.c
+++ src/tar.c
@@ -492,12 +492,13 @@
492 mTime = (pManifest->rDate - 2440587.5)*86400.0;
493 tar_begin(mTime);
494 if( db_get_boolean("manifest", 0) ){
495 blob_append(&filename, "manifest", -1);
496 zName = blob_str(&filename);
497 tar_add_file(zName, &mfile, 0, mTime);
498 sha1sum_blob(&mfile, &hash);
 
 
499 blob_reset(&mfile);
500 blob_append(&hash, "\n", 1);
501 blob_resize(&filename, nPrefix);
502 blob_append(&filename, "manifest.uuid", -1);
503 zName = blob_str(&filename);
504
--- src/tar.c
+++ src/tar.c
@@ -492,12 +492,13 @@
492 mTime = (pManifest->rDate - 2440587.5)*86400.0;
493 tar_begin(mTime);
494 if( db_get_boolean("manifest", 0) ){
495 blob_append(&filename, "manifest", -1);
496 zName = blob_str(&filename);
 
497 sha1sum_blob(&mfile, &hash);
498 sterilize_manifest(&mfile);
499 tar_add_file(zName, &mfile, 0, mTime);
500 blob_reset(&mfile);
501 blob_append(&hash, "\n", 1);
502 blob_resize(&filename, nPrefix);
503 blob_append(&filename, "manifest.uuid", -1);
504 zName = blob_str(&filename);
505
+2 -1
--- src/zip.c
+++ src/zip.c
@@ -350,12 +350,13 @@
350350
zip_set_timedate(pManifest->rDate);
351351
if( db_get_boolean("manifest", 0) ){
352352
blob_append(&filename, "manifest", -1);
353353
zName = blob_str(&filename);
354354
zip_add_folders(zName);
355
- zip_add_file(zName, &mfile, 0);
356355
sha1sum_blob(&mfile, &hash);
356
+ sterilize_manifest(&mfile);
357
+ zip_add_file(zName, &mfile, 0);
357358
blob_reset(&mfile);
358359
blob_append(&hash, "\n", 1);
359360
blob_resize(&filename, nPrefix);
360361
blob_append(&filename, "manifest.uuid", -1);
361362
zName = blob_str(&filename);
362363
--- src/zip.c
+++ src/zip.c
@@ -350,12 +350,13 @@
350 zip_set_timedate(pManifest->rDate);
351 if( db_get_boolean("manifest", 0) ){
352 blob_append(&filename, "manifest", -1);
353 zName = blob_str(&filename);
354 zip_add_folders(zName);
355 zip_add_file(zName, &mfile, 0);
356 sha1sum_blob(&mfile, &hash);
 
 
357 blob_reset(&mfile);
358 blob_append(&hash, "\n", 1);
359 blob_resize(&filename, nPrefix);
360 blob_append(&filename, "manifest.uuid", -1);
361 zName = blob_str(&filename);
362
--- src/zip.c
+++ src/zip.c
@@ -350,12 +350,13 @@
350 zip_set_timedate(pManifest->rDate);
351 if( db_get_boolean("manifest", 0) ){
352 blob_append(&filename, "manifest", -1);
353 zName = blob_str(&filename);
354 zip_add_folders(zName);
 
355 sha1sum_blob(&mfile, &hash);
356 sterilize_manifest(&mfile);
357 zip_add_file(zName, &mfile, 0);
358 blob_reset(&mfile);
359 blob_append(&hash, "\n", 1);
360 blob_resize(&filename, nPrefix);
361 blob_append(&filename, "manifest.uuid", -1);
362 zName = blob_str(&filename);
363

Keyboard Shortcuts

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