Fossil

Check-in [2808e225]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | enhanced-symlink
Files: files | file ages | folders
SHA3-256:2808e225964e5030e6329ff6dfcf662d7bc0ecdbdb3bc2b9635390831c4dec09
User & Date: andygoth 2017-10-14 21:13:39
Context
2017-10-14
21:32
Move manifest.symlinks read functionality into the new get_checkout_symlink_table() function in checkout.c check-in: 7a4bd5cf user: andygoth tags: enhanced-symlink
21:13
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 check-in: 2808e225 user: andygoth tags: enhanced-symlink
19:32
Correct help text for open command check-in: 109c956f user: andygoth tags: enhanced-symlink
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/checkin.c.

  1497   1497     int nBasename;              /* Size of base filename */
  1498   1498     Stmt q;                     /* Various queries */
  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 ){
  1509   1545       zParentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d AND "
  1510   1546         "EXISTS(SELECT 1 FROM event WHERE event.type='ci' and event.objid=%d)",
................................................................................
  1551   1587       int isSelected = db_column_int(&q, 6);
  1552   1588       const char *zPerm;
  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         isExe = ( mPerm==PERM_EXE );
  1569   1613         isLink = ( mPerm==PERM_LNK );