Fossil SCM
When committing on Windows with the "l" manifest flag set, update the symlink permission for selected files from the manifest.symlinks file if it exists
Commit
2808e225964e5030e6329ff6dfcf662d7bc0ecdbdb3bc2b9635390831c4dec09
Parent
109c956ff1d615a…
1 file changed
+47
-3
+47
-3
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -1499,10 +1499,46 @@ | ||
| 1499 | 1499 | Blob mcksum; /* Manifest checksum */ |
| 1500 | 1500 | ManifestFile *pFile; /* File from the baseline */ |
| 1501 | 1501 | int nFBcard = 0; /* Number of B-cards and F-cards */ |
| 1502 | 1502 | int i; /* Loop counter */ |
| 1503 | 1503 | const char *zColor; /* Modified value of p->zColor */ |
| 1504 | + | |
| 1505 | +#ifdef _WIN32 | |
| 1506 | + /* On Windows, if the "manifest" setting contains the "l" flag, get the | |
| 1507 | + * symlink status bits from the "manifest.symlinks" file. */ | |
| 1508 | + int manifestSymlinks = db_get_manifest_setting() & MFESTFLG_SYMLINKS; | |
| 1509 | + if( manifestSymlinks ){ | |
| 1510 | + char *zFile = mprintf("%smanifest.symlinks", g.zLocalRoot); | |
| 1511 | + if( file_wd_size(zFile)>=0 ){ | |
| 1512 | + /* If the file exists, read its contents into a temporary table. */ | |
| 1513 | + char *zLine, *zEnd; | |
| 1514 | + Blob content = BLOB_INITIALIZER; | |
| 1515 | + blob_read_from_file(&content, zFile); | |
| 1516 | + blob_append(&content, "\n", 2); | |
| 1517 | + db_multi_exec("CREATE TEMP TABLE symlink(filename TEXT PRIMARY KEY %s)", | |
| 1518 | + filename_collation()); | |
| 1519 | + zLine = blob_buffer(&content); | |
| 1520 | + while( *zLine ){ | |
| 1521 | + /* Find end of line and replace with NUL. */ | |
| 1522 | + for( zEnd = zLine; *zEnd!='\r' && *zEnd!='\n'; ++zEnd ); | |
| 1523 | + *zEnd = 0; | |
| 1524 | + | |
| 1525 | + /* If not a blank line, insert filename into symlink table. */ | |
| 1526 | + if( *zLine ){ | |
| 1527 | + db_multi_exec("INSERT OR IGNORE INTO symlink VALUES(%Q)", zLine); | |
| 1528 | + } | |
| 1529 | + | |
| 1530 | + /* Find start of next line, or find terminating NUL at end of file. */ | |
| 1531 | + for( zLine = zEnd+1; *zLine=='\r' || *zLine=='\n'; ++zLine ); | |
| 1532 | + } | |
| 1533 | + blob_reset(&content); | |
| 1534 | + }else{ | |
| 1535 | + /* If the file is nonexistent, pretend the "l" flag was not specified. */ | |
| 1536 | + manifestSymlinks = 0; | |
| 1537 | + } | |
| 1538 | + } | |
| 1539 | +#endif | |
| 1504 | 1540 | |
| 1505 | 1541 | assert( pBaseline==0 || pBaseline->zBaseline==0 ); |
| 1506 | 1542 | assert( pBaseline==0 || zBaselineUuid!=0 ); |
| 1507 | 1543 | blob_zero(pOut); |
| 1508 | 1544 | if( vid ){ |
| @@ -1553,15 +1589,23 @@ | ||
| 1553 | 1589 | int cmp; |
| 1554 | 1590 | |
| 1555 | 1591 | blob_resize(&filename, nBasename); |
| 1556 | 1592 | blob_append(&filename, zName, -1); |
| 1557 | 1593 | |
| 1558 | -#if !defined(_WIN32) | |
| 1594 | + /* Potentially update the permissions of files selected to be checked in. */ | |
| 1595 | +#ifdef _WIN32 | |
| 1596 | + /* For Windows, if the "manifest" setting contains the "l" flag and the | |
| 1597 | + ** "manifest.symlinks" file exists, use its contents to determine which | |
| 1598 | + ** files do and do not have the "symlink" permission. | |
| 1599 | + */ | |
| 1600 | + if( isSelected && manifestSymlinks ){ | |
| 1601 | + isLink = db_exists("SELECT 1 FROM symlink WHERE filename=%Q", zName); | |
| 1602 | + } | |
| 1603 | +#else | |
| 1559 | 1604 | /* For unix, extract the "executable" and "symlink" permissions |
| 1560 | 1605 | ** directly from the filesystem. On windows, permissions are |
| 1561 | - ** unchanged from the original. However, only do this if the file | |
| 1562 | - ** itself is actually selected to be part of this check-in. | |
| 1606 | + ** unchanged from the original. | |
| 1563 | 1607 | */ |
| 1564 | 1608 | if( isSelected ){ |
| 1565 | 1609 | int mPerm; |
| 1566 | 1610 | |
| 1567 | 1611 | mPerm = file_wd_perm(blob_str(&filename)); |
| 1568 | 1612 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -1499,10 +1499,46 @@ | |
| 1499 | Blob mcksum; /* Manifest checksum */ |
| 1500 | ManifestFile *pFile; /* File from the baseline */ |
| 1501 | int nFBcard = 0; /* Number of B-cards and F-cards */ |
| 1502 | int i; /* Loop counter */ |
| 1503 | const char *zColor; /* Modified value of p->zColor */ |
| 1504 | |
| 1505 | assert( pBaseline==0 || pBaseline->zBaseline==0 ); |
| 1506 | assert( pBaseline==0 || zBaselineUuid!=0 ); |
| 1507 | blob_zero(pOut); |
| 1508 | if( vid ){ |
| @@ -1553,15 +1589,23 @@ | |
| 1553 | int cmp; |
| 1554 | |
| 1555 | blob_resize(&filename, nBasename); |
| 1556 | blob_append(&filename, zName, -1); |
| 1557 | |
| 1558 | #if !defined(_WIN32) |
| 1559 | /* For unix, extract the "executable" and "symlink" permissions |
| 1560 | ** directly from the filesystem. On windows, permissions are |
| 1561 | ** unchanged from the original. However, only do this if the file |
| 1562 | ** itself is actually selected to be part of this check-in. |
| 1563 | */ |
| 1564 | if( isSelected ){ |
| 1565 | int mPerm; |
| 1566 | |
| 1567 | mPerm = file_wd_perm(blob_str(&filename)); |
| 1568 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -1499,10 +1499,46 @@ | |
| 1499 | Blob mcksum; /* Manifest checksum */ |
| 1500 | ManifestFile *pFile; /* File from the baseline */ |
| 1501 | int nFBcard = 0; /* Number of B-cards and F-cards */ |
| 1502 | int i; /* Loop counter */ |
| 1503 | const char *zColor; /* Modified value of p->zColor */ |
| 1504 | |
| 1505 | #ifdef _WIN32 |
| 1506 | /* On Windows, if the "manifest" setting contains the "l" flag, get the |
| 1507 | * symlink status bits from the "manifest.symlinks" file. */ |
| 1508 | int manifestSymlinks = db_get_manifest_setting() & MFESTFLG_SYMLINKS; |
| 1509 | if( manifestSymlinks ){ |
| 1510 | char *zFile = mprintf("%smanifest.symlinks", g.zLocalRoot); |
| 1511 | if( file_wd_size(zFile)>=0 ){ |
| 1512 | /* If the file exists, read its contents into a temporary table. */ |
| 1513 | char *zLine, *zEnd; |
| 1514 | Blob content = BLOB_INITIALIZER; |
| 1515 | blob_read_from_file(&content, zFile); |
| 1516 | blob_append(&content, "\n", 2); |
| 1517 | db_multi_exec("CREATE TEMP TABLE symlink(filename TEXT PRIMARY KEY %s)", |
| 1518 | filename_collation()); |
| 1519 | zLine = blob_buffer(&content); |
| 1520 | while( *zLine ){ |
| 1521 | /* Find end of line and replace with NUL. */ |
| 1522 | for( zEnd = zLine; *zEnd!='\r' && *zEnd!='\n'; ++zEnd ); |
| 1523 | *zEnd = 0; |
| 1524 | |
| 1525 | /* If not a blank line, insert filename into symlink table. */ |
| 1526 | if( *zLine ){ |
| 1527 | db_multi_exec("INSERT OR IGNORE INTO symlink VALUES(%Q)", zLine); |
| 1528 | } |
| 1529 | |
| 1530 | /* Find start of next line, or find terminating NUL at end of file. */ |
| 1531 | for( zLine = zEnd+1; *zLine=='\r' || *zLine=='\n'; ++zLine ); |
| 1532 | } |
| 1533 | blob_reset(&content); |
| 1534 | }else{ |
| 1535 | /* If the file is nonexistent, pretend the "l" flag was not specified. */ |
| 1536 | manifestSymlinks = 0; |
| 1537 | } |
| 1538 | } |
| 1539 | #endif |
| 1540 | |
| 1541 | assert( pBaseline==0 || pBaseline->zBaseline==0 ); |
| 1542 | assert( pBaseline==0 || zBaselineUuid!=0 ); |
| 1543 | blob_zero(pOut); |
| 1544 | if( vid ){ |
| @@ -1553,15 +1589,23 @@ | |
| 1589 | int cmp; |
| 1590 | |
| 1591 | blob_resize(&filename, nBasename); |
| 1592 | blob_append(&filename, zName, -1); |
| 1593 | |
| 1594 | /* Potentially update the permissions of files selected to be checked in. */ |
| 1595 | #ifdef _WIN32 |
| 1596 | /* For Windows, if the "manifest" setting contains the "l" flag and the |
| 1597 | ** "manifest.symlinks" file exists, use its contents to determine which |
| 1598 | ** files do and do not have the "symlink" permission. |
| 1599 | */ |
| 1600 | if( isSelected && manifestSymlinks ){ |
| 1601 | isLink = db_exists("SELECT 1 FROM symlink WHERE filename=%Q", zName); |
| 1602 | } |
| 1603 | #else |
| 1604 | /* For unix, extract the "executable" and "symlink" permissions |
| 1605 | ** directly from the filesystem. On windows, permissions are |
| 1606 | ** unchanged from the original. |
| 1607 | */ |
| 1608 | if( isSelected ){ |
| 1609 | int mPerm; |
| 1610 | |
| 1611 | mPerm = file_wd_perm(blob_str(&filename)); |
| 1612 |