Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add symlink support for Unix. New settings flag "allow-symlinks" controls this (off by default). |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | symlinks |
Files: | files | file ages | folders |
SHA1: |
ed2ef7e9a3b6a46da6bad49aa777e10b |
User & Date: | dmitry 2011-01-28 19:04:30.652 |
Context
2011-02-07
| ||
17:50 | Fix segmentation fault in historical_version_of_file() when file has no permissions in manifest. ... (check-in: 8e4e30fb user: dmitry tags: symlinks) | |
2011-01-28
| ||
19:04 | Add symlink support for Unix. New settings flag "allow-symlinks" controls this (off by default). ... (check-in: ed2ef7e9 user: dmitry tags: symlinks) | |
18:57 | Create new branch named "symlinks". Mailing list thread ... (check-in: a7b7ff3a user: dmitry tags: symlinks) | |
Changes
Changes to src/add.c.
︙ | |||
181 182 183 184 185 186 187 | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | - + | } blob_appendf(&path, "/%s", pEntry->d_name); zPath = blob_str(&path); if( shouldBeIgnored(pIgnore, zPath) ){ /* Noop */ }else if( file_isdir(zPath)==1 ){ add_directory_content(zPath, pIgnore); |
︙ | |||
302 303 304 305 306 307 308 | 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | - + | if( pEntry->d_name[1]==0 ) continue; if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue; } blob_appendf(&path, "/%s", pEntry->d_name); zPath = blob_str(&path); if( file_isdir(zPath)==1 ){ del_directory_content(zPath); |
︙ | |||
460 461 462 463 464 465 466 | 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 | - + | ); while( db_step(&q)==SQLITE_ROW ){ const char * zFile; const char * zPath; zFile = db_column_text(&q, 0); zPath = db_column_text(&q, 1); |
︙ |
Changes to src/blob.c.
︙ | |||
643 644 645 646 647 648 649 650 651 652 653 654 655 656 | 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 | + + + + + + + + + + + + + + + + + + + + + + + | got = fread(blob_buffer(pBlob), 1, size, in); fclose(in); if( got<size ){ blob_resize(pBlob, got); } return got; } /* ** Reads symlink destination path and puts int into blob. ** Any prior content of the blob is discarded, not freed. ** ** Returns length of destination path. ** ** On windows, zeros blob and returns 0. */ int blob_read_link(Blob *pBlob, const char *zFilename){ #if !defined(_WIN32) char zBuf[1024]; ssize_t len = readlink(zFilename, zBuf, 1023); zBuf[len] = 0; blob_zero(pBlob); blob_appendf(pBlob, "%s", zBuf); return len; #else blob_zero(pBlob); return 0; #endif } /* ** Write the content of a blob into a file. ** ** If the filename is blank or "-" then write to standard output. ** ** Return the number of bytes written. |
︙ |
Changes to src/checkin.c.
︙ | |||
51 52 53 54 55 56 57 | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | - + | int isChnged = db_column_int(&q,2); int isNew = db_column_int(&q,3)==0; int isRenamed = db_column_int(&q,4); char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); blob_append(report, zPrefix, nPrefix); if( isDeleted ){ blob_appendf(report, "DELETED %s\n", zPathname); |
︙ | |||
179 180 181 182 183 184 185 | 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | - + | char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); if( isBrief ){ printf("%s\n", zPathname); }else if( isNew ){ printf("ADDED %s\n", zPathname); }else if( isDeleted ){ printf("DELETED %s\n", zPathname); |
︙ | |||
617 618 619 620 621 622 623 | 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 | - + + - + + + + + + + + | pFile = 0; } blob_appendf(pOut, "C %F\n", blob_str(pComment)); zDate = date_in_standard_format(zDateOvrd ? zDateOvrd : "now"); blob_appendf(pOut, "D %s\n", zDate); zDate[10] = ' '; db_prepare(&q, |
︙ | |||
991 992 993 994 995 996 997 | 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 | + + + + - + + | Blob content; id = db_column_int(&q, 0); zFullname = db_column_text(&q, 1); rid = db_column_int(&q, 2); blob_zero(&content); if( file_islink(zFullname) ){ /* Instead of file content, put link destination path */ blob_read_link(&content, zFullname); }else{ |
︙ |
Changes to src/checkout.c.
︙ | |||
100 101 102 103 104 105 106 | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | - + + | db_bind_text(&s, ":path", zFilename); db_step(&s); db_reset(&s); } /* ** Set or clear the execute permission bit (as appropriate) for all |
︙ |
Changes to src/db.c.
︙ | |||
738 739 740 741 742 743 744 745 746 747 748 749 750 751 | 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 | + + + + + + + + + + + + + + + + + + + + + + + + + + | */ rc = sqlite3_prepare(g.db, "SELECT isexe FROM vfile", -1, &pStmt, 0); sqlite3_finalize(pStmt); if( rc==SQLITE_ERROR ){ sqlite3_exec(g.db, "ALTER TABLE vfile ADD COLUMN isexe BOOLEAN", 0, 0, 0); } /* If the "islink" column is missing from the vfile table, then ** add it now. This code added on 2011-01-17. After all users have ** upgraded, this code can be safely deleted. */ rc = sqlite3_prepare(g.db, "SELECT islink FROM vfile", -1, &pStmt, 0); sqlite3_finalize(pStmt); if( rc==SQLITE_ERROR ){ sqlite3_exec(g.db, "ALTER TABLE vfile ADD COLUMN islink BOOLEAN", 0, 0, 0); } #if 0 /* If the "isLink" column is missing from the stashfile table, then ** add it now. This code added on 2011-01-18. After all users have ** upgraded, this code can be safely deleted. ** ** Table stashfile may not exist at all. We don't handle this case, ** and leave it to sqlite. */ rc = sqlite3_prepare(g.db, "SELECT isLink FROM stashfile", -1, &pStmt, 0); sqlite3_finalize(pStmt); /* NOTE: this prints "SQLITE_ERROR: no such column: isLink" for some reason */ if( rc==SQLITE_ERROR ){ sqlite3_exec(g.db, "ALTER TABLE stashfile ADD COLUMN isLink BOOLEAN", 0, 0, 0); } #endif #if 0 /* If the "mtime" column is missing from the vfile table, then ** add it now. This code added on 2008-12-06. After all users have ** upgraded, this code can be safely deleted. */ rc = sqlite3_prepare(g.db, "SELECT mtime FROM vfile", -1, &pStmt, 0); sqlite3_finalize(pStmt); |
︙ | |||
845 846 847 848 849 850 851 852 853 854 855 856 857 858 | 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 | + + | }else{ fossil_panic("not a valid repository: %s", zDbName); } } db_open_or_attach(zDbName, "repository"); g.repositoryOpen = 1; g.zRepositoryName = mprintf("%s", zDbName); /* Cache "allow-symlinks" option, because we'll need it on every stat call */ g.allowSymlinks = db_get_boolean("allow-symlinks", 0); } /* ** Flags for the db_find_and_open_repository() function. */ #if INTERFACE #define OPEN_OK_NOT_FOUND 0x001 /* Do not error out if not found */ |
︙ | |||
1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 | 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 | + | char const *name; /* Name of the setting */ char const *var; /* Internal variable name used by db_set() */ int width; /* Width of display. 0 for boolean values */ char const *def; /* Default value */ }; #endif /* INTERFACE */ struct stControlSettings const ctrlSettings[] = { { "allow-symlinks",0, 0, "off" }, { "access-log", 0, 0, "off" }, { "auto-captcha", "autocaptcha", 0, "on" }, { "auto-shun", 0, 0, "on" }, { "autosync", 0, 0, "on" }, { "binary-glob", 0, 32, "" }, { "clearsign", 0, 0, "off" }, { "default-perms", 0, 16, "u" }, |
︙ | |||
1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 | 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 | + + + + + + | ** ** The "settings" command with no arguments lists all properties and their ** values. With just a property name it shows the value of that property. ** With a value argument it changes the property for the current repository. ** ** The "unset" command clears a property setting. ** ** ** allow-symlinks If enabled, don't follow symlinks, and instead treat ** them as symlinks on Unix. Has no effect on Windows ** (existing links in repository created on Unix become ** plain-text files with link destination path inside). ** Default: off ** ** auto-captcha If enabled, the Login page provides a button to ** fill in the captcha password. Default: on ** ** auto-shun If enabled, automatically pull the shunning list ** from a server to which the client autosyncs. ** Default: on |
︙ |
Changes to src/diffcmd.c.
︙ | |||
57 58 59 60 61 62 63 | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | + + + - + + | const char *zName2; /* Name of zFile2 for display */ /* Read content of zFile2 into memory */ blob_zero(&file2); if( file_size(zFile2)<0 ){ zName2 = "/dev/null"; }else{ if( file_islink(zFile2) ){ blob_read_link(&file2, zFile2); }else{ |
︙ | |||
166 167 168 169 170 171 172 173 | 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | + - - + + + + + + | static void diff_one_against_disk( const char *zFrom, /* Name of file */ const char *zDiffCmd, /* Use this "diff" command */ int ignoreEolWs /* Ignore whitespace changes at end of lines */ ){ Blob fname; Blob content; int isLink; file_tree_name(g.argv[2], &fname, 1); |
︙ | |||
202 203 204 205 206 207 208 | 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | - + - + - + - + + + + + + + + | if( zFrom ){ int rid = name_to_rid(zFrom); if( !is_a_version(rid) ){ fossil_fatal("no such check-in: %s", zFrom); } load_vfile_from_rid(rid); blob_appendf(&sql, |
︙ | |||
287 288 289 290 291 292 293 294 295 | 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | + - - - + + + + + + + + | const char *zTo, const char *zDiffCmd, int ignoreEolWs ){ char *zName; Blob fname; Blob v1, v2; int isLink1, isLink2; file_tree_name(g.argv[2], &fname, 1); zName = blob_str(&fname); |
︙ |
Changes to src/file.c.
︙ | |||
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | + + + + + + + + + + + + - + | #if defined(_WIN32) && defined(__MSVCRT__) static struct _stati64 fileStat; # define stat _stati64 #else static struct stat fileStat; #endif static int fileStatValid = 0; int fossil_stat(const char *zFilename, struct stat *buf){ #if !defined(_WIN32) if( g.allowSymlinks ){ return lstat(zFilename, buf); }else{ return stat(zFilename, buf); } #else return stat(zFilename, buf); #endif } /* ** Fill in the fileStat variable for the file named zFilename. ** If zFilename==0, then use the previous value of fileStat if ** there is a previous value. ** ** Return the number of errors. No error messages are generated. */ static int getStat(const char *zFilename){ int rc = 0; if( zFilename==0 ){ if( fileStatValid==0 ) rc = 1; }else{ |
︙ | |||
74 75 76 77 78 79 80 81 82 83 | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | ** Return the modification time for a file. Return -1 if the file ** does not exist. If zFilename is NULL return the size of the most ** recently stat-ed file. */ i64 file_mtime(const char *zFilename){ return getStat(zFilename) ? -1 : fileStat.st_mtime; } /* ** Return TRUE if the named file is an ordinary file or symlink ** (if symlinks are allowed). ** Return false for directories, devices, fifos, etc. */ int file_isfile_or_link(const char *zFilename){ #if !defined(_WIN32) if ( g.allowSymlinks ){ return getStat(zFilename) ? 0 : S_ISREG(fileStat.st_mode) || S_ISLNK(fileStat.st_mode); }else{ return getStat(zFilename) ? 0 : S_ISREG(fileStat.st_mode); } #else return getStat(zFilename) ? 0 : S_ISREG(fileStat.st_mode); #endif } /* ** Return TRUE if the named file is an ordinary file. Return false |
︙ | |||
116 117 118 119 120 121 122 | 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | + + + + - + + + + + | char *zFN = mprintf("%s", zFilename); file_simplify_name(zFN, -1); rc = getStat(zFN); free(zFN); }else{ rc = getStat(0); } #if !defined(_WIN32) if( g.allowSymlinks ){ return rc ? 0 : (S_ISDIR(fileStat.st_mode) && !S_ISLNK(fileStat.st_mode) ? 1 : 2); }else{ |
︙ | |||
156 157 158 159 160 161 162 | 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | - + | /* ** Set or clear the execute bit on a file. */ void file_setexe(const char *zFilename, int onoff){ #if !defined(_WIN32) struct stat buf; |
︙ | |||
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 | 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | + + | printf("[%s] -> [%s]\n", zName, blob_buffer(&x)); blob_reset(&x); sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_size(zName)); printf(" file_size = %s\n", zBuf); sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_mtime(zName)); printf(" file_mtime = %s\n", zBuf); printf(" file_isfile = %d\n", file_isfile(zName)); printf(" file_islink = %d\n", file_islink(zName)); printf(" file_isexe = %d\n", file_isexe(zName)); printf(" file_isdir = %d\n", file_isdir(zName)); printf(" file_isfile_or_link = %d\n", file_isfile_or_link(zName)); } } /* ** Return TRUE if the given filename is canonical. ** ** Canonical names are full pathnames using "/" not "\" and which |
︙ | |||
630 631 632 633 634 635 636 | 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 | + + + - + + | i64 iSize; int rc; Blob onDisk; iSize = file_size(zName); if( iSize<0 ) return 0; if( iSize!=blob_size(pContent) ) return 0; if( file_islink(zName) ){ blob_read_link(&onDisk, zName); }else{ |
Changes to src/finfo.c.
︙ | |||
98 99 100 101 102 103 104 | 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | - + | }else if( find_option("print","p",0) ){ Blob record; Blob fname; const char *zRevision = find_option("revision", "r", 1); file_tree_name(g.argv[2], &fname, 1); if( zRevision ){ |
︙ |
Changes to src/import.c.
︙ | |||
28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | + | */ struct ImportFile { char *zName; /* Name of a file */ char *zUuid; /* UUID of the file */ char *zPrior; /* Prior name if the name was changed */ char isFrom; /* True if obtained from the parent */ char isExe; /* True if executable */ char isLink; /* True if symlink */ }; #endif /* ** State information about an on-going fast-import parse. */ |
︙ | |||
56 57 58 59 60 61 62 63 64 65 66 67 68 69 | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | + | int nMerge; /* Number of merge values */ int nMergeAlloc; /* Number of slots in azMerge[] */ char **azMerge; /* Merge values */ int nFile; /* Number of aFile values */ int nFileAlloc; /* Number of slots in aFile[] */ ImportFile *aFile; /* Information about files in a commit */ int fromLoaded; /* True zFrom content loaded into aFile[] */ int hasLinks; /* True if git repository contains symlinks */ } gg; /* ** Duplicate a string. */ char *fossil_strdup(const char *zOrig){ char *z = 0; |
︙ | |||
227 228 229 230 231 232 233 234 235 236 237 238 239 240 | 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | + + + | blob_appendf(&record, "D %s\n", gg.zDate); for(i=0; i<gg.nFile; i++){ const char *zUuid = gg.aFile[i].zUuid; if( zUuid==0 ) continue; blob_appendf(&record, "F %F %s", gg.aFile[i].zName, zUuid); if( gg.aFile[i].isExe ){ blob_append(&record, " x\n", 3); }else if( gg.aFile[i].isLink ){ blob_append(&record, " l\n", 3); gg.hasLinks = 1; }else{ blob_append(&record, "\n", 1); } } if( gg.zFrom ){ blob_appendf(&record, "P %s", gg.zFrom); for(i=0; i<gg.nMerge; i++){ |
︙ | |||
369 370 371 372 373 374 375 376 377 378 379 380 381 382 | 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | + | p = manifest_get(rid, CFTYPE_MANIFEST); if( p==0 ) return; manifest_file_rewind(p); while( (pOld = manifest_file_next(p, 0))!=0 ){ pNew = import_add_file(); pNew->zName = fossil_strdup(pOld->zName); pNew->isExe = pOld->zPerm && strstr(pOld->zPerm, "x")!=0; pNew->isLink = pOld->zPerm && strstr(pOld->zPerm, "l")!=0; pNew->zUuid = fossil_strdup(pOld->zUuid); pNew->isFrom = 1; } manifest_destroy(p); } /* |
︙ | |||
524 525 526 527 528 529 530 531 532 533 534 535 536 537 | 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | + | i = 0; pFile = import_find_file(zName, &i, gg.nFile); if( pFile==0 ){ pFile = import_add_file(); pFile->zName = fossil_strdup(zName); } pFile->isExe = (fossil_strcmp(zPerm, "100755")==0); pFile->isLink = (fossil_strcmp(zPerm, "120000")==0); fossil_free(pFile->zUuid); pFile->zUuid = resolve_committish(zUuid); pFile->isFrom = 0; }else if( memcmp(zLine, "D ", 2)==0 ){ import_prior_files(); z = &zLine[2]; |
︙ | |||
561 562 563 564 565 566 567 568 569 570 571 572 573 574 | 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 | + | pFile = &gg.aFile[i-1]; if( strlen(pFile->zName)>nFrom ){ pNew->zName = mprintf("%s%s", zTo, pFile->zName[nFrom]); }else{ pNew->zName = fossil_strdup(pFile->zName); } pNew->isExe = pFile->isExe; pNew->isLink = pFile->isLink; pNew->zUuid = fossil_strdup(pFile->zUuid); pNew->isFrom = 0; } }else if( memcmp(zLine, "R ", 2)==0 ){ int nFrom; import_prior_files(); |
︙ | |||
584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 | 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 | + + + + | if( strlen(pFile->zName)>nFrom ){ pNew->zName = mprintf("%s%s", zTo, pFile->zName[nFrom]); }else{ pNew->zName = fossil_strdup(pFile->zName); } pNew->zPrior = pFile->zName; pNew->isExe = pFile->isExe; pNew->isLink = pFile->isLink; pNew->zUuid = pFile->zUuid; pNew->isFrom = 0; gg.nFile--; *pFile = *pNew; memset(pNew, 0, sizeof(*pNew)); } fossil_fatal("cannot handle R records, use --full-tree"); }else if( memcmp(zLine, "deleteall", 9)==0 ){ gg.fromLoaded = 1; }else if( memcmp(zLine, "N ", 2)==0 ){ /* No-op */ }else { goto malformed_line; } } gg.xFinish(); if( gg.hasLinks ){ db_set_int("allow-symlinks", 1, 0); } import_reset(1); return; malformed_line: trim_newline(zLine); fossil_fatal("bad fast-import line: [%s]", zLine); return; |
︙ |
Changes to src/main.c.
︙ | |||
148 149 150 151 152 153 154 155 156 157 158 159 160 161 | 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | + + | /* Storage for the aux() and/or option() SQL function arguments */ int nAux; /* Number of distinct aux() or option() values */ const char *azAuxName[MX_AUX]; /* Name of each aux() or option() value */ char *azAuxParam[MX_AUX]; /* Param of each aux() or option() value */ const char *azAuxVal[MX_AUX]; /* Value of each aux() or option() value */ const char **azAuxOpt[MX_AUX]; /* Options of each option() value */ int anAuxCols[MX_AUX]; /* Number of columns for option() values */ int allowSymlinks; /* Cached "allow-symlinks" option */ }; /* ** Macro for debugging: */ #define CGIDEBUG(X) if( g.fDebug ) cgi_debug X |
︙ |
Changes to src/merge.c.
︙ | |||
157 158 159 160 161 162 163 | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | - + + + | " idp INTEGER," /* VFILE entry for the pivot */ " idm INTEGER," /* VFILE entry for version merging in */ " chnged BOOLEAN," /* True if current version has been edited */ " ridv INTEGER," /* Record ID for current version */ " ridp INTEGER," /* Record ID for pivot */ " ridm INTEGER," /* Record ID for merge */ " fnp TEXT," /* The filename in the pivot */ |
︙ | |||
301 302 303 304 305 306 307 308 309 310 311 312 313 314 | 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | + + + + + + + + + + + | if( !nochangeFlag ){ undo_save(zName); vfile_to_disk(0, idm, 0, 0); } } db_finalize(&q); /* ** Add islink information for files in V and M ** */ db_multi_exec( "UPDATE fv SET" " islinkv=coalesce((SELECT islink FROM vfile WHERE vid=%d AND pathname=fnm),0)," " islinkm=coalesce((SELECT islink FROM vfile WHERE vid=%d AND pathname=fnm),0)", vid, mid ); /* ** Find files that have changed from P->M but not P->V. ** Copy the M content over into V. */ db_prepare(&q, "SELECT idv, ridm, fn FROM fv" " WHERE idp>0 AND idv>0 AND idm>0" |
︙ | |||
330 331 332 333 334 335 336 | 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | } db_finalize(&q); /* ** Do a three-way merge on files that have changes on both P->M and P->V. */ db_prepare(&q, |
︙ |
Changes to src/schema.c.
︙ | |||
427 428 429 430 431 432 433 434 435 436 437 438 439 440 | 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 | + | @ -- @ CREATE TABLE vfile( @ id INTEGER PRIMARY KEY, -- ID of the checked out file @ vid INTEGER REFERENCES blob, -- The baseline this file is part of. @ chnged INT DEFAULT 0, -- 0:unchnged 1:edited 2:m-chng 3:m-add @ deleted BOOLEAN DEFAULT 0, -- True if deleted @ isexe BOOLEAN, -- True if file should be executable @ islink BOOLEAN, -- True if file should be symlink @ rid INTEGER, -- Originally from this repository record @ mrid INTEGER, -- Based on this record due to a merge @ mtime INTEGER, -- Modification time of file on disk @ pathname TEXT, -- Full pathname relative to root @ origname TEXT, -- Original pathname. NULL if unchanged @ UNIQUE(pathname,vid) @ ); |
︙ |
Changes to src/sha1.c.
︙ | |||
263 264 265 266 267 268 269 270 271 272 273 274 275 276 | 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | + + + + + + + + + + + | ** Return the number of errors. */ int sha1sum_file(const char *zFilename, Blob *pCksum){ FILE *in; SHA1Context ctx; unsigned char zResult[20]; char zBuf[10240]; if( file_islink(zFilename) ){ /* Instead of file content, return sha1 of link destination path */ Blob destinationPath; int rc; blob_read_link(&destinationPath, zFilename); rc = sha1sum_blob(&destinationPath, pCksum); blob_reset(&destinationPath); return rc; } in = fopen(zFilename,"rb"); if( in==0 ){ return 1; } SHA1Init(&ctx); for(;;){ |
︙ |
Changes to src/stash.c.
︙ | |||
33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | + | @ ); @ CREATE TABLE IF NOT EXISTS %s.stashfile( @ stashid INTEGER REFERENCES stash, -- Stash that contains this file @ rid INTEGER, -- Baseline content in BLOB table or 0. @ isAdded BOOLEAN, -- True if this is an added file @ isRemoved BOOLEAN, -- True if this file is deleted @ isExec BOOLEAN, -- True if file is executable @ isLink BOOLEAN, -- True if file is a symlink @ origname TEXT, -- Original filename @ newname TEXT, -- New name for file at next check-in @ delta BLOB, -- Delta from baseline. Content if rid=0 @ PRIMARY KEY(origname, stashid) @ ); @ INSERT OR IGNORE INTO vvar(name, value) VALUES('stash-next', 1); ; |
︙ | |||
59 60 61 62 63 64 65 | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | - + - + - + + - - - + + + + + + + + + - + + + + + + - + + + | Stmt ins; /* Insert statement */ zFile = mprintf("%/", zFName); file_tree_name(zFile, &fname, 1); zTreename = blob_str(&fname); blob_zero(&sql); blob_appendf(&sql, |
︙ | |||
166 167 168 169 170 171 172 | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | - + + - - + + + + + + - + + - - + + + + + + + + + + + + + + + - - + + + + - - + + - + + - - + + + + + - + + + + + + - - - + + + + + + + + + + - - - - + + + + | /* ** Apply a stash to the current check-out. */ static void stash_apply(int stashid, int nConflict){ Stmt q; db_prepare(&q, |
︙ | |||
345 346 347 348 349 350 351 | 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | - + | ** fossil stash drop ?STASHID? ?--all? ** ** Forget everything about STASHID. Forget the whole stash if the ** --all flag is used. Individual drops are undoable but --all is not. ** ** fossil stash snapshot ?-m COMMENT? ?FILES...? ** |
︙ |
Changes to src/undo.c.
︙ | |||
28 29 30 31 32 33 34 | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | - + + + + + + - + + + + + + + + - + + - + - + | ** true the redo a change. If there is nothing to undo (or redo) then ** this routine is a noop. */ static void undo_one(const char *zPathname, int redoFlag){ Stmt q; char *zFullname; db_prepare(&q, |
︙ | |||
198 199 200 201 202 203 204 205 206 207 208 209 210 211 | 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | + | int cid; const char *zDb = db_name("localdb"); static const char zSql[] = @ CREATE TABLE %s.undo( @ pathname TEXT UNIQUE, -- Name of the file @ redoflag BOOLEAN, -- 0 for undoable. 1 for redoable @ existsflag BOOLEAN, -- True if the file exists @ islink BOOLEAN, -- True if the file is symlink @ content BLOB -- Saved content @ ); @ CREATE TABLE %s.undo_vfile AS SELECT * FROM vfile; @ CREATE TABLE %s.undo_vmerge AS SELECT * FROM vmerge; ; if( undoDisable ) return; undo_reset(); |
︙ | |||
238 239 240 241 242 243 244 245 246 247 248 249 250 | 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | + + - - - + + + + + + - + + | ** will be undoable. The name is relative to the root of the ** tree. */ void undo_save(const char *zPathname){ char *zFullname; Blob content; int existsFlag; int isLink; Stmt q; if( !undoActive ) return; zFullname = mprintf("%s%s", g.zLocalRoot, zPathname); existsFlag = file_size(zFullname)>=0; isLink = file_islink(zFullname); db_prepare(&q, |
︙ |
Changes to src/update.c.
︙ | |||
193 194 195 196 197 198 199 200 201 202 203 204 205 206 | 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | + + | db_multi_exec( "DROP TABLE IF EXISTS fv;" "CREATE TEMP TABLE fv(" " fn TEXT PRIMARY KEY," /* The filename relative to root */ " idv INTEGER," /* VFILE entry for current version */ " idt INTEGER," /* VFILE entry for target version */ " chnged BOOLEAN," /* True if current version has been edited */ " islinkv BOOLEAN," /* True if current file is a link */ " islinkt BOOLEAN," /* True if target file is a link */ " ridv INTEGER," /* Record ID for current version */ " ridt INTEGER," /* Record ID for target */ " fnt TEXT" /* Filename of same file on target version */ ");" ); /* Add files found in the current version |
︙ | |||
243 244 245 246 247 248 249 250 251 252 | 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | + + + + + + + + + + + - + - + - + + + | */ db_multi_exec( "UPDATE fv SET" " idt=coalesce((SELECT id FROM vfile WHERE vid=%d AND pathname=fnt),0)," " ridt=coalesce((SELECT rid FROM vfile WHERE vid=%d AND pathname=fnt),0)", tid, tid ); /* ** Add islink information */ db_multi_exec( "UPDATE fv SET" " islinkv=coalesce((SELECT islink FROM vfile WHERE vid=%d AND pathname=fnt),0)," " islinkt=coalesce((SELECT islink FROM vfile WHERE vid=%d AND pathname=fnt),0)", vid, tid ); if( debugFlag ){ db_prepare(&q, |
︙ | |||
297 298 299 300 301 302 303 | 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | - + + + | } /* ** Alter the content of the checkout so that it conforms with the ** target */ db_prepare(&q, |
︙ | |||
367 368 369 370 371 372 373 | 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + | Blob e, r, t, v; int rc; if( nameChng ){ printf("MERGE %s -> %s\n", zName, zNewName); }else{ printf("MERGE %s\n", zName); } if( islinkv || islinkt /* || file_islink(zFullPath) */ ){ //if( !nochangeFlag ) blob_write_to_file(&t, zFullNewPath); printf("***** Cannot merge symlink %s\n", zNewName); nConflict++; }else{ |
︙ | |||
450 451 452 453 454 455 456 457 458 459 460 461 462 463 | 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | + | ** Get the contents of a file within the checking "revision". If ** revision==NULL then get the file content for the current checkout. */ int historical_version_of_file( const char *revision, /* The checkin containing the file */ const char *file, /* Full treename of the file */ Blob *content, /* Put the content here */ int *isLink, /* Put islink here. Pass NULL if you don't need it */ int errCode /* Error code if file not found. Panic if 0. */ ){ Manifest *pManifest; ManifestFile *pFile; int rid=0; if( revision ){ |
︙ | |||
473 474 475 476 477 478 479 480 481 482 483 484 485 486 | 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 | + + + | if( pManifest ){ manifest_file_rewind(pManifest); while( (pFile = manifest_file_next(pManifest,0))!=0 ){ if( fossil_strcmp(pFile->zName, file)==0 ){ rid = uuid_to_rid(pFile->zUuid, 0); manifest_destroy(pManifest); if( isLink!=NULL ){ *isLink = strstr(pFile->zPerm, "l") ? 1 : 0; } return content_get(rid, content); } } manifest_destroy(pManifest); if( errCode<=0 ){ fossil_fatal("file %s does not exist in checkin: %s", file, revision); } |
︙ | |||
548 549 550 551 552 553 554 555 556 | 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 | + - + + + + + + + - + + - + - + | " FROM vfile " " WHERE chnged OR deleted OR rid=0 OR pathname!=origname;" ); } blob_zero(&record); db_prepare(&q, "SELECT name FROM torevert"); while( db_step(&q)==SQLITE_ROW ){ int isLink = 0; zFile = db_column_text(&q, 0); if( zRevision!=0 ){ |
Changes to src/vfile.c.
︙ | |||
82 83 84 85 86 87 88 | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | - - + + + | ManifestFile *pFile; db_begin_transaction(); p = manifest_get(vid, CFTYPE_MANIFEST); if( p==0 ) return; db_multi_exec("DELETE FROM vfile WHERE vid=%d", vid); db_prepare(&ins, |
︙ | |||
146 147 148 149 150 151 152 | 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | - + | zName = db_column_text(&q, 1); rid = db_column_int(&q, 2); isDeleted = db_column_int(&q, 3); oldChnged = db_column_int(&q, 4); oldMtime = db_column_int64(&q, 7); if( isDeleted ){ chnged = 1; |
︙ | |||
204 205 206 207 208 209 210 | 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | - + - + - + + | int promptFlag /* Prompt user to confirm overwrites */ ){ Stmt q; Blob content; int nRepos = strlen(g.zLocalRoot); if( vid>0 && id==0 ){ |
︙ | |||
246 247 248 249 250 251 252 | 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | + + + + + + + + + + - + + | } if( cReply=='n' || cReply=='N' ){ blob_reset(&content); continue; } } if( verbose ) printf("%s\n", &zName[nRepos]); if( file_isdir(zName) == 1 ){ //TODO remove directories? fossil_fatal("%s is directory, cannot overwrite\n", zName); } if( file_size(zName)>=0 && (isLink || file_islink(zName)) ){ unlink(zName); } if( isLink ){ create_symlink(blob_str(&content), zName); }else{ |
︙ | |||
303 304 305 306 307 308 309 | 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | - + | if( pEntry->d_name[1]==0 ) continue; if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue; } blob_appendf(pPath, "/%s", pEntry->d_name); zPath = blob_str(pPath); if( file_isdir(zPath)==1 ){ vfile_scan(vid, pPath, nPrefix, allFlag); |
︙ | |||
354 355 356 357 358 359 360 | 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + | while( db_step(&q)==SQLITE_ROW ){ const char *zFullpath = db_column_text(&q, 0); const char *zName = db_column_text(&q, 1); int isSelected = db_column_int(&q, 3); if( isSelected ){ md5sum_step_text(zName, -1); if( file_islink(zFullpath) ){ /* Instead of file content, use link destination path */ Blob pathBuf; sqlite3_snprintf(sizeof(zBuf), zBuf, " %ld\n", blob_read_link(&pathBuf, zFullpath)); md5sum_step_text(zBuf, -1); md5sum_step_text(blob_str(&pathBuf), -1); blob_reset(&pathBuf); }else{ |
︙ | |||
415 416 417 418 419 420 421 | 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 | + + + - - - - - + + + + + + | md5sum_init(); while( db_step(&q)==SQLITE_ROW ){ const char *zFullpath = db_column_text(&q, 0); const char *zName = db_column_text(&q, 1); int rid = db_column_int(&q, 2); blob_zero(&disk); if( file_islink(zFullpath) ){ blob_read_link(&disk, zFullpath); }else{ |
︙ |