Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Difference From 0.10 To 0.11
2022-05-08 13:47 | Bump version number: 0.12 (check-in: d32f0aee53 user: mark tags: trunk) | |
2022-05-08 13:45 | CHANGES for 0.11 (check-in: 53c1d7eb57 user: mark tags: trunk, 0.11) | |
2022-05-08 13:43 | Remove redundant fcli_has_unused_args() call from main() (check-in: 2cf1a6ee21 user: mark tags: trunk) | |
2022-03-23 14:12 | Bump version number: 0.11 (check-in: 96169cac63 user: mark tags: trunk) | |
2022-03-23 14:07 | CHANGES for 0.10 (check-in: dc8f00b193 user: mark tags: trunk, 0.10) | |
2022-03-22 14:54 | Expand diff view C-{j,k} key maps to navigate parent blame view. (check-in: d05828fbb7 user: mark tags: trunk) | |
Changes to CHANGES.md.
|
Changes to README.md.
1 2 | 1 2 3 4 5 6 7 8 9 10 | - + | # README |
︙ | |||
49 50 51 52 53 54 55 56 57 58 59 60 61 62 | 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 | + + + + + + + + + + + + + + + + + | This will install the `fnc` executable and man page into `/usr/local/bin` and `/usr/local/share/man/man1`, respectively. Alternatively, cryptographically signed tarballs of the source code and binaries for some of the abovementioned platforms are available to [download][3]. # Doc Commands available in **fnc**: 1. [**stash**](/uv/resources/doc/fnc.1.html#stash) - interactively select hunks to stash from the diff of local changes on disk 2. [**timeline**](/uv/resources/doc/fnc.1.html#timeline) - hyperlinked chronological commit history of the repository 3. [**diff**](/uv/resources/doc/fnc.1.html#diff) - diff of all changes between commits or blobs 4. [**blame**](/uv/resources/doc/fnc.1.html#blame) - annotated file displaying commit attribution history of each line 5. [**tree**](/uv/resources/doc/fnc.1.html#tree) - navigable file hierarchy of the repository tree 6. [**branch**](/uv/resources/doc/fnc.1.html#branch) - hyperlinked list of all public and private branches 7. [**config**](/uv/resources/doc/fnc.1.html#config) - configure or view fnc settings See `fnc --help` for a quick reference, and the [fnc(1)][4] manual page for more comprehensive documentation. In-app help can also be accessed with the `?`, `F1`, or `H` key binding. The following video briefly demonstrates some of the key bindings in use. [![fnc demo][5]][6] |
︙ | |||
81 82 83 84 85 86 87 88 89 90 91 92 93 94 | 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | + + + | and complies with OpenBSD's KNF [style(9)][13]. Any patch containing user-visible code addition, modification, or deletion (i.e., code that impacts user interfaces) should concomitantly include updating documentation affected by the change. # Screenshots           |
︙ |
Changes to fnc.bld.mk.
1 2 3 4 5 6 7 8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | - + | # # FNC Common Build # # CONFIGURATION CC ?= cc PREFIX ?= /usr/local MANDIR ?= /share/man |
︙ |
Changes to include/diff.h.
︙ | |||
36 37 38 39 40 41 42 | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | - + | #define FNC_DIFF_WIDTH_MASK ((uint64_t)0x0fff0000) /* SBS column width */ }; struct diff_out_state { fsl_output_f out; /* Output callback */ void *state; /* State for this->out() */ enum line_type *lines; /* Diff line type (e.g., minus, plus) */ |
︙ | |||
94 95 96 97 98 99 100 | 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 | - + - + | int unidiff(fsl__diff_cx *, struct diff_out_state *, void *, uint16_t, uint64_t); int unidiff_lineno(struct diff_out_state *, int, int, bool); int unidiff_txt( struct diff_out_state *const, char, fsl_dline *, int, void *); int sbsdiff(fsl__diff_cx *, struct diff_out_state *, void *, uint16_t, uint64_t); |
Changes to lib/sqlite3.c.
more than 10,000 changes
Changes to lib/sqlite3.h.
︙ | |||
142 143 144 145 146 147 148 | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | - - - + + + | ** been edited in any way since it was last checked in, then the last ** four hexadecimal digits of the hash may be modified. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ |
︙ | |||
535 536 537 538 539 540 541 | 535 536 537 538 539 540 541 542 543 544 545 546 547 548 | - | #define SQLITE_BUSY_TIMEOUT (SQLITE_BUSY | (3<<8)) #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8)) #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8)) #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8)) #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8)) #define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) /* Not Used */ #define SQLITE_CANTOPEN_SYMLINK (SQLITE_CANTOPEN | (6<<8)) |
︙ | |||
563 564 565 566 567 568 569 | 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 | - + + + + + + + + + + + + + + | #define SQLITE_CONSTRAINT_PINNED (SQLITE_CONSTRAINT |(11<<8)) #define SQLITE_CONSTRAINT_DATATYPE (SQLITE_CONSTRAINT |(12<<8)) #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8)) #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8)) #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8)) #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8)) #define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8)) |
︙ | |||
593 594 595 596 597 598 599 600 601 602 603 604 605 606 | 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 | + | #define SQLITE_OPEN_SUPER_JOURNAL 0x00004000 /* VFS only */ #define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_WAL 0x00080000 /* VFS only */ #define SQLITE_OPEN_NOFOLLOW 0x01000000 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_EXRESCODE 0x02000000 /* Extended result codes */ /* Reserved: 0x00F00000 */ /* Legacy compatibility: */ #define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 /* VFS only */ /* |
︙ | |||
3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 | 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 | + + + + + + + + - - - - - - - + + + + + + + + + | ** the default shared cache setting provided by ** [sqlite3_enable_shared_cache()].)^ ** ** ^(<dt>[SQLITE_OPEN_PRIVATECACHE]</dt> ** <dd>The database is opened [shared cache] disabled, overriding ** the default shared cache setting provided by ** [sqlite3_enable_shared_cache()].)^ ** ** [[OPEN_EXRESCODE]] ^(<dt>[SQLITE_OPEN_EXRESCODE]</dt> ** <dd>The database connection comes up in "extended result code mode". ** In other words, the database behaves has if ** [sqlite3_extended_result_codes(db,1)] where called on the database ** connection as soon as the connection is created. In addition to setting ** the extended result code mode, this flag also causes [sqlite3_open_v2()] ** to return an extended result code.</dd> ** ** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt> ** <dd>The database filename is not allowed to be a symbolic link</dd> |
︙ | |||
3797 3798 3799 3800 3801 3802 3803 | 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 | - + + + + + + + + + + | ** [extended result code] even when extended result codes are ** disabled. ** ** The values returned by sqlite3_errcode() and/or ** sqlite3_extended_errcode() might change with each API call. ** Except, there are some interfaces that are guaranteed to never ** change the value of the error code. The error-code preserving |
︙ | |||
4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 | 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 | + + + + | ** statement might change the database file. ^A false return does ** not guarantee that the statement will change the database file. ** ^For example, an UPDATE statement might have a WHERE clause that ** makes it a no-op, but the sqlite3_stmt_readonly() result would still ** be false. ^Similarly, a CREATE TABLE IF NOT EXISTS statement is a ** read-only no-op if the table already exists, but ** sqlite3_stmt_readonly() still returns false for such a statement. ** ** ^If prepared statement X is an [EXPLAIN] or [EXPLAIN QUERY PLAN] ** statement, then sqlite3_stmt_readonly(X) returns the same value as ** if the EXPLAIN or EXPLAIN QUERY PLAN prefix were omitted. */ SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); /* ** CAPI3REF: Query The EXPLAIN Setting For A Prepared Statement ** METHOD: sqlite3_stmt ** |
︙ | |||
4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 | 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 | + + | ** sqlite3_value objects and they can be used interchangeably. However, ** for maximum code portability it is recommended that applications ** still make the distinction between protected and unprotected ** sqlite3_value objects even when not strictly required. ** ** ^The sqlite3_value objects that are passed as parameters into the ** implementation of [application-defined SQL functions] are protected. ** ^The sqlite3_value objects returned by [sqlite3_vtab_rhs_value()] ** are protected. ** ^The sqlite3_value object returned by ** [sqlite3_column_value()] is unprotected. ** Unprotected sqlite3_value objects may only be used as arguments ** to [sqlite3_result_value()], [sqlite3_bind_value()], and ** [sqlite3_value_dup()]. ** The [sqlite3_value_blob | sqlite3_value_type()] family of ** interfaces require protected sqlite3_value objects. |
︙ | |||
4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 | 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 | + + + + - + | ** of the string. ^For clarity: the values returned by ** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of ** bytes in the string, not the number of characters. ** ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(), ** even empty strings, are always zero-terminated. ^The return ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer. ** ** ^Strings returned by sqlite3_column_text16() always have the endianness ** which is native to the platform, regardless of the text encoding set ** for the database. ** ** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an ** [unprotected sqlite3_value] object. In a multithreaded environment, ** an unprotected sqlite3_value object may only be used safely with ** [sqlite3_bind_value()] and [sqlite3_result_value()]. ** If the [unprotected sqlite3_value] object returned by ** [sqlite3_column_value()] is used in any other way, including calls ** to routines like [sqlite3_value_int()], [sqlite3_value_text()], ** or [sqlite3_value_bytes()], the behavior is not threadsafe. ** Hence, the sqlite3_column_value() interface ** is normally only useful within the implementation of ** [application-defined SQL functions] or [virtual tables], not within ** top-level application code. ** |
︙ | |||
4975 4976 4977 4978 4979 4980 4981 | 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 | - + | ** <tr><td> FLOAT <td> TEXT <td> ASCII rendering of the float ** <tr><td> FLOAT <td> BLOB <td> [CAST] to BLOB ** <tr><td> TEXT <td> INTEGER <td> [CAST] to INTEGER ** <tr><td> TEXT <td> FLOAT <td> [CAST] to REAL ** <tr><td> TEXT <td> BLOB <td> No change ** <tr><td> BLOB <td> INTEGER <td> [CAST] to INTEGER ** <tr><td> BLOB <td> FLOAT <td> [CAST] to REAL |
︙ | |||
6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 | 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | ** ^The rollback callback is not invoked if a transaction is ** automatically rolled back because the database connection is closed. ** ** See also the [sqlite3_update_hook()] interface. */ SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*); SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); /* ** CAPI3REF: Autovacuum Compaction Amount Callback ** METHOD: sqlite3 ** ** ^The sqlite3_autovacuum_pages(D,C,P,X) interface registers a callback ** function C that is invoked prior to each autovacuum of the database ** file. ^The callback is passed a copy of the generic data pointer (P), ** the schema-name of the attached database that is being autovacuumed, ** the the size of the database file in pages, the number of free pages, ** and the number of bytes per page, respectively. The callback should ** return the number of free pages that should be removed by the ** autovacuum. ^If the callback returns zero, then no autovacuum happens. ** ^If the value returned is greater than or equal to the number of ** free pages, then a complete autovacuum happens. ** ** <p>^If there are multiple ATTACH-ed database files that are being ** modified as part of a transaction commit, then the autovacuum pages ** callback is invoked separately for each file. ** ** <p><b>The callback is not reentrant.</b> The callback function should ** not attempt to invoke any other SQLite interface. If it does, bad ** things may happen, including segmentation faults and corrupt database ** files. The callback function should be a simple function that ** does some arithmetic on its input parameters and returns a result. ** ** ^The X parameter to sqlite3_autovacuum_pages(D,C,P,X) is an optional ** destructor for the P parameter. ^If X is not NULL, then X(P) is ** invoked whenever the database connection closes or when the callback ** is overwritten by another invocation of sqlite3_autovacuum_pages(). ** ** <p>^There is only one autovacuum pages callback per database connection. ** ^Each call to the sqlite3_autovacuum_pages() interface overrides all ** previous invocations for that database connection. ^If the callback ** argument (C) to sqlite3_autovacuum_pages(D,C,P,X) is a NULL pointer, ** then the autovacuum steps callback is cancelled. The return value ** from sqlite3_autovacuum_pages() is normally SQLITE_OK, but might ** be some other error code if something goes wrong. The current ** implementation will only return SQLITE_OK or SQLITE_MISUSE, but other ** return codes might be added in future releases. ** ** <p>If no autovacuum pages callback is specified (the usual case) or ** a NULL pointer is provided for the callback, ** then the default behavior is to vacuum all free pages. So, in other ** words, the default behavior is the same as if the callback function ** were something like this: ** ** <blockquote><pre> ** unsigned int demonstration_autovac_pages_callback( ** void *pClientData, ** const char *zSchema, ** unsigned int nDbPage, ** unsigned int nFreePage, ** unsigned int nBytePerPage ** ){ ** return nFreePage; ** } ** </pre></blockquote> */ SQLITE_API int sqlite3_autovacuum_pages( sqlite3 *db, unsigned int(*)(void*,const char*,unsigned int,unsigned int,unsigned int), void*, void(*)(void*) ); /* ** CAPI3REF: Data Change Notification Callbacks ** METHOD: sqlite3 ** ** ^The sqlite3_update_hook() interface registers a callback function ** with the [database connection] identified by the first argument |
︙ | |||
7029 7030 7031 7032 7033 7034 7035 | 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 | - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + | #define SQLITE_INDEX_SCAN_UNIQUE 1 /* Scan visits at most 1 row */ /* ** CAPI3REF: Virtual Table Constraint Operator Codes ** ** These macros define the allowed values for the ** [sqlite3_index_info].aConstraint[].op field. Each value represents |
︙ | |||
7075 7076 7077 7078 7079 7080 7081 | 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 | - + | ** no longer needs the pClientData pointer. ^The destructor will also ** be invoked if the call to sqlite3_create_module_v2() fails. ** ^The sqlite3_create_module() ** interface is equivalent to sqlite3_create_module_v2() with a NULL ** destructor. ** ** ^If the third parameter (the pointer to the sqlite3_module object) is |
︙ | |||
7851 7852 7853 7854 7855 7856 7857 | 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 | + - + | #define SQLITE_TESTCTRL_PARSER_COVERAGE 26 #define SQLITE_TESTCTRL_RESULT_INTREAL 27 #define SQLITE_TESTCTRL_PRNG_SEED 28 #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29 #define SQLITE_TESTCTRL_SEEK_COUNT 30 #define SQLITE_TESTCTRL_TRACEFLAGS 31 #define SQLITE_TESTCTRL_TUNE 32 #define SQLITE_TESTCTRL_LOGEST 33 |
︙ | |||
8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 | 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 | + + + + + + + + + + + + | ** ** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt> ** <dd>^This is the number of times that the prepared statement has ** been run. A single "run" for the purposes of this counter is one ** or more calls to [sqlite3_step()] followed by a call to [sqlite3_reset()]. ** The counter is incremented on the first [sqlite3_step()] call of each ** cycle. ** ** [[SQLITE_STMTSTATUS_FILTER_MISS]] ** [[SQLITE_STMTSTATUS_FILTER HIT]] ** <dt>SQLITE_STMTSTATUS_FILTER_HIT<br> ** SQLITE_STMTSTATUS_FILTER_MISS</dt> ** <dd>^SQLITE_STMTSTATUS_FILTER_HIT is the number of times that a join ** step was bypassed because a Bloom filter returned not-found. The ** corresponding SQLITE_STMTSTATUS_FILTER_MISS value is the number of ** times that the Bloom filter returned a find, and thus the join step ** had to be processed as normal. ** ** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt> ** <dd>^This is the approximate number of bytes of heap memory ** used to store the prepared statement. ^This value is not actually ** a counter, and so the resetFlg parameter to sqlite3_stmt_status() ** is ignored when the opcode is SQLITE_STMTSTATUS_MEMUSED. ** </dd> ** </dl> */ #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 #define SQLITE_STMTSTATUS_SORT 2 #define SQLITE_STMTSTATUS_AUTOINDEX 3 #define SQLITE_STMTSTATUS_VM_STEP 4 #define SQLITE_STMTSTATUS_REPREPARE 5 #define SQLITE_STMTSTATUS_RUN 6 #define SQLITE_STMTSTATUS_FILTER_MISS 7 #define SQLITE_STMTSTATUS_FILTER_HIT 8 #define SQLITE_STMTSTATUS_MEMUSED 99 /* ** CAPI3REF: Custom Page Cache Object ** ** The sqlite3_pcache type is opaque. It is implemented by ** the pluggable module. The SQLite core has no knowledge of |
︙ | |||
9356 9357 9358 9359 9360 9361 9362 9363 9364 | 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 | + - + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | ** current implementation, the sqlite3_vtab_nochange() interface does always ** returns false for the enhanced [UPDATE FROM] statement. */ SQLITE_API int sqlite3_vtab_nochange(sqlite3_context*); /* ** CAPI3REF: Determine The Collation For a Virtual Table Constraint ** METHOD: sqlite3_index_info ** ** This function may only be called from within a call to the [xBestIndex] |
︙ |
Changes to lib/sqlite3ext.h.
︙ | |||
333 334 335 336 337 338 339 340 341 342 343 344 345 346 | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | + + + + + + + + + + + + + + | /* Version 3.32.0 and later */ char *(*create_filename)(const char*,const char*,const char*, int,const char**); void (*free_filename)(char*); sqlite3_file *(*database_file_object)(const char*); /* Version 3.34.0 and later */ int (*txn_state)(sqlite3*,const char*); /* Version 3.36.1 and later */ sqlite3_int64 (*changes64)(sqlite3*); sqlite3_int64 (*total_changes64)(sqlite3*); /* Version 3.37.0 and later */ int (*autovacuum_pages)(sqlite3*, unsigned int(*)(void*,const char*,unsigned int,unsigned int,unsigned int), void*, void(*)(void*)); /* Version 3.38.0 and later */ int (*error_offset)(sqlite3*); int (*vtab_rhs_value)(sqlite3_index_info*,int,sqlite3_value**); int (*vtab_distinct)(sqlite3_index_info*); int (*vtab_in)(sqlite3_index_info*,int,int); int (*vtab_in_first)(sqlite3_value*,sqlite3_value**); int (*vtab_in_next)(sqlite3_value*,sqlite3_value**); }; /* ** This is the function signature used for all extension entry points. It ** is also defined in the file "loadext.c". */ typedef int (*sqlite3_loadext_entry)( |
︙ | |||
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 668 669 670 671 672 673 674 675 676 677 678 | + + + + + + + + + + + + | #define sqlite3_filename_wal sqlite3_api->filename_wal /* Version 3.32.0 and later */ #define sqlite3_create_filename sqlite3_api->create_filename #define sqlite3_free_filename sqlite3_api->free_filename #define sqlite3_database_file_object sqlite3_api->database_file_object /* Version 3.34.0 and later */ #define sqlite3_txn_state sqlite3_api->txn_state /* Version 3.36.1 and later */ #define sqlite3_changes64 sqlite3_api->changes64 #define sqlite3_total_changes64 sqlite3_api->total_changes64 /* Version 3.37.0 and later */ #define sqlite3_autovacuum_pages sqlite3_api->autovacuum_pages /* Version 3.38.0 and later */ #define sqlite3_error_offset sqlite3_api->error_offset #define sqlite3_vtab_rhs_value sqlite3_api->vtab_rhs_value #define sqlite3_vtab_distinct sqlite3_api->vtab_distinct #define sqlite3_vtab_in sqlite3_api->vtab_in #define sqlite3_vtab_in_first sqlite3_api->vtab_in_first #define sqlite3_vtab_in_next sqlite3_api->vtab_in_next #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) /* This case when the file really is being compiled as a loadable ** extension */ # define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api=0; # define SQLITE_EXTENSION_INIT2(v) sqlite3_api=v; |
︙ |
Deleted signify/fnc-09-release.pub.
| - - |
|
Added signify/fnc-11-release.pub.
|
Changes to src/diff.c.
︙ | |||
190 191 192 193 194 195 196 | 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 | - - - + - - - - - + - + + + - - - - + - + - - | } } /* fsl__dump_triples(&c, __FILE__, __LINE__); */ /* DEBUG */ if (!FLAG_CHK(flags, FNC_DIFF_NOOPT)) fsl__diff_optimize(&c); /* fsl__dump_triples(&c, __FILE__, __LINE__); */ /* DEBUG */ |
︙ | |||
280 281 282 283 284 285 286 | 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | - | start += c->aEdit[j]; /* Chunk start line */ endl = endr = start; endl += MAX(c->aEdit[j + 1], 0); /* End of left side chunk */ endr += MAX(c->aEdit[j + 2], 0); /* End of right side chunk */ s = MAX(start - ctxt, 0); /* Include leading ctxt */ e = MIN(endl + ctxt, c->nFrom); /* L include trailing ctxt */ e2 = MIN(endr + ctxt, c->nTo); /* R include trailing ctxt */ |
︙ | |||
312 313 314 315 316 317 318 | 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 328 | - - - - + - + | /* Account for insertions before adding lines to next chunk. */ start += c->aEdit[j + 2]; } while ((j += 3) < k - 3); *flags |= ((int)(sbswidth & 0xFFF)) << 16; /* Encode max width */ |
︙ | |||
588 589 590 591 592 593 594 | 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 | - + | ++idx; break; } } ++idx; } |
︙ | |||
682 683 684 685 686 687 688 | 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 | - - - - - - - - - - - + + + + + + + + + + + - - - + + + | { fsl_dline *l, *r; /* Left and right side of diff */ fsl_buffer sbscols[5] = { fsl_buffer_empty_m, fsl_buffer_empty_m, fsl_buffer_empty_m, fsl_buffer_empty_m, fsl_buffer_empty_m }; |
︙ | |||
789 790 791 792 793 794 795 | 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 | - + + + | for (i = 1; i < nc; ++i) { nleft += c[ci + i * 3]; nright += c[ci + i * 3]; } /* Draw separator between blocks except the first. */ if (showsep) { |
︙ | |||
828 829 830 831 832 833 834 | 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 | + + - + - - + - + - | chunks); /* Show the initial common area */ li += skip; ri += skip; ntotal = c[ci] - skip; for (j = 0; !rc && j < ntotal; j++) { rc = add_line_type(lines, nlines, LINE_DIFF_CONTEXT); if (!rc) |
︙ | |||
871 872 873 874 875 876 877 | 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 | - + - + + + | alignment = sbsdiff_align(&l[li], nleft, &r[ri], nright); if (!alignment) { rc = FSL_RC_OOM; goto end; } |
︙ | |||
915 916 917 918 919 920 921 | 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 | - + + + | rc = sbsdiff_lineno(&s, ri, SBS_RLINE); if (rc) goto end_align; s.idx = 0; fsl_strlcat(tag, "add\">", sizeof(tag)); s.tag = tag; s.end = LENGTH(&r[ri]); |
︙ | |||
947 948 949 950 951 952 953 | 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 | - + + + | s.idx = 0; fsl_strlcat(tag, "rm\">", sizeof(tag)); s.tag = tag; s.end = LENGTH(&l[li]); rc = sbsdiff_txt(&s, &l[li], SBS_LTEXT); if (rc) goto end_align; |
︙ | |||
974 975 976 977 978 979 980 | 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 | - + - + + + - - - + + + + - - | } end_align: fsl_free(alignment); if (rc) goto end; if (i < nc - 1) { ntotal = c[ci + i * 3 + 3]; |
︙ | |||
1054 1055 1056 1057 1058 1059 1060 | 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 | - - - - - - - - - - - - + + + + + + + + + + + + + + | * context Number of context lines * flags Flags controlling the diff */ int unidiff(fsl__diff_cx *cx, struct diff_out_state *dst, void *regex, uint16_t context, uint64_t flags) { |
︙ | |||
1156 1157 1158 1159 1160 1161 1162 | 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 | - - + + + + + + | if (showln) { if (!showsep) showsep = 1; /* Don't show a top divider */ else if (html) rc = diff_outf(dst, "<span class=\"fsl-diff-hr\">%.*c</span>\n", 80, '.'); |
︙ | |||
1183 1184 1185 1186 1187 1188 1189 | 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 | - - - - + + + + + + + + + | #endif /* * If the patch changes an empty file or results in * an empty file, the block header must use 0,0 as * position indicator and not 1,0. Otherwise, patch * would be confused and may reject the diff. */ |
︙ | |||
1209 1210 1211 1212 1213 1214 1215 | 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 | + - + + + - + + + - + + + - + + - + | return rc; /* Show the initial common area */ li += skip; ri += skip; ntotal = c[ci] - skip; for (j = 0; !rc && j < ntotal; j++) { rc = add_line_type(lines, nlines, LINE_DIFF_CONTEXT); |
︙ | |||
1583 1584 1585 1586 1587 1588 1589 | 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 | - - + + | * Insertion and deletion costs are 50. Match costs are between 0 and 100 where * 0 is a perfect match 100 is a complete mismatch. * left lines of text on the left * nleft number of lines on the left * right lines of text on the right * nright number of lines on the right */ |
︙ | |||
1732 1733 1734 1735 1736 1737 1738 | 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 | - - - - - - - + + + + + + + | * right Right line of the change * rlnno Line number of the right line */ int sbsdiff_write_change(struct sbsline *dst, fsl_dline *left, int llnno, fsl_dline *right, int rlnno) { |
︙ | |||
1790 1791 1792 1793 1794 1795 1796 | 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 | + + - + - + + - + - - + + | rc = sbsdiff_lineno(dst, llnno, SBS_LLINE); if (rc) return rc; dst->idx2 = dst->end2 = 0; dst->idx = dst->end = -1; rc = sbsdiff_txt(dst, left, SBS_LTEXT); if (!rc && leftsz == rightsz && ltxt[leftsz] == rtxt[rightsz]) { rc = add_line_type(lines, nlines, LINE_DIFF_CONTEXT); if (!rc) |
︙ | |||
1858 1859 1860 1861 1862 1863 1864 | 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 | - + + | dst->tag = tag_rm; } else dst->tag = tag_chg; dst->idx2 = npfx + lcs[1]; dst->end2 = leftsz - nsfx; dst->tag2 = lcs[3] == nright ? tag_rm : tag_chg; sbsdiff_simplify_line(dst, ltxt + npfx); |
︙ | |||
1884 1885 1886 1887 1888 1889 1890 | 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 | - + | rc = sbsdiff_txt(dst, right, SBS_RTEXT); return rc; } /* If all else fails, show a single big change between left and right */ rc = sbsdiff_lineno(dst, llnno, SBS_LLINE); if (!rc) { |
︙ | |||
2008 2009 2010 2011 2012 2013 2014 | 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 | + + + + + + + + + + + + + + + + | rc = diff_out(dst, ANSI_RESET, -1); if (!rc) rc = diff_out(dst, "\n", 1); } return rc; } int add_line_type(enum line_type **lines, uint32_t *nlines, enum line_type type) { enum line_type *p; p = fsl_realloc(*lines, (*nlines + 1) * sizeof(enum line_type)); if (p == NULL) return FSL_RC_ERROR; *lines = p; (*lines)[*nlines] = type; (*nlines)++; return FSL_RC_OK; } |
Changes to src/fnc.1.
︙ | |||
22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | + + + + + + + + + | .Sh SYNOPSIS .Nm .Op Ar command .Op Fl h | -help .Nm .Op Fl h | -help .Op Fl v | -version .Nm .Cm stash .Sm off .Oo .Cm get | pop .Li | .Fl ChPx .Sm on .Oc .Nm .Cm config .Op Fl hu .Op Fl -ls .Op Fl R Ar path .Op Ar setting Op Ar value .Nm |
︙ | |||
71 72 73 74 75 76 77 | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | - + | .Op Fl R Ar path .Op Fl s Ar order .Op Ar glob .Nm .Op Ar path .Sh DESCRIPTION .Nm |
︙ | |||
195 196 197 198 199 200 201 202 203 204 205 206 207 208 | 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 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | for the current .Cm fnc config invocation. .It Fl u , -unset Clear the specified .Ar setting. .El .Tg stash .It Cm stash Oo Cm get Ns | Ns Cm pop Ns | Ns Oo Fl C | -no-colour Oc \ Oo Fl h | -help Oc Oo Fl P | -no-prototype Oc Oo Fl x | -context Ar n Oc Oc .Dl Pq aliases: Cm snapshot , Cm snap , Cm save , Cm sta When run with neither the .Cm get nor .Cm pop subcommands, .Nm .Cm stash will present an interactive view of the local changes on disk and iterate each hunk in the diff, prompting the user to either stash or keep the current change in the checkout. Valid answers are as follows: .Bl -column -offset 2s YXZ description .Sy b Ta scroll back Ns \(ha .Sy m Ta show more of the current hunk Ns \(ha .Sy y Ta yes, stash the current hunk .Sy n Ta no, do not stash the current hunk .Sy a Ta yes, stash this hunk and all remaining hunks in the file .Sy k Ta no, do not stash this hunk nor any remaining hunks in the file .Sy A Ta yes, stash this hunk and all remaining hunks in the diff .Sy K Ta no, do not stash this hunk nor any remaining hunks in the diff .Sy ? Ta display help dialog .El .Pp \(haConditionally available when the current hunk occupies the previous and/or following page. .Pp When all hunks have been selected, .Nm will prompt the user to enter a stash message. If not provided, a default message of .Qo fnc stash HASH-PREFIX .Qc , where .Qq HASH-PREFIX is an abbreviated SHA UUID hash of the current checkout, will be used. At any time prior to the final hunk being selected .Po i.e., before the stash message prompt .Pc , the operation can be aborted by opening the help dialog and entering .Qq Q , which will discard all selections and leave the checkout state unchanged. .Pp Available subcommands for .Nm .Cm stash are as follows: .Bl -ohang -width Ds .It Cm get .Dl Pq aliases: Cm apply Retrieve the most recent stash entry and apply it to the current checkout. .It Cm pop Remove the most recent stash entry and apply it to the current checkout. .El .Pp Options only apply to .Nm .Cm stash .Po i.e., neither the .Cm get nor .Cm pop subcommands .Pc and are as follows: .Bl -tag -width Ds .It Fl C , -no-colour Disable coloured output, which is enabled by default on supported terminals. .It Fl h , -help Display .Cm stash command help and usage information then exit. .It Fl P , -no-prototype Disable hunk header display of which function or scope each change is in, which is enabled by default. The heuristic will produce reliable results for all C-like languages .Pq e.g., C/C++, Java, Python, JavaScript, Rust ; however, Lisps and non-source code .Pq e.g., Markdown, reStructuredText will return meaningless results. .It Fl x , -context Ar n Set .Ar n context lines to be shown in the interactive stash diff display such that 0 \*(Le n \*(Le 64. By default, 5 context lines are shown. Illegal values are a no-op. .El .Pp .Tg log .It Cm timeline Oo Fl C | -no-colour Oc Oo Fl T | -tag Ar tag Oc \ Oo Fl b | -branch Ar branch Oc Oo Fl c | -commit Ar commit Oc \ Oo Fl f | -filter Ar glob Oc Oo Fl h | -help Oc Oo Fl n | -limit Ar n Oc \ Oo Fl R | -repo Ar path Oc Oo Fl t | -type Ar type Oc \ Oo Fl u | -username Ar user Oc Oo Fl z | -utc Oc \ Op Ar path |
︙ | |||
352 353 354 355 356 357 358 359 360 361 362 363 364 365 | 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | + + + + + + + + + + + | .Cm fnc timeline are as follows: .Bl -tag -width Ds .It Cm Arrow-down, j, >, \&. Move selection cursor down the timeline. .It Cm Arrow-up, k, <, \&, Move selection cursor up the timeline. .It Cm Arrow-right, l Scroll the view two columns to the right in the buffer. The comment field moves left on the screen. .It Cm Arrow-left, h Scroll the view two columns to the left in the buffer. The comment field moves right on the screen. .It Cm $ Scroll the view right to the end of the longest comment summary line on the page. .It Cm 0 Scroll the view left to the beginning of the line. .It Cm C-f, Page-down Scroll timeline view one page downwards in the buffer. .It Cm C-b, Page-up Scroll timeline view one page upwards in the buffer. .It Cm C-d Scroll timeline view half a page downwards in the buffer. .It Cm C-u |
︙ | |||
1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 | 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 | + + + + + + + + + + + + + + + | value is .Qq yellow . .El .Pp To clear environment variables, issue .Cm unset Ar ENVIRONMENT_VARIABLE in the shell. .Pp .Nm displays best with UTF-8, and will detect whether UTF-8 is enabled to determine which characters to draw in certain views. If UTF-8 is supported by your terminal but is currently disabled, it can be enabled with .Qq export LC_ALL=en_US.UTF-8 ; If not available, .Nm will revert to ASCII. Relatedly, some fonts may render certain characters poorly in the help screen; .Li Monospace Regular , .Li JetBrains Mono , and .Li Menlo are known to render all characters well. .Sh EXIT STATUS .Ex -std fnc .Sh SEE ALSO .Xr fossil 1 , .Xr re_format 7 .Xr sqlite3 1 .Sh AUTHOR .An Mark Jamsek Aq Mt mark@jamsek.com |
Changes to src/fnc.c.
︙ | |||
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | 17 18 19 20 21 22 23 24 25 26 27 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 | + + + - + + + | /* * _POSIX_C_SOURCE >= 199309L needed for sigaction() & sigemptyset() on Linux, * but glibc docs claim _XOPEN_SOURCE >= 700 has the same effect, plus we need * _XOPEN_SOURCE >= 500 for ncurses wchar APIs on linux. */ #ifdef __linux__ # ifndef _BSD_SOURCE # define _BSD_SOURCE /* mkstemps(3) on glibc <= 2.19 */ # endif /* _BSD_SOURCE */ # ifndef _XOPEN_SOURCE # define _XOPEN_SOURCE 700 # endif /* _XOPEN_SOURCE */ # ifndef _DEFAULT_SOURCE # define _DEFAULT_SOURCE /* strsep() on glibc >= 2.19. */ # endif /* _DEFAULT_SOURCE */ # ifdef __has_include # if __has_include("linux/landlock.h") # define HAVE_LANDLOCK # include <linux/landlock.h> # include <linux/prctl.h> # include <sys/prctl.h> # include <sys/syscall.h> |
︙ | |||
86 87 88 89 90 91 92 | 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 | - - - - - - - - - - - + + + + + + + + + + + + - - + + + + - + + + + + + + + | /* Utility macros. */ #define MIN(_a, _b) ((_a) < (_b) ? (_a) : (_b)) #define MAX(_a, _b) ((_a) > (_b) ? (_a) : (_b)) #define ABS(_n) ((_n) >= 0 ? (_n) : -(_n)) #ifndef CTRL #define CTRL(key) ((key) & 037) /* CTRL+<key> input. */ #endif |
︙ | |||
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | 179 180 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 | + + + | # endif /* strlcat */ # ifndef strlcpy # define strlcpy(_d, _s, _sz) fsl_strlcpy(_d, _s, _sz) # endif /* strlcpy */ #endif /* __linux__ */ __dead static void usage(void); static void help_stash(const fcli_command *); static void usage_timeline(void); static void usage_diff(void); static void usage_tree(void); static void usage_blame(void); static void usage_branch(void); static void usage_config(void); static void usage_stash(void); static int fcli_flag_type_arg_cb(fcli_cliflag const *); static int cmd_timeline(fcli_command const *); static int cmd_diff(fcli_command const *); static int cmd_tree(fcli_command const *); static int cmd_blame(fcli_command const *); static int cmd_branch(fcli_command const *); static int cmd_config(fcli_command const *); static int cmd_stash(fcli_command const *); /* * Singleton initialising global configuration and state for app startup. */ static struct fnc_setup { /* Global options. */ const char *cmdarg; /* Retain argv[1] for use/err report. */ |
︙ | |||
239 240 241 242 243 244 245 | 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | - + + | /* Config options. */ bool lsconf; /* List all defined settings. */ bool unset; /* Unset the specified setting. */ /* Command line flags and help. */ fcli_help_info fnc_help; /* Global help. */ fcli_cliflag cliflags_global[3]; /* Global options. */ |
︙ | |||
271 272 273 274 275 276 277 | 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | - + | false, /* sbs diff defaults to false (show unified diff). */ false, /* ws defaults to acknowledge all whitespace. */ false, /* eol defaults to acknowledge eol whitespace. */ false, /* nocolour defaults to off (i.e., use diff colours). */ true, /* verbose defaults to on. */ false, /* invert diff defaults to off. */ false, /* showln in diff defaults to off. */ |
︙ | |||
313 314 315 316 317 318 319 320 321 322 323 324 325 326 | 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | + + + + | cmd_blame, usage_blame, fnc_init.cliflags_blame}, {"branch", "br\0tag\0", "Show navigable list of repository branches.", cmd_branch, usage_branch, fnc_init.cliflags_branch}, {"config", "conf\0cfg\0settings\0set\0", "Configure or view currently available settings.", cmd_config, usage_config, fnc_init.cliflags_config}, {"stash", "snapshot\0snap\0save\0sta\0", "Interactively select hunks to stash from the diff of local " "changes on\n disk.", cmd_stash, usage_stash, fnc_init.cliflags_stash}, {NULL, NULL, NULL, NULL, NULL} /* Sentinel. */ }, { /* cliflags_timeline timeline command related options. */ FCLI_FLAG("b", "branch", "<branch>", &fnc_init.filter_branch, "Only display commits that reside on the given <branch>."), FCLI_FLAG_BOOL("C", "no-colour", &fnc_init.nocolour, |
︙ | |||
379 380 381 382 383 384 385 | 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | - + | FCLI_FLAG_BOOL("i", "invert", &fnc_init.invert, "Invert difference between artifacts. Inversion can also be " "toggled\n with the 'i' key binding in diff view."), FCLI_FLAG_BOOL("l", "line-numbers", &fnc_init.showln, "Show file line numbers in diff output. Line numbers can also be " "toggled\n with the 'L' key binding in diff view."), FCLI_FLAG_BOOL_INVERT("P", "no-prototype", &fnc_init.proto, |
︙ | |||
518 519 520 521 522 523 524 525 526 527 528 529 530 531 | 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 | + + + + + + + + + + + + + + | "Use the fossil(1) repository located at <path> for this config\n" " invocation."), FCLI_FLAG_BOOL("u", "unset", &fnc_init.unset, "Unset (i.e., remove) the specified repository setting."), fcli_cliflag_empty_m }, /* End cliflags_tree. */ { /* cliflags_stash stash command related options. */ FCLI_FLAG_BOOL("C", "no-colour", &fnc_init.nocolour, "Disable coloured diff output, which is enabled by default on\n " "supported terminals."), FCLI_FLAG_BOOL("h", "help", NULL, "Display stash command help and usage."), FCLI_FLAG_BOOL_INVERT("P", "no-prototype", &fnc_init.proto, "Disable display of the enclosing function prototype in diff hunk " "headers."), FCLI_FLAG("x", "context", "<n>", &fnc_init.context, "Show <n> context lines when displaying diff; <n> is capped at 64." "\n Negative values are a no-op."), fcli_cliflag_empty_m }, /* End cliflags_stash. */ }; enum date_string { ISO8601_DATE_ONLY = 10, ISO8601_DATE_HHMM = 16, ISO8601_TIMESTAMP = 20 }; |
︙ | |||
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 | 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 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + | enum fnc_diff_type { FNC_DIFF_CKOUT, FNC_DIFF_COMMIT, FNC_DIFF_BLOB, FNC_DIFF_WIKI }; enum fnc_diff_mode { DIFF_PLAIN, COMMIT_META, STASH_INTERACTIVE }; enum fnc_diff_hunk { HUNK_NONE, HUNK_STASH, HUNK_CKOUT }; enum fnc_patch_rc { PATCH_OK, PATCH_MALFORMED, PATCH_TRUNCATED, NO_PATCH, HUNK_FAILED, PATCH_FAILED, }; enum stash_opt { NO_CHOICE, KEEP_FILE, /* keep remaining hunks in file in ckout */ KEEP_DIFF, /* keep remaining hunks in diff in ckout */ STASH_FILE, /* stash the rest of the hunks in the file */ STASH_DIFF /* stash the rest of the hunks in the diff */ }; struct input { void *data; char *prompt; enum input_type type; int flags; #define SR_CLREOL 1 << 0 #define SR_UPDATE 1 << 1 #define SR_SLEEP 1 << 2 #define SR_RESET 1 << 3 |
︙ | |||
716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 | 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | fsl_id_t rid; } tagged; const char *curr_ckout_uuid; const char *glob; /* Match commits containing glob. */ char *path; /* Match commits involving path. */ int selected; int nscrolled; uint16_t maxx; sig_atomic_t quit; pthread_t thread_id; bool colour; bool showmeta; }; struct fnc_pathlist_entry { TAILQ_ENTRY(fnc_pathlist_entry) entry; const char *path; size_t pathlen; void *data; /* XXX May want to save id, mode, etc. */ }; TAILQ_HEAD(fnc_pathlist_head, fnc_pathlist_entry); struct index { size_t *lineno; off_t *offset; uint32_t n; uint32_t idx; }; /* * A stash context is comprised of two patch contexts: a (1) patch of all hunks * selected to stash; and a (2) patch of all hunks kept in the checkout. Each * patch has a queue of fnc_patch_file(s), one for each versioned file with * hunks to be stashed or kept. Each fnc_patch_file has a queue of hunks with * an array of all context, plus, and minus lines comprising the hunk. Each * patch context produces a patch(1) file that gets applied to the base ckout. */ struct fnc_patch_hunk { STAILQ_ENTRY(fnc_patch_hunk) entries; char **lines; /* plus, minus, context lines */ long offset; /* line offset into this hunk */ size_t nlines; /* number of *lines */ size_t cap; /* capacity of **lines */ int_least32_t oldfrom; /* start line in "from" file */ int_least32_t oldlines; /* number of lines from "oldfrom" */ int_least32_t newfrom; /* start line in "new" file */ int_least32_t newlines; /* number of lines from "newfrom" */ bool nonl; /* line continuation flag */ enum fnc_patch_rc rc; }; STAILQ_HEAD(fnc_patch_hunk_head, fnc_patch_hunk); struct fnc_patch_file { STAILQ_ENTRY(fnc_patch_file) entries; char old[PATH_MAX]; char new[PATH_MAX]; struct fnc_patch_hunk_head head; }; typedef int (*fnc_patch_report_cb)(struct fnc_patch_file *, const char *, const char *, char *); STAILQ_HEAD(fnc_patch_file_head, fnc_patch_file); struct patch_cx { fnc_patch_report_cb report_cb; struct fnc_patch_file *pf; /* current fnc_patch_file */ struct fnc_patch_file_head head; /* queue of fnc_patch_file(s) */ uint8_t context; /* MAX_DIFF_CTX lines = 64 */ enum fnc_patch_rc rc; bool report; }; struct stash_cx { struct patch_cx pcx; struct index hunk; /* line indexes for each hunk in the diff */ char patch[2][PATH_MAX]; /* stash & ckout patch filepath */ unsigned char *stash; /* bit array into this.hunk->lineno */ #define NBITS (sizeof(unsigned char) * 8) #define nbytes(nbits) (((nbits) + 7) >> 3) #define BIT_SET(_B, _i) (_B[(_i / NBITS)] |= (1 << (_i % NBITS))) #define BIT_CLR(_B, _i) (_B[(_i / NBITS)] &= ~(1 << (_i % NBITS))) #define BIT_CHK(_B, _i) (_B[(_i / NBITS)] & (1 << (_i % NBITS))) }; struct fnc_diff_view_state { struct fnc_view *view; struct fnc_view *parent_view; struct fnc_commit_artifact *selected_entry; struct fnc_pathlist_head *paths; struct stash_cx scx; fsl_buffer buf; struct fnc_colours colours; struct index index; FILE *f; fsl_uuid_str id1; fsl_uuid_str id2; int first_line_onscreen; |
︙ | |||
762 763 764 765 766 767 768 769 770 771 | 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 | + + - | int lineno; int gtl; uint32_t ndlines; size_t ncols; size_t nlines; enum line_type *dlines; enum line_attr sline; enum fnc_diff_hunk stash; enum fnc_diff_mode diff_mode; off_t *line_offsets; bool eof; bool colour; |
︙ | |||
980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 | 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 | + + - - - - + + + + | static int signal_tl_thread(struct fnc_view *, int); static int draw_commits(struct fnc_view *); static void parse_emailaddr_username(char **); static int formatln(wchar_t **, int *, const char *, size_t, int, bool); static size_t expand_tab(char **, const char *, int); static int multibyte_to_wchar(const char *, wchar_t **, size_t *); static int replace_unicode(char **, const char *); static int write_commit_line(struct fnc_view *, struct fnc_commit_artifact *, int); static int view_input(struct fnc_view **, int *, struct fnc_view *, struct view_tailhead *); static int cycle_view(struct fnc_view *); static int toggle_fullscreen(struct fnc_view **, struct fnc_view *); static int stash_help(struct fnc_view *, int8_t); static int help(struct fnc_view *); |
︙ | |||
1018 1019 1020 1021 1022 1023 1024 | 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 | - + - + + - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | static int view_search_start(struct fnc_view *); static void tl_grep_init(struct fnc_view *); static int tl_search_next(struct fnc_view *); static bool find_commit_match(struct fnc_commit_artifact *, regex_t *); static int init_diff_view(struct fnc_view **, int, int, struct fnc_commit_artifact *, struct fnc_view *, |
︙ | |||
1168 1169 1170 1171 1172 1173 1174 | 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 | - + - + + - + - - + - | static void view_set_child(struct fnc_view *, struct fnc_view *); static int view_close_child(struct fnc_view *); static int close_tree_view(struct fnc_view *); static int close_timeline_view(struct fnc_view *); static int close_diff_view(struct fnc_view *); static void free_index(struct index *); static void free_tags(struct fnc_tl_view_state *, bool); |
︙ | |||
1226 1227 1228 1229 1230 1231 1232 | 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 | - + + + + + + + + + + - + - - - + + + + + + - - + + - - - - + - - + + - - - - + - - - - + + + - - - - + + - - - - + + - + - + - - - + - - + + + + + + + + + | const char *, size_t); int main(int argc, const char **argv) { fcli_command *cmd = NULL; char *path = NULL; |
︙ | |||
1360 1361 1362 1363 1364 1365 1366 | 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 | - + + - + | if (rc) goto end; } rc = init_curses(); if (rc) goto end; |
︙ | |||
1411 1412 1413 1414 1415 1416 1417 | 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 | - + - + - + - - - + + + - - - + - + - + - + | *requested_path = NULL; /* If no path argument is supplied, default to repository root. */ if (!fcli_next_arg(false)) { *requested_path = fsl_strdup("/"); if (*requested_path == NULL) |
︙ | |||
1536 1537 1538 1539 1540 1541 1542 | 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 | - - - - + + - + - + - + + + | } /* Trim trailing slash if it exists. */ if (path[fsl_strlen(path) - 1] == '/') path[fsl_strlen(path) - 1] = '\0'; end: |
︙ | |||
1608 1609 1610 1611 1612 1613 1614 | 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 | - + - + | abspath[parentlen - 1 /* Trailing slash */] != '/') return RC(FSL_RC_TYPE, "invalid path [%s]", abspath); while (abspath[parentlen] == '/') ++abspath; bufsz = len - parentlen + 1; *child = fsl_malloc(bufsz); if (*child == NULL) |
︙ | |||
1655 1656 1657 1658 1659 1660 1661 | 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 | - + - + - + | static int fnc_set_signals(void) { if (sigaction(SIGPIPE, &(struct sigaction){{sigpipe_handler}}, NULL) == -1) return RC(fsl_errno_to_rc(errno, FSL_RC_ERROR), |
︙ | |||
1716 1717 1718 1719 1720 1721 1722 | 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 | - + - + | fsl_id_t idtag = 0; int idx, rc = FSL_RC_OK; if (path != s->path) { fsl_free(s->path); s->path = fsl_strdup(path); if (s->path == NULL) |
︙ | |||
1776 1777 1778 1779 1780 1781 1782 | 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 | - + - - + - | fsl_free(id); if (!ispath) return RC(FSL_RC_NOT_FOUND, "'%s' invalid path in [%s]", path + 1, fnc_init.sym ? fnc_init.sym : "tip"); } if ((rc = pthread_cond_init(&s->thread_cx.commit_consumer, NULL))) { |
︙ | |||
1934 1935 1936 1937 1938 1939 1940 | 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 | - + - + - + | view->close = close_timeline_view; view->grep_init = tl_grep_init; view->grep = tl_search_next; s->thread_cx.q = fsl_stmt_malloc(); rc = fsl_db_prepare(db, s->thread_cx.q, "%b", &sql); if (rc) { |
︙ | |||
1995 1996 1997 1998 1999 2000 2001 | 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 | - + | { struct view_tailhead views; struct fnc_view *new_view; int done = 0, err = 0, rc = 0; if ((rc = pthread_mutex_lock(&fnc_mutex))) return RC(fsl_errno_to_rc(rc, FSL_RC_ACCESS), |
︙ | |||
2022 2023 2024 2025 2026 2027 2028 | 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 | - + | prev = view->parent; if (view->parent) { view->parent->child = NULL; view->parent->focus_child = false; /* Restore fullscreen line height. */ view->parent->nlines = view->parent->lines; |
︙ | |||
2105 2106 2107 2108 2109 2110 2111 | 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 | - + - + | view = TAILQ_FIRST(&views); TAILQ_REMOVE(&views, view, entries); view_close(view); } if ((err = pthread_mutex_unlock(&fnc_mutex)) && !rc) rc = RC(fsl_errno_to_rc(err, FSL_RC_ACCESS), |
︙ | |||
2163 2164 2165 2166 2167 2168 2169 | 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 | - + - + - + - + - + - - + - - + - - + - - + | else if (cx->ncommits_needed > 0) cx->ncommits_needed--; break; } if ((rc = pthread_mutex_lock(&fnc_mutex))) { rc = RC(fsl_errno_to_rc(rc, FSL_RC_ACCESS), |
︙ | |||
2244 2245 2246 2247 2248 2249 2250 | 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 | - + - + - + - + - + - + - - + | * of the APIs down the fsl_stmt_step() call stack fails; * irrespective of whether fsl_db_prepare_cached() was used. */ fsl_size_t loaded = cx->commits->ncommits + 1; cx->reset = false; rc = fsl_stmt_reset(cx->q); if (rc) |
︙ | |||
2338 2339 2340 2341 2342 2343 2344 | 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 | - + | "FROM tag, tagxref WHERE tagname GLOB 'sym-*' " "AND tag.tagid=tagxref.tagid AND tagxref.rid=blob.rid " "AND tagxref.tagtype > 0) as tags, " /*6*/"coalesce(ecomment, comment) AS comment " "FROM event JOIN blob WHERE blob.rid=%d AND event.objid=%d", fnc_init.utc ? "" : ", 'localtime'", rid, rid); if (rc) |
︙ | |||
2390 2391 2392 2393 2394 2395 2396 | 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 | - + - + - + | case 'f': type = "forum"; break; }; if (!rc && comment) rc = fsl_buffer_append(&buf, comment, -1); if (rc) { |
︙ | |||
2441 2442 2443 2444 2445 2446 2447 | 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 | - + - + | if (view->mode == VIEW_SPLIT_HRZN) cx->reset = true; /* Wake timeline thread. */ rc = pthread_cond_signal(&cx->commit_consumer); if (rc) return RC(fsl_errno_to_rc(rc, FSL_RC_MISUSE), |
︙ | |||
2499 2500 2501 2502 2503 2504 2505 | 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 | - + | if (tcx->ncommits_needed > 0 && !tcx->eotl) { if ((idxstr = fsl_mprintf(" [%d/%d] %s", entry ? entry->idx + 1 : 0, s->commits.ncommits, (view->searching && !view->search_status) ? "searching..." : view->search_status == SEARCH_ABORTED ? "aborted" : "loading...")) == NULL) { |
︙ | |||
2524 2525 2526 2527 2528 2529 2530 | 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 | - + | } if ((idxstr = fsl_mprintf("%s [%d/%d] %s", !fsl_strcmp(uuid, s->curr_ckout_uuid) ? " [current]" : "", entry ? entry->idx + 1 : 0, s->commits.ncommits, search_str ? search_str : (branch ? branch : ""))) == NULL) { |
︙ | |||
2546 2547 2548 2549 2550 2551 2552 | 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 | - + - + | if (s->path[1]) { if ((headln = fsl_mprintf("%s%c%.*s %s%s", type ? type : "", type ? ' ' : SPINNER[tcx->spin_idx], view->ncols < ncols_needed ? view->ncols - (ncols_needed - FSL_STRLEN_K256) : FSL_STRLEN_K256, uuid ? uuid : "........................................", s->path, idxstr)) == NULL) { |
︙ | |||
2584 2585 2586 2587 2588 2589 2590 | 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 | + - + + + + - + - + - - + + + + + + | ++wlen; } wattroff(view->window, rx); fsl_free(wline); if (view->nlines <= 1) goto end; /* |
︙ | |||
2703 2704 2705 2706 2707 2708 2709 | 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 | - + - + | i++; } else if (width == -1) { if (wline[i] == L'\t') { width = TABSIZE - ((cols + start_column) % TABSIZE); } else { width = 1; |
︙ | |||
2763 2764 2765 2766 2767 2768 2769 | 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 | + - + - - + + + + + + + + + - + + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | *ptr = dst; return sz; } static int multibyte_to_wchar(const char *src, wchar_t **dst, size_t *dstlen) { char *rep = NULL; |
︙ | |||
2821 2822 2823 2824 2825 2826 2827 | 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 | - + | int maxlen) { struct fnc_tl_view_state *s = &view->state.timeline; struct fnc_colour *c = NULL; wchar_t *wstr = NULL; char *comment0 = NULL, *comment = NULL; char *date = NULL; |
︙ | |||
2865 2866 2867 2868 2869 2870 2871 | 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 | - + - - - - + + + + + + - - - + + + + - - - - - - + + + + + + + + + - - + - + - + - - + + + + + + + - + - + + + - + + + + - - - - | * the longest username on the screen. */ user = fsl_strdup(commit->user); if (user == NULL) goto end; if (strpbrk(user, "<@>") != NULL) parse_emailaddr_username(&user); |
︙ | |||
3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 | 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 | + + + + | case CTRL('z'): raise(SIGTSTP); default: rc = view->input(new, view, ch); break; } if (rc == FSL_RC_BREAK) { rc = FSL_RC_OK; *done = 1; } return rc; } static int cycle_view(struct fnc_view *view) { int rc = FSL_RC_OK; |
︙ | |||
3092 3093 3094 3095 3096 3097 3098 3099 3100 | 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 | - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | rc = offset_selected_line(view->parent); if (!rc) rc = offset_selected_line(view); } return rc; } static int |
︙ | |||
3198 3199 3200 3201 3202 3203 3204 | 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 | - - - - + + + + + + | "Move selection cursor or page down one line", "Scroll view up one page", "Scroll view down one page", "Scroll view up one half page", "Scroll view down one half page", "Jump to first line or start of the view", "Jump to last line or end of the view", |
︙ | |||
3235 3236 3237 3238 3239 3240 3241 | 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 | - + | "Navigate to next file in the diff", "Navigate to previous file in the diff", "Open and populate branch view with all repository branches", "Open prompt to enter file number and navigate to file", "Toggle inversion of diff output", "Toggle display of file line numbers", "Prompt for path to write a patch of the currently viewed diff", |
︙ | |||
3274 3275 3276 3277 3278 3279 3280 | 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 | - - + - - + - - - - - - - - - - - - - - - - - - - - + - - - - + + + - + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - + - - - + + + + + | "Toggle display of the SHA hash that identifies the branch", "Toggle branch sort order (lexicographical -> mru -> state)", "Open a tree view of the currently selected branch", "Reload view with all repository branches and no filters applied", "", " See fnc(1) for complete list of options and key bindings." }; |
︙ | |||
3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 | 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 | + + + - - - + + + - + - - + + + - - - - - + + + + + + + + + + + + + + + + + + + | box(win, 0, 0); wnoutrefresh(win); pnoutrefresh(content, cury, curx, y0 + 1, x0 + 1, wy, wx); doupdate(); } while (!rc && (ch = wgetch(content)) != 'q' && ch != KEY_ESCAPE && ch != ERR); if (fclose(txt) == EOF) rc = RC(fsl_errno_to_rc(errno, FSL_RC_IO), "fclose"); /* Destroy window. */ werase(win); wrefresh(win); delwin(win); delwin(content); /* Restore fnc window content. */ touchwin(view->window); wnoutrefresh(view->window); doupdate(); return rc; } |
︙ | |||
3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 | 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 | + - - + + - + - + - - + + | move_tl_cursor_up(view, false, true); break; case KEY_RESIZE: if (s->selected > view->nlines - 2) s->selected = view->nlines - 2; if (s->selected > s->commits.ncommits - 1) s->selected = s->commits.ncommits - 1; s->selected = MAX(s->selected, 0); select_commit(s); if (s->commits.ncommits < view->nlines - 1 && !s->thread_cx.eotl) { s->thread_cx.ncommits_needed += (view->nlines - 1) - s->commits.ncommits; rc = signal_tl_thread(view, 1); } break; case 'C': { if (s->selected_entry->commit->type[0] != 'c') { |
︙ | |||
3565 3566 3567 3568 3569 3570 3571 | 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 | - + - - + + - | struct input input = {NULL, "filter: ", INPUT_ALPHA, SR_CLREOL}; rc = fnc_prompt_input(view, &input); if (rc) return rc; s->glob = input.buf; rc = request_view(new_view, view, FNC_VIEW_TIMELINE); if (rc == FSL_RC_BREAK) { |
︙ | |||
3758 3759 3760 3761 3762 3763 3764 | 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 | - + | switch (request) { case FNC_VIEW_DIFF: { struct fnc_tl_view_state *s = &view->state.timeline; if (s->selected_entry == NULL) break; rc = init_diff_view(new_view, x, y, s->selected_entry->commit, |
︙ | |||
3787 3788 3789 3790 3791 3792 3793 | 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 | - + | rc = browse_commit_tree(new_view, x, y, s->selected_entry, s->path); break; } case FNC_VIEW_BRANCH: { *new_view = view_open(0, 0, y, x, FNC_VIEW_BRANCH); if (*new_view == NULL) |
︙ | |||
3833 3834 3835 3836 3837 3838 3839 | 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 | - + | static int split_view(struct fnc_view *view, int *start_ln) { int rc = FSL_RC_OK; view->mode = VIEW_SPLIT_HRZN; view->nlines = *start_ln; |
︙ | |||
3982 3983 3984 3985 3986 3987 3988 | 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 | - + - + - + - + | view->start_col = view->mode != VIEW_SPLIT_HRZN ? view_split_start_col(0) : 0; view->nlines = LINES - view->start_ln; view->ncols = COLS - view->start_col; view->lines = LINES; view->cols = COLS; |
︙ | |||
4048 4049 4050 4051 4052 4053 4054 | 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 | - + - - + - | int rc = FSL_RC_OK; height = fnc_conf_getopt(FNC_VIEW_SPLIT_HEIGHT, false); if (height && height[fsl_strlen(height) - 1] == '%') { n = strtol(height, NULL, 10); if (n > INT_MAX || (errno == ERANGE && n == LONG_MAX)) |
︙ | |||
4132 4133 4134 4135 4136 4137 4138 | 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 | - + - + | update_panels(); doupdate(); if (s->search_commit) { int ch; if ((rc = pthread_mutex_unlock(&fnc_mutex))) return RC(fsl_errno_to_rc(rc, FSL_RC_ACCESS), |
︙ | |||
4220 4221 4222 4223 4224 4225 4226 | 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 | - + - + - - - + + + - - | s->search_commit = NULL; end: cbreak(); return rc; } static bool |
︙ | |||
4299 4300 4301 4302 4303 4304 4305 | 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 | - + - + - + - + - + - - + - | int rc = 0; if (s->thread_id) { s->quit = 1; if ((rc = pthread_cond_signal(&s->thread_cx.commit_consumer))) return RC(fsl_errno_to_rc(rc, FSL_RC_MISUSE), |
︙ | |||
4378 4379 4380 4381 4382 4383 4384 | 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 | - + - + - + - + + + - + | return 0; } static int init_diff_view(struct fnc_view **new_view, int start_col, int start_ln, struct fnc_commit_artifact *commit, struct fnc_view *parent_view, |
︙ | |||
4555 4556 4557 4558 4559 4560 4561 4562 | 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 | + - + - + - + - + - + - + - + - + - + + + + + - + - + + + + + + + + + - + + - - - + + + + + + + + + + - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | char *line, *st0 = NULL, *st = NULL; off_t off = 0; uint32_t idx = 0; int rc = 0; s->maxx = 0; free_index(&s->index); free(s->dlines); |
︙ | |||
4703 4704 4705 4706 4707 4708 4709 | 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 | - + | "(SELECT name FROM filename WHERE filename.fnid=mlink.pfnid) " "FROM mlink JOIN filename ON filename.fnid=mlink.fnid " "WHERE mlink.mid=%d AND NOT mlink.isaux " "AND (mlink.fid > 0 " "OR mlink.fnid NOT IN (SELECT pfnid FROM mlink WHERE mid=%d)) " "ORDER BY name", commit->rid, commit->rid); if (rc) |
︙ | |||
4753 4754 4755 4756 4757 4758 4759 | 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 | - + - - - + - + - + - + + - + - + - - + + + - + - + - + + - - + + + - + - - + - - - - + + + + - - - + + + - - + + | static int write_commit_meta(struct fnc_diff_view_state *s) { char *line = NULL, *st0 = NULL, *st = NULL; fsl_size_t linelen, idx = 0; off_t off = 0; |
︙ | |||
4936 4937 4938 4939 4940 4941 4942 | 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 | - - + + - + - + - + - - - - - - - - - - - - - - - - - - - - | int n = 0, rc = 0; while ((word = fnc_strsep(&line, " ")) != NULL) { wordlen = fsl_strlen(word); if ((cursor + wordlen) >= limit) { fputc('\n', s->f); ++(*off); |
︙ | |||
5095 5096 5097 5098 5099 5100 5101 | 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 | - - - + + + + - - - + - - + + + + + | change = FSL_CKOUT_CHANGE_MOD; if (diff) rc = diff_file_artifact(s, id1, fc1, fc2, change); fsl_deck_F_next(&d1, &fc1); fsl_deck_F_next(&d2, &fc2); } |
︙ | |||
5147 5148 5149 5150 5151 5152 5153 | 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 | - - + + - + - + - - + + - + + - + - + + - - - - - + + + + + - + + - + + + - + | * changes. Otherwise query the current checkout state for changes. */ if (vid != cid) { /* Keep vfile ckout state; but unload vid when finished. */ rc = fsl_vfile_load(f, vid, false, NULL); if (rc) goto unload; |
︙ | |||
5238 5239 5240 5241 5242 5243 5244 | 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 | - + - + + + + + + | if (rc) goto yield; do { fsl_deck_F_next(&d, &cf); if (cf && !fsl_strcmp(cf->name, path)) { xminus = fsl_strdup(cf->uuid); if (xminus == NULL) { |
︙ | |||
5279 5280 5281 5282 5283 5284 5285 | 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 | - + - - - + + + + - - - + - - + + + + + | if (!fsl_strncmp(pe->path, path, pe->pathlen) || !fsl_strcmp(pe->path, path)) { diff = true; break; } } if (diff) |
︙ | |||
5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 | 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 | + + - + + + + + + + + + + + + + - + - - - + + | case FSL_CKOUT_CHANGE_MOD: /* FALL THROUGH */ default: minus = xminus; plus = xplus; break; } zminus = zminus ? zminus : zplus; if FLAG_CHK(s->diff_flags, FNC_DIFF_INVERT) { const char *tmp = minus; minus = plus; plus = tmp; tmp = zminus; zminus = zplus; zplus = tmp; } if (!FLAG_CHK(s->diff_flags, FNC_DIFF_BRIEF)) { |
︙ | |||
5401 5402 5403 5404 5405 5406 5407 | 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 | - + + - | * xminus hex UUID containing the SHA{1,3} hash of the file named zminus * abspath absolute path to the file on disk being diffed * change enum denoting the versioning change of the file * diff_flags, context, and sbs are the same parameters as diff_file_artifact() */ static int diff_file(struct fnc_diff_view_state *s, fsl_buffer *bminus, const char *zminus, |
︙ | |||
5435 5436 5437 5438 5439 5440 5441 | 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 | - | * removed file with 'fossil diff -v' output—remove the above * 'if (change != FSL_CKOUT_CHANGE_REMOVED)' from the else * condition and uncomment the following three lines of code. */ /* if (change == FSL_CKOUT_CHANGE_REMOVED && */ /* !fsl_buffer_compare(bminus, &bplus)) */ /* fsl_buffer_clear(&bplus); */ |
︙ | |||
5488 5489 5490 5491 5492 5493 5494 | 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 | - | zminus); } else if (FLAG_CHK(s->diff_flags, FNC_DIFF_VERBOSE) || (bminus->used && bplus.used)) rc = fnc_diff_text_to_buffer(bminus, &bplus, &s->buf, &s->dlines, &s->ndlines, s->context, s->sbs, s->diff_flags); end: |
︙ | |||
5512 5513 5514 5515 5516 5517 5518 | 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 | - + - + - + | fsl_id_t prid = 0; fsl_size_t idx; int rc = 0; fsl_deck *d = NULL; d = fsl_deck_malloc(); if (d == NULL) |
︙ | |||
5660 5661 5662 5663 5664 5665 5666 | 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 | - + | if (rc == FSL_RC_STEP_ROW) { rc = 0; zminus0 = fsl_strdup(fsl_stmt_g_text(&stmt, 0, NULL)); zminus = zminus0; } else if (rc == FSL_RC_STEP_DONE) rc = 0; else if (rc) { |
︙ | |||
5690 5691 5692 5693 5694 5695 5696 | 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 | - + | if (rc == FSL_RC_STEP_ROW) { rc = 0; zplus0 = fsl_strdup(fsl_stmt_g_text(&stmt, 0, NULL)); zplus = zplus0; } else if (rc == FSL_RC_STEP_DONE) rc = 0; else if (rc) { |
︙ | |||
5719 5720 5721 5722 5723 5724 5725 | 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 | - - + - + - + - + - + + - - + + + + - + | s->diff_flags); if (rc) RC(rc, "%s: fnc_diff_text_to_buffer\n" " -> %s [%s]\n -> %s [%s]", fsl_rc_cstr(rc), a ? a->name : NULL_DEVICE, a ? a->uuid : NULL_DEVICE, b ? b->name : NULL_DEVICE, b ? b->uuid : NULL_DEVICE); end: |
︙ | |||
5833 5834 5835 5836 5837 5838 5839 | 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 | - + + + + + + - - - + + | if (linelen == -1) { if (feof(s->f)) { s->eof = true; break; } fsl_free(line); RC(ferror(s->f) ? fsl_errno_to_rc(errno, FSL_RC_IO) : |
︙ | |||
6147 6148 6149 6150 6151 6152 6153 | 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 | - + | while (!s->eof && i++ < nscroll) { linelen = getline(&line, &linesz, s->f); ++s->first_line_onscreen; if (linelen == -1) { if (!feof(s->f)) return RC(ferror(s->f) ? fsl_errno_to_rc(errno, FSL_RC_IO) : |
︙ | |||
6244 6245 6246 6247 6248 6249 6250 | 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 | - + | case 'b': { int start_col = 0; if (view_is_parent(view)) start_col = view_split_start_col(view->start_col); branch_view = view_open(view->nlines, view->ncols, view->start_ln, start_col, FNC_VIEW_BRANCH); if (branch_view == NULL) |
︙ | |||
6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 | 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - | /* FALL THROUGH */ default: break; } return rc; } static int f__stash_get(bool pop) { fsl_cx *const f = fcli_cx(); fsl_db *db = fsl_needs_ckout(f); fsl_stmt q = fsl_stmt_empty; int nadded, stashid, vid, rc0, rc = FSL_RC_OK; uint32_t cc = 0; stashid = fsl_db_g_int32(db, 0, "SELECT max(stashid) FROM stash"); if (!stashid) { f_out(">> empty stash"); return rc; } vid = f->ckout.rid; rc = fsl_db_prepare(db, &q, "SELECT blob.rid, isRemoved, isExec," " isLink, origname, newname, delta FROM stashfile, blob" " WHERE stashid=%d AND blob.uuid=stashfile.hash UNION ALL" " SELECT 0, isRemoved, isExec, isLink, origname, newname, delta" " FROM stashfile WHERE stashid=%d AND stashfile.hash IS NULL", stashid, stashid); if (rc) return RC(rc, "fsl_db_prepare"); fsl_db_exec_multi(db, "CREATE TEMP TABLE sfile(pathname TEXT PRIMARY KEY %s)", fsl_cx_filename_collation(f)); if (rc) return RC(rc, "fsl_db_exec_multi"); while (fsl_stmt_step(&q) == FSL_RC_STEP_ROW) { fsl_buffer delta = fsl_buffer_empty; const void *blob = NULL; const char *ogname = fsl_stmt_g_text(&q, 4, NULL); const char *name = fsl_stmt_g_text(&q, 5, NULL); int rid = fsl_stmt_g_int32(&q, 0); int removed = fsl_stmt_g_int32(&q, 1); int exec = fsl_stmt_g_int32(&q, 2); int link = fsl_stmt_g_int32(&q, 3); char *ogpath = fsl_mprintf("%s%s", CKOUTDIR, ogname); char *path = fsl_mprintf("%s%s", CKOUTDIR, name); fsl_size_t len = 0; if (!rid) { /* new file */ rc = fsl_db_exec_multi(db, "INSERT OR IGNORE INTO sfile(pathname) VALUES(%Q)", name); if (!rc) rc = fsl_stmt_get_blob(&q, 6, &blob, &len); fsl_buffer_external(&delta, blob, len); if (!rc) rc = fsl_buffer_to_filename(&delta, path); if (!rc) rc = fsl_file_exec_set(path, exec); if (rc) { rc = RC(rc, "new file: %s", name); goto clear_delta; } } else if (removed) { fsl_ckout_unmanage_opt opt = fsl_ckout_unmanage_opt_empty; opt.scanForChanges = false; opt.vfileIds = NULL; opt.relativeToCwd = false; opt.callback = stash_get_rm_cb; opt.callbackState = NULL; opt.filename = ogname; rc = fsl_ckout_unmanage(f, &opt); if (rc) { rc = RC(rc, "fsl_ckout_unmanage(%s)", ogname); goto clear_delta; } /* * XXX Unlike fossil(1), we don't want to rm the file * from disk because removal has not been committed, * only stashed. We've unmanaged it, let the user rm it. */ /* fsl_file_unlink(ogpath); */ } else if (fsl__ckout_safe_file_check(f, path)) /* nop--ignore unsafe path */; else { fsl_buffer a, b, out, disk; fsl_error err; int newlink = fsl_is_symlink(ogpath); a = b = out = disk = fsl_buffer_empty; rc = fsl_stmt_get_blob(&q, 6, &blob, &len); fsl_buffer_external(&delta, blob, len); if (rc) { rc = RC(rc, "fsl_stmt_get_blob"); goto clear_delta; } rc = fsl_buffer_fill_from_filename(&disk, ogpath); if (rc == FSL_RC_NOT_FOUND) rc = fsl_buffer_fill_from_filename(&disk, path); if (rc) { rc = RC(rc, "fsl_buffer_fill_from_filename(%s)", ogpath); goto clear_file; } rc = fsl_content_get(f, rid, &a); if (rc) { rc = RC(rc, "fsl_content_get(%d)", rid); goto clear_file; } rc = fsl_buffer_delta_apply2(&a, &delta, &b, &err); if (rc) { rc = RC(err.code, "%s", fsl_buffer_cstr(&err.msg)); goto clear_file; } if (link == newlink && !fsl_buffer_compare(&disk, &a)) { if (link || newlink) rc = fsl_file_unlink(path); if (!rc && link) { bool linkit = fsl_config_get_bool(f, FSL_CONFDB_REPO, false, "allow-symlinks"); rc = fsl_symlink_create( fsl_buffer_cstr(&b), path, linkit); f_out("[>] %s -> %s\n", fsl_buffer_cstr(&b), name); } else if (!rc) rc = fsl_buffer_to_filename(&b, path); if (!rc) rc = fsl_file_exec_set(path, exec); if (rc) { rc = RC(rc, "update file: %s", name); goto clear_file; } if (ogname && fsl_strcmp(ogname, name)) f_out("[>] %s -> %s\n", ogname, name); else f_out("[u] %s\n", name); } else { bool lnk = false; if (link || newlink) { lnk = true; fsl_buffer_clear(&b); /* f_out(">> cannot merge symlink %s\n", name); */ } else { rc = fsl_buffer_merge3(&a, &disk, &b, &out, &cc); if (!rc) rc = fsl_buffer_to_filename(&out, path); if (!rc) rc = fsl_file_exec_set(path, exec); if (rc) { rc = RC(rc, "merge file: %s", path); goto clear_file; } } if (cc) f_out("[!] %s -> %u " "merge conflict(s)\n", name, cc); else if (lnk) f_out("[!] %s -> symlink\n", name); else if (ogname && fsl_strcmp(ogname, name)) f_out("[~] %s -> %s\n", ogname, name); else f_out("[~] %s\n", name); } clear_file: fsl_buffer_clear(&a); fsl_buffer_clear(&b); fsl_buffer_clear(&out); fsl_buffer_clear(&disk); if (rc) goto clear_delta; } clear_delta: fsl_buffer_clear(&delta); if (!rc && fsl_strcmp(ogname, name)) { fsl_file_unlink(ogpath); if (rc) rc = RC(rc, "fsl_file_unlink(%s)", ogpath); rc = rc ? rc : fsl_db_exec_multi(db, "UPDATE vfile SET pathname='%q', origname='%q'" " WHERE pathname='%q' %s AND vid=%d", name, ogname, ogname, fsl_cx_filename_collation(f), vid); } fsl_free(path); fsl_free(ogpath); if (rc) break; } if (!rc) rc = f__add_files_in_sfile(&nadded, vid); rc0 = fsl_stmt_finalize(&q); rc = rc ? rc : rc0; if (cc) f_out("\n>> merge conflict(s): %u\n", cc); if (pop) { rc = fsl_db_exec_multi(db, "DELETE FROM stash WHERE stashid=%d;" "DELETE FROM stashfile WHERE stashid=%d;", stashid, stashid); } return rc; } static int f__add_files_in_sfile(int *nadded, int vid) { fsl_cx *const f = fcli_cx(); fsl_db *db = fsl_needs_ckout(f); int rc0, rc = FSL_RC_OK; fsl_stmt loop = fsl_stmt_empty; /* SQL to loop over all files to add */ rc = fsl_db_prepare(db, &loop, "SELECT pathname FROM sfile" " WHERE pathname NOT IN" " (SELECT sfile.pathname FROM vfile, sfile" " WHERE vfile.islink AND NOT vfile.deleted" " AND sfile.pathname>(vfile.pathname||'/')" " AND sfile.pathname<(vfile.pathname||'0'))" " ORDER BY pathname"); if (rc) return RC(rc, "fsl_db_prepare"); while (!rc && fsl_stmt_step(&loop) == FSL_RC_STEP_ROW) { fsl_ckout_manage_opt opt = fsl_ckout_manage_opt_empty; const char *add = fsl_stmt_g_text(&loop, 0, NULL); if (!fsl_strcmp(add, REPODB)) continue; if (fsl_is_reserved_fn(add, -1)) continue; opt.filename = add; opt.relativeToCwd = false; /* abs repo paths from fnc diff */ opt.checkIgnoreGlobs = true; /* XXX make an 'fnc stash' opt */ opt.callback = stash_get_add_cb; rc = fsl_ckout_manage(f, &opt); *nadded += opt.counts.added; } rc0 = fsl_stmt_finalize(&loop); return rc ? RC(rc, "fsl_ckout_manage") : rc0; } static int stash_get_rm_cb(fsl_ckout_unmanage_state const *st) { f_out("[-] %s\n", st->filename); return FSL_RC_OK; } static int stash_get_add_cb(fsl_ckout_manage_state const *cms, bool *include) { *include = true; f_out("[+] %s\n", cms->filename); return FSL_RC_OK; } /* * Get hunks selected to stash from the user and make two patch(1) files: * (1) diff of all hunks selected to stash; and (2) diff of all hunks to be * kept in the checkout. Then revert the checkout and use patch files to: * 1. apply patch of hunks selected to stash * 2. stash (and revert) checkout * 3. apply patch of hunks that were not selected to stash * This produces a ckout with only those changes that were not selected * to stash, achieving the same function as 'git add -p'. The user can * now test the code, commit, then run 'fnc stash pop' and repeat. */ static int fnc_stash(struct fnc_view *view) { struct fnc_diff_view_state *s = &view->state.diff; struct stash_cx *scx = &s->scx; struct input in; char *msg = NULL, *prompt = NULL; int rc = FSL_RC_OK; scx->stash = alloc_bitstring(scx->hunk.n); if (scx->stash == NULL) return RC(FSL_RC_ERROR, "calloc"); rc = select_hunks(view); /* get hunks to stash */ if (rc) goto end; /* Use default stash msg of "fnc stash CKOUT-HASH" if not provided. */ msg = fsl_mprintf("fnc stash %.11s", s->id2); prompt = fsl_mprintf("stash message [%s]: ", msg); in = (struct input){NULL, prompt, INPUT_ALPHA, SR_CLREOL}; rc = fnc_prompt_input(view, &in); if (in.buf[0]) { fsl_free(msg); msg = fsl_mprintf("%s", in.buf); } if (rc) { rc = RC(rc, "fnc_prompt_input"); goto end; } s->stash = HUNK_STASH; /* make patch of hunks selected to stash */ rc = create_diff(s); s->stash = HUNK_CKOUT; /* make patch of hunks to keep in ckout */ if (!rc) rc = create_diff(s); if (rc) goto end; endwin(); /* restore tty so we can report progress to stdout */ /* Clean ckout to apply patches; vfile already scanned in cmd_stash() */ rc = revert_ckout(true, false); if (rc) { rc = RC(rc, "revert_ckout"); goto end; } /* XXX With revert_ckout() finished, we can drop privileges further. */ rc = init_unveil(((const char *[]){"/usr/bin/patch", "fossil"}), ((const char *[]){"rx", "rx"}), 2, true); if (rc) goto end; scx->pcx.context = s->context; scx->pcx.report = true; /* report files with changes stashed */ rc = fnc_patch(&scx->pcx, scx->patch[0]); /* (1) apply stash patch */ scx->pcx.report = false; /* don't report changes kept in ckout */ if (!rc) { /* fnc_execp((const char *const []) */ /* {"fossil", "stash", "save", "-m", msg, (char *)NULL}, 10); */ rc = f__stash_create(msg, fcli_cx()->ckout.rid); /* (2) */ if (!rc) rc = revert_ckout(false, false); } if (!rc) rc = fnc_patch(&scx->pcx, scx->patch[1]); /* (3) ckout patch */ rc = (rc == NO_PATCH ? FSL_RC_OK : rc); end: fsl_free(scx->stash); fsl_free(scx->hunk.lineno); fsl_free(msg); fsl_free(prompt); return rc; } /* * Allocate, zero, and return an unsigned char pointer of enough bytes * to store n bits, which must eventually be disposed of by the caller. */ static unsigned char * alloc_bitstring(size_t n) { size_t idx; unsigned char *bs; bs = (unsigned char *)calloc((size_t)nbytes(n), sizeof(unsigned char)); for (idx = 0; bs && idx < n; ++idx) BIT_CLR(bs, idx); return bs; } static int select_hunks(struct fnc_view *view) { int rc = FSL_RC_OK; bool stashing = false; rc = stash_input_handler(view, &stashing); if (!rc && !stashing) rc = RC(FSL_RC_BREAK, "No hunks selected to stash, " "checkout state unchanged."); return rc; } /* * Iterate each hunk of changes in the local checkout, and prompt the user * for their choice with: "stash this hunk (b,m,y,n,a,k,A,K,?)? [y]" * b - scroll back (only available if hunk occupies previous page) * m - show more (only available if hunk occupies following page) * y - stash this hunk (default choice if [return] is pressed) * n - do not stash this hunk * a - stash this hunk and all remaining hunks in the _file_ * k - do not stash this hunk nor any remaining hunks in the _file_ * A - stash this hunk and all remaining hunks in the _diff_ * K - do not stash this hunk nor any remaining hunks in the _diff_ * ? - display stash help dialog box * Key maps in the stash help dialog: * q - quit the help * Q - exit help and quit fnc stash _discarding_ any selections * XXX This input handling and the set_choice() code is tricky! */ static int stash_input_handler(struct fnc_view *view, bool *stashing) { struct fnc_diff_view_state *s = &view->state.diff; struct index *hunks; struct input in; size_t last, nxt = 0, nf = 0; uint32_t *nh; int hl, rc = FSL_RC_OK; enum stash_opt choice = NO_CHOICE; bool lastfile = false; hunks = &s->scx.hunk; nh = &hunks->idx; in = (struct input){NULL, NULL, INPUT_ALPHA, SR_CLREOL, "X"}; /* Iterate hunks and prompt user to stash or keep in ckout. */ while (!rc && *nh < hunks->n) { char **ans = NULL; char prompt[64]; int len; enum { NONE, DOWN, UP, BOTH } scroll; /* * If not yet in the last file of the diff and the next hunk * to choose is in the next file, reset any sticky file choice. */ if (!lastfile && nxt && hunks->lineno[*nh] >= nxt) { nxt = 0; *in.buf = 'X'; choice = NO_CHOICE; } /* * Place hunk header, or file Index line if showing the * first hunk in the file, at the top of the screen. */ s->first_line_onscreen = hunks->lineno[*nh] + 1; if (s->dlines[hunks->lineno[*nh] - 5] == LINE_DIFF_INDEX) s->first_line_onscreen = hunks->lineno[*nh] - 5; s->selected_line = 1; hl = s->first_line_onscreen; /* current hunk start line */ redraw: rc = view->show(view); if (rc) return rc; updatescreen(view->window, true, true); keypad(view->window, false); /* don't accept arrow keys */ last = s->last_line_onscreen; len = snprintf(prompt, sizeof(prompt), "[%u/%u] stash this hunk (", hunks->idx + 1, hunks->n); if (len < 0 || (len > 0 && (size_t)len >= sizeof(prompt))) return RC(fsl_errno_to_rc(errno, FSL_RC_RANGE), "snprintf"); scroll = NONE; /* Enable 'b,m' answers if hunk occupies multiple pages. */ if (s->first_line_onscreen > hl) scroll = UP; if ((*nh < hunks->n - 1 && ((nf == s->index.n - 1 && hunks->lineno[*nh] >= s->index.lineno[nf] + 5) || last < s->index.lineno[nf]) && last < hunks->lineno[*nh + 1]) || (*nh == hunks->n - 1 && last < s->nlines)) scroll = scroll ? BOTH : DOWN; rc = generate_prompt(&ans, prompt, sizeof(prompt), scroll); if (rc) { free_answers(ans); return RC(rc, "generate_prompt(%s)", STRINGIFY(scroll)); } in.prompt = prompt; do { if (choice || valid_input(in.buf, ans)) break; /* ongoing persistent answer */ rc = fnc_prompt_input(view, &in); if (*in.buf == '?' || *in.buf == 'H' || (int)*in.buf == (KEY_F(1))) rc = stash_help(view, scroll); } while (!rc && !choice && !valid_input(in.buf, ans)); free_answers(ans); if (*in.buf == 'm' || *in.buf == 'b') { /* scroll pgup/pgdn */ s->first_line_onscreen = *in.buf == 'm' ? s->last_line_onscreen : MAX(hl, s->first_line_onscreen - view->nlines + 2); *in.buf = 'X'; goto redraw; } set_choice(s, stashing, &in, hunks, nh, &nxt, &nf, &lastfile, &choice); } return rc; } /* * Construct a set of valid answers based on scroll and assign to *ptr, and * generate the corresponding prompt containing the available answers from * which to choose. *ptr must eventually be disposed of by the caller. */ static int generate_prompt(char ***ptr, char *prompt, size_t sz, short scroll) { char **ans; char *opts[10] = {"b", "m", "y", "n", "a", "k", "A", "K", "", NULL}; size_t n, oi, ai = 0; /* Set valid answers. */ switch (scroll) { case 3: /* BOTH "bmynakAK?" */ oi = 0; n = 10; break; case 2: /* UP "bynakAK?" */ opts[0] = "m"; opts[1] = "b"; /* FALL THROUGH */ case 1: /* DOWN "mynakAK?" */ oi = 1; n = 9; break; case 0: /* NONE "ynakAK?" */ oi = 2; n = 8; break; } /* Generate valid answers array. */ ans = calloc(n, sizeof(*ans)); if (ans == NULL) return RC(FSL_RC_ERROR, "calloc"); while (ai < n) ans[ai++] = fsl_strdup(opts[oi++]); /* Generate prompt string. */ for (ai = 0; ai < n - 2; ++ai) { char *t = fsl_mprintf("%s%c", ans[ai], ','); if (t == NULL) return RC(FSL_RC_ERROR, "fsl_mprintf"); if (fsl_strlcat(prompt, t, sz) >= sz) return RC(FSL_RC_RANGE, "fsl_strlcat(%s, %s, %lu)", prompt, t, sz); fsl_free(t); } if (fsl_strlcat(prompt, "?)? [y] ", sz) >= sz) return RC(FSL_RC_RANGE, "fsl_strlcat(%s, %s, %lu)", prompt, "?)? [y] ", sz); *ptr = ans; return FSL_RC_OK;; } /* * Return true if in is found in valid, else return false. * valid must be terminated with a sentinel (NULL) pointer. */ static bool valid_input(const char *in, char **valid) { size_t idx; for (idx = 0; valid[idx]; ++idx) if (!fsl_strcmp(in, valid[idx])) return true; return false; } /* * Set or clear the corresponding bit in bitstring s->scx.stash based on the * answer in in.buf. If a persistent choice was made, assign it to *ch. Advance * next file *nf in relation to next hunk *nh, and assign next file start line * to *nxt. If the current file is the last file, set *lastfile. Advance *nh. */ static void set_choice(struct fnc_diff_view_state *s, bool *stashing, struct input *in, struct index *hunks, uint32_t *nh, size_t *nxt, size_t *nf, bool *lastfile, enum stash_opt *ch) { struct index *files; unsigned char *bs; files = &s->index; bs = s->scx.stash; /* Update bitstring based on ongoing persistent or single hunk choice */ if (*in->buf != 'n' && *in->buf != 'k' && *in->buf != 'K') { BIT_SET(bs, *nh); /* stash hunk */ *stashing = true; } else /* 'n' 'k' 'K' */ BIT_CLR(bs, *nh); /* keep hunk in ckout */ /* Check for a new persistent choice. */ if (*in->buf == 'a') *ch = STASH_FILE; else if (*in->buf == 'k') *ch = KEEP_FILE; else if (*in->buf == 'A') *ch = STASH_DIFF; else if (*in->buf == 'K') *ch = KEEP_DIFF; if (!*ch) *in->buf = 'X'; /* no persistent choice; reset */ /* We're in the last file, so any persistent choice can stick */ if (*nf == files->n - 1 && hunks->lineno[*nh] >= files->lineno[*nf]) *lastfile = true; if ((*ch == STASH_FILE || *ch == KEEP_FILE) && *in->buf != 'y' && *in->buf != 'n') { *nxt = files->lineno[MIN(*nf + (*nf ? 0 : 1), files->n - 1)] + 5; *in->buf = *ch == STASH_FILE ? 'y': 'n'; } /* Update next file in relation to the next hunk. */ while (*nf < files->n - 1 && *nh < hunks->n - 1 && files->lineno[*nf] + 5 <= hunks->lineno[*nh + 1]) ++(*nf); ++(*nh); } static void free_answers(char **ans) { size_t i = 0; while (ans[i]) fsl_free(ans[i++]); fsl_free(ans); } /* * Revert the current checkout. If renames is set, don't revert files that are * renamed with _no_ changes. If scan is set, scan for changes before reverting. */ static int revert_ckout(bool renames, bool scan) { fsl_cx *const f = fcli_cx(); fsl_db *db = fsl_needs_ckout(f); fsl_stmt q = fsl_stmt_empty; fsl_ckout_revert_opt opt = fsl_ckout_revert_opt_empty; fsl_id_bag idbag = fsl_id_bag_empty; int rc = FSL_RC_OK; rc = fsl_ckout_vfile_ids(fcli.f, 0, &idbag, ".", false, true); if (!rc && renames) { /* * XXX Don't revert renamed files with _NO_ changes because * we need to stash them, but there's no way to apply them * with a diff as there's no hunks; however, we can apply our * stash patch to the checkout with renames in the vfile. */ rc = fsl_db_prepare(db, &q, "SELECT id, origname, pathname" " FROM vfile WHERE origname IS NOT NULL" " AND origname<>pathname AND chnged=0"); if (!rc) rc = fsl_stmt_each(&q, rm_vfile_renames_cb, &idbag); fsl_stmt_finalize(&q); } opt.scanForChanges = scan; opt.filename = NULL; opt.callback = NULL; opt.callbackState = NULL; opt.vfileIds = &idbag; if (!rc) rc = fsl_ckout_revert(fcli_cx(), &opt); fsl_id_bag_clear(&idbag); return rc; } static int rm_vfile_renames_cb(fsl_stmt *stmt, void *state) { fsl_id_bag *bag = (fsl_id_bag *)state; const char *ogname = fsl_stmt_g_text(stmt, 1, NULL); const char *name = fsl_stmt_g_text(stmt, 2, NULL); fsl_id_t id = fsl_stmt_g_id(stmt, 0); fsl_id_bag_remove(bag, id); f_out("[s>] %s -> %s\n", ogname, name); return FSL_RC_OK; } /* * Scan patch(1) file found at path for valid patches, and populate patch * context pcx with an fnc_patch_file queue of all diffed files, each * containing an fnc_patch_hunk queue representing the file's changes. Iterate * the file queue and apply each fnc_patch_file to the checkout. */ static int fnc_patch(struct patch_cx *pcx, const char *path) { struct fnc_patch_file *patch, *t; FILE *fp; int fd, rc = FSL_RC_OK; fd = open(path, O_RDONLY | O_CLOEXEC); if (fd == -1) return RC(fsl_errno_to_rc(errno, FSL_RC_IO), "open(%s)", path); if ((fp = fdopen(fd, "r")) == NULL) return RC(fsl_errno_to_rc(errno, FSL_RC_IO), "fdopen"); pcx->report_cb = patch_reporter; STAILQ_INIT(&pcx->head); /* queue of files to be patched */ rc = scan_patch(pcx, fp); /* read patch file to construct patch ADTs */ fclose(fp); close(fd); if (rc) return rc; STAILQ_FOREACH_SAFE(patch, &pcx->head, entries, t) { pcx->pf = patch; rc = apply_patch(pcx, patch, false); STAILQ_REMOVE(&pcx->head, patch, fnc_patch_file, entries); free_patch(patch); if (rc) break; } return rc; } /* * Scan patch file fp to construct an fnc_patch_file pf for each versioned * file found with changes, and queue them in pcx->head. Parse each pf for * valid hunks, and queue them in pf->head to produce a hierarchical ADT of * files->hunks->lines to be patched. */ static int scan_patch(struct patch_cx *pcx, FILE *fp) { int rc = FSL_RC_OK; bool eof = false, patch_found = false; while (!feof(fp)) { struct fnc_patch_file *pf = NULL; rc = find_patch_file(&pf, pcx, fp); if (rc) { fsl_free(pf); goto end; } STAILQ_INIT(&pf->head); /* queue of hunks per file to patch */ patch_found = true; for (;;) { struct fnc_patch_hunk *h = NULL; rc = parse_hunk(&h, fp, pcx->context, &eof); if (rc) goto end; if (h) STAILQ_INSERT_TAIL(&pf->head, h, entries); if (eof) { STAILQ_INSERT_TAIL(&pcx->head, pf, entries); break; } } } end: if (rc == NO_PATCH && patch_found) rc = FSL_RC_OK; /* ignore valid case of index with no hunks */ return rc; } /* * Find the next versioned file in patch(1) file fp by parsing the path from * the diff ---/+++ header line. If found, construct and assign a new * fnc_patch_file to *ptr, which must eventually be disposed of by the caller. */ static int find_patch_file(struct fnc_patch_file **ptr, struct patch_cx *pcx, FILE *fp) { struct fnc_patch_file *pf = NULL; char *old = NULL, *new = NULL; char *line = NULL; size_t linesize = 0; ssize_t linelen; int create, rc = FSL_RC_OK; pf = calloc(1, sizeof(*pf)); if (pf == NULL) return RC(FSL_RC_ERROR, "fsl_malloc"); while ((linelen = getline(&line, &linesize, fp)) != -1) { if (!strncmp(line, "--- ", 4)) { fsl_free(old); rc = parse_filename(line + 4, &old, 0); } else if (!strncmp(line, "+++ ", 4)) { fsl_free(new); rc = parse_filename(line + 4, &new, 0); } if (rc) break; if (!strncmp(line, "@@ -", 4)) { create = !fsl_strncmp(line + 4, "0,0", 3); if ((old == NULL && new == NULL) || (!create && old == NULL)) rc = PATCH_MALFORMED; else rc = set_patch_paths(pf, old, new); if (rc) break; /* Rewind to previous line. */ if (fseek(fp, linelen * -1, SEEK_CUR) == -1) rc = RC(fsl_errno_to_rc(errno, FSL_RC_IO), "fseek"); break; } } if (!rc) *ptr = pf; fsl_free(old); fsl_free(new); fsl_free(line); if (ferror(fp) && !rc) rc = RC(fsl_errno_to_rc(errno, FSL_RC_IO), "getline"); if (feof(fp) && !rc) rc = NO_PATCH; return rc; } static int parse_filename(const char *at, char **name, int strip) { char *fullname, *t; int l, tab, rc = FSL_RC_OK; *name = NULL; if (*at == '\0') return rc; while (isspace((unsigned char)*at)) ++at; /* If path is /dev/null, file is being removed or created. */ if (!fsl_strncmp(at, NULL_DEVICE, NULL_DEVICELEN)) return rc; t = fsl_strdup(at); if (t == NULL) return RC(FSL_RC_ERROR, "fsl_strdup"); *name = fullname = t; tab = strchr(t, '\t') != NULL; /* Strip path components and NUL-terminate. */ for (l = strip; *t != '\0' && ((tab && *t != '\t') || !isspace((unsigned char)*t)); ++t) { if (t[0] == '/' && t[1] != '/' && t[1] != '\0') if (--l >= 0) *name = t + 1; } *t = '\0'; *name = fsl_strdup(*name); fsl_free(fullname); if (*name == NULL) return RC(FSL_RC_ERROR, "fsl_strdup"); return rc; } static int set_patch_paths(struct fnc_patch_file *pf, const char *old, const char *new) { int rc = FSL_RC_OK; size_t ret = 0; /* Prefer the new name if it's neither /dev/null nor a renamed file. */ if (new != NULL && old != NULL && !fsl_strcmp(new, old)) ret = fsl_strlcpy(pf->old, new, sizeof(pf->old)); else if (old != NULL) ret = fsl_strlcpy(pf->old, old, sizeof(pf->old)); if (ret >= sizeof(pf->old)) rc = RC(FSL_RC_RANGE, "fsl_strlcpy"); if (!rc && new != NULL) ret = fsl_strlcpy(pf->new, new, sizeof(pf->new)); if (!rc && ret >= sizeof(pf->new)) rc = RC(FSL_RC_RANGE, "fsl_strlcpy"); return rc; } /* * Parse patch(1) file fp and extract the changed lines data from each hunk * header to construct an fnc_patch_hunk object and assign it to *ptr, which * must eventually be dispoed of by the caller. Iterate the section of changed * lines, and push each +/- and context line onto the hdr->lines array, which * must also be disposed of by the caller. */ static int parse_hunk(struct fnc_patch_hunk **ptr, FILE *fp, uint8_t context, bool *eof) { struct fnc_patch_hunk *hdr = NULL; char *line = NULL, ch; size_t linesize = 0; ssize_t linelen; long leftold, leftnew; int rc = FSL_RC_OK; linelen = getline(&line, &linesize, fp); if (linelen == -1) { *eof = true; /* end of this versioned file in the patch file */ goto end; } if ((hdr = calloc(1, sizeof(*hdr))) == NULL) { rc = RC(FSL_RC_ERROR, "calloc"); goto end; } hdr->lines = NULL; rc = parse_hdr(line, eof, hdr); if (rc) goto end; if (*eof) { if (fseek(fp, linelen * -1, SEEK_CUR) == -1) rc = RC(fsl_errno_to_rc(errno, FSL_RC_IO), "fseek"); goto end; } leftold = hdr->oldlines; leftnew = hdr->newlines; while (leftold > 0 || leftnew > 0) { linelen = getline(&line, &linesize, fp); if (linelen == -1) { if (ferror(fp)) { rc = RC(fsl_errno_to_rc(errno, FSL_RC_IO), "getline"); goto end; } if (leftold < 3 && leftnew < 3) { *eof = true; /* trim trailing newlines */ break; } rc = PATCH_TRUNCATED; goto end; } if (line[linelen - 1] == '\n') line[linelen - 1] = '\0'; ch = *line; if (ch == '\t' || ch == '\0') ch = ' '; /* leading space got eaten */ switch (ch) { case '-': leftold--; break; case ' ': leftold--; leftnew--; break; case '+': leftnew--; break; default: rc = PATCH_MALFORMED; goto end; } if (leftold < 0 || leftnew < 0) { rc = PATCH_MALFORMED; goto end; } rc = pushline(hdr, line); if (rc) goto end; if ((ch == '-' && leftold == 0) || (ch == '+' && leftnew == 0)) { rc = peek_special_line(hdr, fp, ch == '+'); if (rc) goto end; } } end: /* * XXX Check for hdr->lines as fnc diff adds a trailing empty newline * between diffs (i.e., before the next file's Index line), which, if * added, will produce a false negative in patch_file(). */ if (!rc && hdr && hdr->lines) *ptr = hdr; else fsl_free(hdr); fsl_free(line); return rc; } /* * Parse hunk header line and assign corresponding new and old lines to * hdr->{old,new}lines, respectively. */ static int parse_hdr(char *s, bool *eof, struct fnc_patch_hunk *hdr) { int rc = FSL_RC_OK; *eof = false; if (fsl_strncmp(s, "@@ -", 4)) { *eof = true; return rc; } s += 4; if (!*s) return rc; rc = strtolnum(&s, &hdr->oldfrom); if (!rc && *s == ',') { s++; rc = strtolnum(&s, &hdr->oldlines); } else hdr->oldlines = 1; if (rc) return rc; if (*s == ' ') ++s; if (*s != '+' || !*++s) return PATCH_MALFORMED; rc = strtolnum(&s, &hdr->newfrom); if (!rc && *s == ',') { s++; rc = strtolnum(&s, &hdr->newlines); } else hdr->newlines = 1; if (rc) return rc; if (*s == ' ') ++s; if (*s != '@') return PATCH_MALFORMED; if (hdr->oldfrom >= LONG_MAX - hdr->oldlines || hdr->newfrom >= LONG_MAX - hdr->newlines || hdr->oldlines >= LONG_MAX - hdr->newlines - 1) rc = PATCH_MALFORMED; if (hdr->oldlines == 0) hdr->oldfrom++; return rc; } static int strtolnum(char **str, int_least32_t *n) { char *cmp, *p, c; const char *errstr; #ifdef __OpenBSD__ cmp = NULL; /* strtonum() assigns last arg to NULL on success */ #else cmp = "\0"; /* strtol() assigns 2nd arg to NUL on success */ #endif for (p = *str; isdigit((unsigned char)*p); ++p) /* nop */; c = *p; *p = '\0'; *n = strtonum(*str, 0, LONG_MAX, &errstr); if ((errstr && *errstr != *cmp) || (!errstr && errstr != cmp)) return PATCH_MALFORMED; *p = c; *str = p; return FSL_RC_OK; } static int pushline(struct fnc_patch_hunk *hdr, const char *line) { static int rc = FSL_RC_OK; char *p = NULL; if (*line != '+' && *line != '-' && *line != ' ' && *line != '\\') { if ((p = fsl_mprintf(" %s", line)) == NULL) return RC(FSL_RC_ERROR, "fsl_mprintf"); line = p; } rc = alloc_hunk_line(hdr, line); fsl_free(p); return rc; } static int alloc_hunk_line(struct fnc_patch_hunk *h, const char *line) { void *t; size_t newcap; if (h->nlines == h->cap) { if ((newcap = h->cap * 1.5) == 0) newcap = 16; t = fsl_realloc(h->lines, newcap * sizeof(char *)); if (t == NULL) return RC(FSL_RC_ERROR, "fsl_realloc"); h->lines = t; memset(h->lines + h->cap, 0, sizeof(*h->lines) * (newcap - h->cap)); h->cap = newcap; } if ((t = fsl_strdup(line)) == NULL) return RC(FSL_RC_ERROR, "fsl_strdup"); h->lines[h->nlines++] = t; return FSL_RC_OK; } static int peek_special_line(struct fnc_patch_hunk *hdr, FILE *fp, int send) { int ch, rc = FSL_RC_OK; ch = fgetc(fp); if (ch != EOF && ch != '\\') { ungetc(ch, fp); return rc; } if (ch == '\\' && send) { rc = pushline(hdr, "\\"); if (rc) return rc; } while (ch != EOF && ch != '\n') ch = fgetc(fp); if (ch != EOF || feof(fp)) return rc; return RC(FSL_RC_IO, "fgetc"); } static int apply_patch(struct patch_cx *pcx, struct fnc_patch_file *p, bool nop) { const char *newpath, *oldpath; char *parent = NULL, *tmppath = NULL, *template = NULL; FILE *tmp = NULL; int renamed = 0, rc = FSL_RC_OK; #define DFLT_FILEMODE (S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) #define DFLT_DIRMODE (S_IFDIR | S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) mode_t mode = DFLT_FILEMODE; newpath = p->new; oldpath = p->old; if (oldpath[0]) renamed = fsl_strcmp(oldpath, newpath); if ((template = fsl_mprintf("%sfnc-patch", fcli_cx()->ckout.dir)) == NULL) { rc = RC(FSL_RC_ERROR, "fsl_mprintf"); goto end; } if (!nop) rc = fnc_open_tmpfile(&tmppath, &tmp, template, NULL); if (!rc) rc = patch_file(p, oldpath, tmp, nop, &mode); if (rc || nop) goto end; if (p->old[0] && !p->new[0]) { /* file deleted */ rc = fnc_rm_vfile(pcx, oldpath, false); goto end; } if (fchmod(fileno(tmp), mode) == -1) { rc = RC(fsl_errno_to_rc(errno, FSL_RC_ACCESS), "fchmod: %s %d", newpath, mode); goto end; } fclose(tmp); if (rename(tmppath, newpath) == -1) { if (errno != ENOENT) { rc = RC(fsl_errno_to_rc(errno, FSL_RC_ACCESS), "rename(%s, %s)", tmppath, newpath); goto end; } rc = fsl_mkdir_for_file(newpath, true); if (rc || rename(tmppath, newpath) == -1) { rc = RC(fsl_errno_to_rc(errno, FSL_RC_ACCESS), "rename(%s, %s)", tmppath, newpath); goto end; } } if (renamed) { /* * XXX Removing the original name versioned file and adding * the renamed version produces a verbose diff with "duplicate" * entries showing the entire file contents of the previous * name versioned file deleted, and the entire file contents, * including any edits, added under the new name. This makes it * difficult to discern changes. By performing a rename in the * vfile table, we get a more useful diff with rename context. */ /* rc = fnc_rm_vfile(pcx, oldpath, false); */ /* if (!rc) */ /* rc = fnc_add_vfile(pcx, newpath, false); */ rc = fnc_rename_vfile(oldpath, newpath); if (!rc && pcx->report) rc = patch_reporter(p, oldpath, newpath, "~"); } else if (!p->old[0]) { /* file added */ rc = fnc_add_vfile(pcx, newpath, false); /* rc = fnc_execp((const char *const []) */ /* {"fossil", "add", newpath, (char *)NULL}, 10); */ } else if (pcx->report) rc = patch_reporter(p, oldpath, newpath, "~"); end: fsl_free(parent); fsl_free(template); if (tmppath != NULL) unlink(tmppath); fsl_free(tmppath); return rc; } /* * Open new tmp file at basepath, which is expected to be an absolute path, * with optional suffix. The final filename will be "basepath-XXXXXX[SUFFIX]" * where XXXXXX is a random character string populated by mkstemp(3) (or * mkstemps(3) if suffix is not NULL). */ static int fnc_open_tmpfile(char **path, FILE **outfile, const char *basepath, const char *suffix) { int fd, rc = FSL_RC_OK; *outfile = NULL; if ((*path = fsl_mprintf("%s-XXXXXX%s", basepath, suffix ? suffix : "")) == NULL) return RC(FSL_RC_ERROR, "fsl_mprintf"); if (suffix) fd = mkstemps(*path, fsl_strlen(suffix)); else fd = mkstemp(*path); if (fd == -1) { rc = RC(fsl_errno_to_rc(errno, FSL_RC_IO), "%s(%s)", suffix ? "mkstemps" : "mkstemp", *path); fsl_free(*path); *path = NULL; return rc; } *outfile = fdopen(fd, "w+"); if (*outfile == NULL) { rc = RC(fsl_errno_to_rc(errno, FSL_RC_IO), "fdopen: %s", *path); fsl_free(*path); *path = NULL; } return rc; } /* * Apply patch file p to the versioned file at path by iterating and applying * each hunk from p->head and creating thepatched file in tmp. Upon success, * copy to the versioned file at path. */ static int patch_file(struct fnc_patch_file *p, const char *path, FILE *tmp, int nop, mode_t *mode) { struct fnc_patch_hunk *h; struct stat sb; FILE *orig; char *line = NULL; off_t copypos, pos; ssize_t linelen; size_t linesize = 0; long lineno = 0; int rc = FSL_RC_OK; if (!p->old[0]) { /* create new versioned file */ h = STAILQ_FIRST(&p->head); if (h == NULL || STAILQ_NEXT(h, entries) != NULL) return PATCH_MALFORMED; if (nop) return rc; return apply_hunk(tmp, h, &lineno); } if ((orig = fopen(path, "r")) == NULL) { rc = RC(fsl_errno_to_rc(errno, FSL_RC_IO), "fopen(%s, \"r\")", path); goto end; } if (fstat(fileno(orig), &sb) == -1) { rc = RC(fsl_errno_to_rc(errno, FSL_RC_IO), "fstat(%s)", path); goto end; } *mode = sb.st_mode; copypos = 0; STAILQ_FOREACH(h, &p->head, entries) { if (h->lines == NULL) break; retry: rc = locate_hunk(orig, h, &pos, &lineno); if (rc && rc == HUNK_FAILED) h->rc = rc; if (rc) goto end; if (!nop) rc = copyfile(tmp, orig, copypos, pos); if (rc) goto end; copypos = pos; rc = test_hunk(orig, h); if (rc && rc == HUNK_FAILED) { /* * Retry applying the hunk by starting the search * after the previous partial match. */ if (fseek(orig, pos, SEEK_SET) == -1) { rc = RC(fsl_errno_to_rc(errno, FSL_RC_IO), "fseek"); goto end; } linelen = getline(&line, &linesize, orig); if (linelen == -1) { rc = RC(fsl_errno_to_rc(errno, FSL_RC_IO), "getline"); goto end; } ++lineno; goto retry; } if (rc) goto end; if (lineno + 1 != h->oldfrom) h->offset = lineno + 1 - h->oldfrom; if (!nop) rc = apply_hunk(tmp, h, &lineno); if (rc) goto end; copypos = ftello(orig); if (copypos == -1) { rc = RC(fsl_errno_to_rc(errno, FSL_RC_IO), "ftello"); goto end; } } if (!p->new[0] && sb.st_size != copypos) { h = STAILQ_FIRST(&p->head); rc = h->rc = HUNK_FAILED; } else if (!nop && !feof(orig)) /* success! copy to versioned file */ rc = copyfile(tmp, orig, copypos, -1); end: if (orig != NULL) fclose(orig); return rc; } static int apply_hunk(FILE *tmp, struct fnc_patch_hunk *h, long *lineno) { size_t i = 0; for (i = 0; i < h->nlines; ++i) { switch (*h->lines[i]) { case ' ': if (fprintf(tmp, "%s\n", h->lines[i] + 1) < 0) return RC(fsl_errno_to_rc(errno, FSL_RC_IO), "fprintf"); /* fallthrough */ case '-': (*lineno)++; break; case '+': if (fprintf(tmp, "%s", h->lines[i] + 1) < 0) return RC(fsl_errno_to_rc(errno, FSL_RC_IO), "fprintf"); if (i != h->nlines - 1 || !h->nonl) { if (fprintf(tmp, "\n") < 0) return RC(fsl_errno_to_rc(errno, FSL_RC_IO), "fprintf"); } break; } } return FSL_RC_OK; } static int locate_hunk(FILE *orig, struct fnc_patch_hunk *h, off_t *pos, long *lineno) { char *line = NULL; char mode = *h->lines[0]; ssize_t linelen; size_t linesize = 0; off_t match = -1; long match_lineno = -1; int rc = FSL_RC_OK; for (;;) { linelen = getline(&line, &linesize, orig); if (linelen == -1) { if (ferror(orig)) rc = RC(fsl_errno_to_rc(errno, FSL_RC_IO), "getline"); else if (match == -1) rc = HUNK_FAILED; break; } if (line[linelen - 1] == '\n') line[linelen - 1] = '\0'; (*lineno)++; if ((mode == ' ' && !fsl_strcmp(h->lines[0] + 1, line)) || (mode == '-' && !fsl_strcmp(h->lines[0] + 1, line)) || (mode == '+' && *lineno == h->oldfrom)) { match = ftello(orig); if (match == -1) { rc = RC(fsl_errno_to_rc(errno, FSL_RC_IO), "ftello"); break; } match -= linelen; match_lineno = (*lineno) - 1; } if (*lineno >= h->oldfrom && match != -1) break; } if (!rc) { *pos = match; *lineno = match_lineno; if (fseek(orig, match, SEEK_SET) == -1) rc = RC(fsl_errno_to_rc(errno, FSL_RC_IO), "fseek"); } fsl_free(line); return rc; } /* * Starting at copypos until pos, copy data from orig into tmp. * If pos is -1, copy until EOF. */ static int copyfile(FILE *tmp, FILE *orig, off_t copypos, off_t pos) { char buf[BUFSIZ]; size_t len, r, w; if (fseek(orig, copypos, SEEK_SET) == -1) return RC(fsl_errno_to_rc(errno, FSL_RC_IO), "fseek"); while (pos == -1 || copypos < pos) { len = sizeof(buf); if (pos > 0) len = MIN(len, (size_t)pos - copypos); r = fread(buf, 1, len, orig); if (r != len && ferror(orig)) return RC(fsl_errno_to_rc(errno, FSL_RC_IO), "fread"); w = fwrite(buf, 1, r, tmp); if (w != r) return RC(fsl_errno_to_rc(errno, FSL_RC_IO), "fwrite"); copypos += len; if (r != len && feof(orig)) { if (pos == -1) return FSL_RC_OK; return HUNK_FAILED; } } return FSL_RC_OK; } static int test_hunk(FILE *orig, struct fnc_patch_hunk *h) { char *line = NULL; ssize_t linelen; size_t linesize = 0, i = 0; int rc = FSL_RC_OK; for (i = 0; i < h->nlines; ++i) { switch (*h->lines[i]) { case '+': continue; case ' ': case '-': linelen = getline(&line, &linesize, orig); if (linelen == -1) { if (ferror(orig)) rc = RC(fsl_errno_to_rc(errno, FSL_RC_IO), "getline"); else rc = HUNK_FAILED; goto end; } if (line[linelen - 1] == '\n') line[linelen - 1] = '\0'; if (fsl_strcmp(h->lines[i] + 1, line)) { rc = HUNK_FAILED; goto end; } break; } } end: fsl_free(line); return rc; } static int fnc_add_vfile(struct patch_cx *pcx, const char *path, bool nop) { fsl_cx *const f = fcli_cx(); fsl_db *db; fsl_ckout_manage_opt opt = fsl_ckout_manage_opt_empty; int rc = FSL_RC_OK; bool trans = false; db = fsl_needs_ckout(f); if (!db) goto end; rc = fsl_db_transaction_begin(db); if (rc) { fsl_cx_uplift_db_error(f, db); goto end; } trans = true; opt.filename = path; opt.relativeToCwd = false; /* relative repo root paths from fnc diff */ opt.checkIgnoreGlobs = true; /* XXX make an 'fnc stash' option? */ opt.callbackState = pcx; /* patch context and report cb */ opt.callback = fnc_addvfile_cb; rc = fsl_ckout_manage(f, &opt); if (rc) goto end; if (nop) { f_out("dry run...rolling back transaction.\n"); fsl_db_transaction_rollback(db); } else rc = fsl_db_transaction_end(db, false); trans = false; end: if (trans) { const int rc2 = fsl_db_transaction_end(db, true); rc = rc ? rc : rc2; } return rc; } static int fnc_addvfile_cb(fsl_ckout_manage_state const *cx, bool *include) { struct patch_cx *pcx = cx->opt->callbackState; int rc = FSL_RC_OK; if (pcx->report) rc = pcx->report_cb(pcx->pf, pcx->pf->old, pcx->pf->new, "+"); if (!rc) *include = true; return rc; } static int fnc_rm_vfile(struct patch_cx *pcx, const char *path, bool nop) { fsl_cx *const f = fcli_cx(); fsl_db *db; fsl_ckout_unmanage_opt opt = fsl_ckout_unmanage_opt_empty; int rc = FSL_RC_OK; bool trans = false; db = fsl_cx_db_ckout(f); if (!db) { rc = fsl_cx_err_set(f, FSL_RC_NOT_A_CKOUT, "ckout required"); goto end; } rc = fsl_cx_transaction_begin(f); if (rc) goto end; trans = true; opt.filename = path; opt.scanForChanges = false; opt.vfileIds = NULL; opt.relativeToCwd = false; /* relative repo root paths from fnc diff */ opt.callback = fnc_rmvfile_cb; opt.callbackState = pcx; rc = fsl_ckout_unmanage(f, &opt); if (rc) goto end; if (nop) { f_out("dry run...rolling back transaction.\n"); fsl_db_transaction_rollback(db); } else rc = fsl_db_transaction_end(db, false); trans = false; end: if (trans) { const int rc2 = fsl_db_transaction_end(db, true); rc = rc ? rc : rc2; } return rc; } static int fnc_rmvfile_cb(fsl_ckout_unmanage_state const *cx) { struct patch_cx *pcx = cx->opt->callbackState; int rc = FSL_RC_OK; if (pcx->report) rc = pcx->report_cb(pcx->pf, pcx->pf->old, pcx->pf->new, "-"); return rc; } static int fnc_rename_vfile(const char *oldpath, const char *newpath) { fsl_cx *const f = fcli_cx(); fsl_db *db = fsl_needs_ckout(f); int rc = FSL_RC_OK; rc = fsl_db_exec_multi(db, "UPDATE vfile SET pathname='%q', origname='%q'" " WHERE pathname='%q' %s AND vid=%d", newpath, oldpath, oldpath, fsl_cx_filename_collation(f), f->ckout.rid); if (rc) fsl_file_unlink(newpath); else { const char *dir = getdirname(oldpath, -1, false); rc = fsl_file_unlink(oldpath); if (!fsl_dir_is_empty(dir)) rc = fsl_rmdir(dir); } return rc; } static int patch_reporter(struct fnc_patch_file *p, const char *old, const char *new, char *status) { struct fnc_patch_hunk *h; int rc = FSL_RC_OK; rc = patch_report(old, new, status, 0, 0, 0, 0, 0, 0); if (rc) return rc; STAILQ_FOREACH(h, &p->head, entries) { if (h->offset == 0 && !h->rc) continue; rc = patch_report(old, new, 0, h->oldfrom, h->oldlines, h->newfrom, h->newlines, h->offset, h->rc); } return rc; } static int patch_report(const char *old, const char *new, char *status, long oldfrom, long oldlines, long newfrom, long newlines, long offset, enum fnc_patch_rc hunkrc) { const char *path = !new[0] ? old : new; while (*path == '/') path++; if (old[0] && new[0] && fsl_strcmp(old, new)) printf("[s%s] %s -> %s\n", status, old, new); else printf("[s%s] %s\n", status, path); if (offset != 0 || hunkrc) { printf("@@ -%ld,%ld +%ld,%ld @@ ", oldfrom, oldlines, newfrom, newlines); if (hunkrc) printf("error %d: %s\n", hunkrc, STRINGIFY(hunkrc)); else printf("applied with offset %ld\n", offset); } fflush(stdout); return FSL_RC_OK; } static void free_patch(struct fnc_patch_file *p) { struct fnc_patch_hunk *h; size_t i; while (!STAILQ_EMPTY(&p->head)) { h = STAILQ_FIRST(&p->head); STAILQ_REMOVE_HEAD(&p->head, entries); for (i = 0; i < h->nlines; ++i) { fsl_free(h->lines[i]); h->lines[i] = NULL; } fsl_free(h->lines); fsl_free(h); h = NULL; } fsl_free(p); } /* * exec(2) arg[0] with args arg after a fork(2). Optionally wait wait seconds * for child process to complete; set to zero or a negative integer to not wait. */ #if 0 static int fnc_execp(const char *const *arg, const int wait) { pid_t pid; int status, timeout, rc = FSL_RC_OK; pid = fork(); if (pid == -1) return RC(fsl_errno_to_rc(errno, FSL_RC_ACCESS), "fork"); else if (pid == 0) if (execvp(arg[0], (char *const *)arg) == -1) return RC(fsl_errno_to_rc(errno, FSL_RC_ACCESS), "ecexve"); if (wait < 1) return rc; timeout = wait; while (waitpid(pid , &status , WNOHANG) == 0) { if ( --timeout < 0 ) return RC(FSL_RC_RANGE, "timeout for child [%d]", pid); sleep(1); } if (WIFEXITED(status) != 1 || WEXITSTATUS(status) != 0) return RC(fsl_errno_to_rc(errno, FSL_RC_ERROR), "%s: WEXITSTATUS %d | WIFEXITED %d [status %d]", arg[0], WEXITSTATUS(status), WIFEXITED(status), status); return rc; } #endif /* * Create new stash of changes in checkout vid with stash message msg. */ static int f__stash_create(const char *msg, int vid) { fsl_cx *const f = fcli_cx(); fsl_db *db = fsl_needs_ckout(f); int stashid, rc = FSL_RC_OK; rc = f__check_stash_tables(); if (rc) return RC(rc, "check_stash_tables"); stashid = fsl_config_get_int32(f, FSL_CONFDB_CKOUT, 1, "stash-next"); rc = fsl_config_set_id(f, FSL_CONFDB_CKOUT, "stash-next", stashid + 1); if (!rc) rc = fsl_ckout_changes_scan(f); if (rc) return rc; fsl_db_exec_multi(db, "INSERT INTO stash(stashid, vid, hash, comment, ctime)" " VALUES(%d, %d, (SELECT uuid FROM blob WHERE rid = %d)," " %Q, julianday('now'))", stashid, vid, vid, msg); rc = f__stash_path(stashid, vid, "."); return rc; } /* * Check checkout database for up-to-date stash and stashfile tables. Create * or upgrade if needed. */ static int f__check_stash_tables(void) { static const char stashtab[] = "CREATE TABLE IF NOT EXISTS stash(\n" " stashid INTEGER PRIMARY KEY, -- Unique stash identifier\n" " vid INTEGER, -- Legacy baseline RID value. Do not use.\n" " hash TEXT, -- The SHA hash for the baseline\n" " comment TEXT, -- Comment for this stash. Or NULL\n" " ctime TIMESTAMP -- When the stash was created\n" ");\n" "CREATE TABLE IF NOT EXISTS stashfile(\n" " stashid INTEGER REFERENCES stash, -- Stash containing this file\n" " isAdded BOOLEAN, -- True if this file is added\n" " isRemoved BOOLEAN, -- True if this file is deleted\n" " isExec BOOLEAN, -- True if file is executable\n" " isLink BOOLEAN, -- True if file is a symlink\n" " rid INTEGER, -- Legacy baseline RID value. Do not use\n" " hash TEXT, -- Hash for baseline or NULL\n" " origname TEXT, -- Original filename\n" " newname TEXT, -- New name for file at next check-in\n" " delta BLOB, -- Delta from baseline or raw content\n" " PRIMARY KEY(newname, stashid)\n" ");\n" "INSERT OR IGNORE INTO vvar(name,value) VALUES('stash-next',1);\n"; fsl_cx *const f = fcli_cx(); fsl_db *db = fsl_needs_ckout(f); int rc = FSL_RC_OK; if (fsl_db_table_has_column(db, "stashfile", "hash")) { /* * Schema is up-to-date, but an older version of Fossil that * doesn't know about the stash.hash and stashfile.hash columns * may have run since the schema was updated, and added entries * with NULL hash columns. Check for this case, and input any * missing hash values. */ if (fsl_db_g_int32(db, 0, "SELECT hash IS NULL FROM stash " "ORDER BY stashid DESC LIMIT 1")) { rc = fsl_db_exec_multi(db, "UPDATE stash" " SET hash=(SELECT uuid FROM blob" " WHERE blob.rid=stash.vid)" " WHERE hash IS NULL;" "UPDATE stashfile" " SET hash=(SELECT uuid FROM blob" " WHERE blob.rid=stashfile.rid)" " WHERE hash IS NULL AND rid>0;"); } return rc; } if (!fsl_db_table_exists(db, FSL_DBROLE_CKOUT, "stashfile") || !fsl_db_table_exists(db, FSL_DBROLE_CKOUT, "stash")) { /* Tables don't exist; create them from scratch. */ rc = fsl_db_exec(db, "DROP TABLE IF EXISTS stash;"); if (!rc) rc = fsl_db_exec(db, "DROP TABLE IF EXISTS stashfile;"); if (!rc) rc = fsl_db_exec_multi(db, stashtab); return rc; } /* * Tables exist but aren't necessarily current. Upgrade to the latest * format. Assume the 2011-09-01 format that includes the column * stashfile.isLink. Upgrade the PRIMARY KEY change on 2016-10-16 and * the addition of the "hash" columns on 2019-01-19. */ rc = fsl_db_exec_multi(db, "ALTER TABLE stash RENAME TO old_stash;" "ALTER TABLE stashfile RENAME TO old_stashfile;"); if (!rc) rc = fsl_db_exec_multi(db, stashtab); if (!rc) rc = fsl_db_exec_multi(db, "INSERT INTO stash(stashid,vid,hash,comment,ctime)" " SELECT stashid, vid," " (SELECT uuid FROM blob WHERE blob.rid=old_stash.vid)," " comment, ctime FROM old_stash; " "DROP TABLE old_stash;"); if (!rc) rc = fsl_db_exec_multi(db, "INSERT INTO stashfile(stashid, isAdded, isRemoved," " isExec, isLink, rid, hash, origname, newname, delta)" " SELECT stashid, isAdded, isRemoved, isExec, isLink, rid," " (SELECT uuid FROM blob WHERE blob.rid=old_stashfile.rid)," " origname, newname, delta FROM old_stashfile; " "DROP TABLE old_stashfile;"); return rc; } /* * Add file(s) at path to the stash changeset identified by stashid based on * checkout vid. If path is a directory, all files in that dir will be added. * If path is ".", the entire checkout will be stashed from the repository root. */ static int f__stash_path(int stashid, int vid, const char *path) { fsl_cx *const f = fcli_cx(); fsl_db *db = fsl_needs_ckout(f); fsl_buffer sql = fsl_buffer_empty; /* query statement */ fsl_stmt q = fsl_stmt_empty; /* vfile statement */ fsl_stmt ins = fsl_stmt_empty; /* insert statement */ int rc = FSL_RC_OK; rc = fsl_buffer_appendf(&sql, "SELECT deleted, isexe, islink, mrid, pathname," " coalesce(origname,pathname)" " FROM vfile WHERE vid=%d AND (chnged OR deleted OR" " (origname IS NOT NULL AND origname<>pathname) OR mrid==0)", vid); if (!rc && fsl_strcmp(path, ".")) { /* specific file provided */ rc = fsl_buffer_appendf(&sql, " AND (pathname GLOB '%q/*' OR origname GLOB '%q/*'" " OR pathname=%Q OR origname=%Q)", path, path, path, path); } if (rc) return RC(rc, "fsl_buffer_appendf"); fsl_simplify_sql_buffer(&sql); rc = fsl_db_prepare(db, &q, "%s", fsl_buffer_str(&sql)); fsl_buffer_clear(&sql); if (rc) return RC(rc, "fsl_db_prepare(%s): %d", "stash query", vid); rc = fsl_db_prepare(db, &ins, "INSERT INTO stashfile(stashid, isAdded, isRemoved, isExec, isLink," " rid, hash, origname, newname, delta)" "VALUES(%d,:isadd,:isrm,:isexe,:islink,:rid," "(SELECT uuid FROM blob WHERE rid=:rid),:orig,:new,:content)", stashid); if (rc) return RC(rc, "fsl_db_prepare(%s): %d", "stash insert", stashid); while (fsl_stmt_step(&q) == FSL_RC_STEP_ROW) { fsl_buffer content = fsl_buffer_empty; char path[PATH_MAX]; int deleted = fsl_stmt_g_int32(&q, 0); int rid = fsl_stmt_g_int32(&q, 3); const char *name = fsl_stmt_g_text(&q, 4, NULL); const char *ogname = fsl_stmt_g_text(&q, 5, NULL); fsl_strlcpy(path, CKOUTDIR, sizeof(path)); fsl_strlcat(path, name, sizeof(path)); rc = fsl_stmt_bind_int32_name(&ins, ":rid", rid); if (!rc) rc = fsl_stmt_bind_int32_name(&ins, ":isadd", rid==0); if (!rc) rc = fsl_stmt_bind_int32_name(&ins, ":isrm", deleted); if (!rc) rc = fsl_stmt_bind_int32_name(&ins, ":isexe", fsl_stmt_g_int32(&q, 1)); if (!rc) rc = fsl_stmt_bind_int32_name(&ins, ":islink", fsl_stmt_g_int32(&q, 2)); if (rc) { rc = RC(rc, "fsl_stmt_bind_int32_name"); goto end; } rc = fsl_stmt_bind_text_name(&ins, ":orig", ogname, -1, false); if (!rc) rc = fsl_stmt_bind_text_name(&ins, ":new", name, -1, false); if (rc) { rc = RC(rc, "fsl_stmt_bind_text_name"); goto end; } if (!rid) { /* new file */ rc = fsl_buffer_fill_from_filename(&content, path); if (rc) { rc = RC(rc, "fsl_buffer_fill_from_filename(%s)", path); goto end; } rc = fsl_stmt_bind_blob_name(&ins, ":content", content.mem, content.used, false); if (rc) { rc = RC(rc, "fsl_stmt_bind_blob_name"); goto clear_delta; } } else if (deleted) { fsl_buffer_clear(&content); rc = fsl_stmt_bind_null_name(&ins, ":content"); if (rc) { rc = RC(rc, "fsl_stmt_bind_null_name"); goto end; } } else { /* modified file */ fsl_buffer orig = fsl_buffer_empty; fsl_buffer disk = fsl_buffer_empty; rc = fsl_buffer_fill_from_filename(&disk, path); if (rc) { rc = RC(rc, "fsl_buffer_fill_from_filename(%s)", path); goto end; } rc = fsl_content_get(f, rid, &orig); if (rc) { rc = RC(rc, "fsl_content_get(%d)", rid); goto clear_file; } rc = fsl_buffer_delta_create(&orig, &disk, &content); if (rc) { rc = RC(rc, "fsl_buffer_delta_create"); goto clear_file; } rc = fsl_stmt_bind_blob_name(&ins, ":content", content.mem, content.used, false); if (rc) rc = RC(rc, "fsl_stmt_bind_blob_name"); clear_file: fsl_buffer_clear(&orig); fsl_buffer_clear(&disk); } if (rc) goto clear_delta; rc = fsl_stmt_bind_int32_name(&ins, ":islink", fsl_is_symlink(path)); if (rc) rc = RC(rc, "fsl_stmt_bind_int32_name"); else { fsl_stmt_step(&ins); fsl_stmt_reset(&ins); } clear_delta: fsl_buffer_clear(&content); if (rc) goto end; } end: fsl_stmt_finalize(&ins); fsl_stmt_finalize(&q); return rc; } static int reset_diff_view(struct fnc_view *view, bool stay) { struct fnc_diff_view_state *s = &view->state.diff; int n, rc = FSL_RC_OK; n = s->nlines; |
︙ | |||
6423 6424 6425 6426 6427 6428 6429 | 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 | - + | static int set_selected_commit(struct fnc_diff_view_state *s, struct commit_entry *entry) { fsl_free(s->id2); s->id2 = fsl_strdup(entry->commit->uuid); if (s->id2 == NULL) |
︙ | |||
6490 6491 6492 6493 6494 6495 6496 | 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 | - + - | else lineno = nlines; } offset = line_offsets[lineno - 1]; if (fseeko(f, offset, SEEK_SET) != 0) { fsl_free(line); |
︙ | |||
6578 6579 6580 6581 6582 6583 6584 | 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 | - + | static int close_diff_view(struct fnc_view *view) { struct fnc_diff_view_state *s = &view->state.diff; int rc = 0; if (s->f && fclose(s->f) == EOF) |
︙ | |||
6646 6647 6648 6649 6650 6651 6652 | 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 | - + - + + + - + - + - + + + + + + + + + + + + + + - - + + + + + + + + + + + + + - + | cols = size.ws_col; lines = size.ws_row; } resize_term(lines, cols); } static int |
︙ | |||
6763 6764 6765 6766 6767 6768 6769 | 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 | - + + + + - + | */ /* fsl_cx *f = fcli_cx(); */ /* f->output = fsl_outputer_FILE; */ /* f->output.state.state = (fnc_init.err == true) ? stderr : stdout; */ FILE *f = fnc_init.err ? stderr : stdout; size_t idx = 0; |
︙ | |||
6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 | 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + | { fsl_fprintf(fnc_init.err ? stderr : stdout, " usage: %s config [-R path] [-h|--help] [--ls] " "[setting [value|--unset]]\n" " e.g.: %s config FNC_COLOUR_COMMIT blue\n\n" , fcli_progname(), fcli_progname()); } static void usage_stash(void) { fsl_fprintf(fnc_init.err ? stderr : stdout, " usage: %s stash [get|pop | [-C|--no-colour] [-h|--help] " "[-P|--no-prototype] [-x|--context n]]\n" " e.g.: %s stash -x 10\n\n", fcli_progname(), fcli_progname()); } static void help_stash(const fcli_command *cmd) { fcli_command_help(cmd, false, true); f_out("[stash] subcommands:\n\n"); f_out(" get\n " "Apply the most recent stash changeset to the checkout.\n\n"); f_out(" pop\n Remove the most recent stash changeset, " "and apply to the checkout.\n\n"); usage_stash(); } static int cmd_stash(fcli_command const *argv) { fsl_cx *const f = fcli_cx(); struct fnc_view *view = NULL; struct fnc_commit_artifact *commit = NULL; fsl_id_t prid = -1, rid = -1; int rc = FSL_RC_OK; enum fnc_diff_type diff_type = FNC_DIFF_CKOUT; enum fnc_diff_mode diff_mode = STASH_INTERACTIVE; #ifdef __OpenBSD__ if (pledge("stdio rpath wpath cpath fattr flock tty unveil", NULL) == -1) return RC(fsl_errno_to_rc(errno, FSL_RC_ACCESS), "pledge"); #endif rc = fcli_process_flags(argv->flags); if (rc || (rc = fcli_has_unused_flags(false))) return rc; if (fcli_next_arg(false)) { const char *cmd; bool pop = false; if (fsl_strcmp((cmd = fcli_next_arg(true)), "get") && fsl_strcmp(cmd, "apply") && !(pop = !fsl_strcmp(cmd, "pop"))) return RC(FSL_RC_NOT_FOUND, "invalid stash subcommand: %s", cmd); return f__stash_get(pop); } rc = fsl_sym_to_rid(f, "current", FSL_SATYPE_CHECKIN, &prid); if (rc || prid < 0) return RC(rc, "fsl_sym_to_rid"); fsl_ckout_version_info(f, &rid, NULL); if ((rc = fsl_ckout_changes_scan(f))) return RC(rc, "fsl_ckout_changes_scan"); if (!fsl_ckout_has_changes(f)) { fsl_fprintf(stdout, "No local changes.\n"); return rc; } commit = calloc(1, sizeof(*commit)); if (commit == NULL) return RC(fsl_errno_to_rc(errno, FSL_RC_ERROR), "calloc"); commit->prid = prid; commit->rid = rid; commit->puuid = fsl_rid_to_uuid(f, prid); commit->uuid = fsl_rid_to_uuid(f, rid); commit->type = fsl_strdup("blob"); commit->diff_type = diff_type; rc = init_curses(); if (rc) goto end; /* * XXX revert_ckout:fsl_ckout_revert()^ walks the tree from / to the * ckout stat(2)ing every dir so we need rx on root. Revoke privileges * on root after returning from revert_ckout(). * ^fsl__vfile_to_ckout:fsl_mkdir_for_file:fsl_dir_check() */ rc = init_unveil(((const char *[]){"/", REPODIR, CKOUTDIR, P_tmpdir, gettzfile()}), ((const char *[]){"rx", "rwc", "rwc", "rwc", "r"}), 5, false); if (rc) goto end; view = view_open(0, 0, 0, 0, FNC_VIEW_DIFF); if (view == NULL) { rc = RC(FSL_RC_ERROR, "view_open"); goto end; } rc = open_diff_view(view, commit, NULL, NULL, diff_mode); if (!rc) { rc = show_diff(view); if (!rc) rc = fnc_stash(view); } end: /* * We must check for changes based on file content--not mtime--else * the lib will report files as unchanged in some cases. */ fsl_vfile_changes_scan(f, f->ckout.rid, FSL_VFILE_CKSIG_HASH); if (commit) fnc_commit_artifact_close(commit); if (view) view_close(view); return rc; } static int cmd_diff(fcli_command const *argv) { fsl_cx *const f = fcli_cx(); struct fnc_view *view; struct fnc_commit_artifact *commit = NULL; struct fnc_pathlist_head paths; struct fnc_pathlist_entry *pe; fsl_deck d = fsl_deck_empty; fsl_stmt *q = NULL; const char *artifact1 = NULL, *artifact2 = NULL; char *path0 = NULL; fsl_id_t prid = -1, rid = -1; int rc = FSL_RC_OK; unsigned short blob = 0; enum fnc_diff_type diff_type = FNC_DIFF_CKOUT; |
︙ | |||
6897 6898 6899 6900 6901 6902 6903 | 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 | - - + + - - - + - + - - - - - + + + + + + - + - - + - + + + - + - + - + - + + - + - + | &rid)) { artifact2 = fcli_next_arg(true); diff_type = FNC_DIFF_COMMIT; if (!fsl_rid_is_a_checkin(f, rid)) ++blob; } } |
︙ | |||
7040 7041 7042 7043 7044 7045 7046 | 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 | - + | struct commit_entry *entry, const char *path) { struct fnc_view *tree_view; int rc = 0; tree_view = view_open(0, 0, start_ln, start_col, FNC_VIEW_TREE); if (tree_view == NULL) |
︙ | |||
7107 7108 7109 7110 7111 7112 7113 | 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 | - + + - + | fcli_progname()); goto end; } rc = init_curses(); if (rc) goto end; |
︙ | |||
7138 7139 7140 7141 7142 7143 7144 | 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 | - + | TAILQ_INIT(&s->parents); s->show_id = false; s->colour = !fnc_init.nocolour && has_colors(); s->rid = rid; s->commit_id = fsl_rid_to_uuid(f, rid); if (s->commit_id == NULL) |
︙ | |||
7169 7170 7171 7172 7173 7174 7175 | 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 | - + | rc = walk_tree_path(s, s->repo, &s->root, path); if (rc) goto end; } if ((s->tree_label = fsl_mprintf("checkin %s", s->commit_id)) == NULL) { |
︙ | |||
7222 7223 7224 7225 7226 7227 7228 | 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 | - + | slash = strchr(p, '/'); if (slash == NULL) te_name = fsl_strdup(p); else te_name = fsl_strndup(p, slash - p); if (te_name == NULL) { |
︙ | |||
7245 7246 7247 7248 7249 7250 7251 | 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 | - + | slash = strchr(p, '/'); if (slash) subpath = fsl_strndup(path, slash - path); else subpath = fsl_strdup(path); if (subpath == NULL) { |
︙ | |||
7286 7287 7288 7289 7290 7291 7292 | 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 | - + - + - + - + | struct fnc_repository_tree *ptr; fsl_deck d = fsl_deck_empty; const fsl_card_F *cf = NULL; int rc = 0; ptr = fsl_malloc(sizeof(struct fnc_repository_tree)); if (ptr == NULL) |
︙ | |||
7347 7348 7349 7350 7351 7352 7353 | 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 | - + - + - + - + - + | struct fnc_tree_entry *te = NULL; struct fnc_repo_tree_node *tn = NULL; int i = 0; *tree = NULL; *tree = fsl_malloc(sizeof(**tree)); if (*tree == NULL) |
︙ | |||
7464 7465 7466 7467 7468 7469 7470 | 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 | - + | * If not at end of path string, node is a directory so don't * allocate space for the hash. */ if (uuid != 0 && path[i] == '\0') nodesz += FSL_STRLEN_K256 + 1; /* NUL */ tn = fsl_malloc(nodesz); if (tn == NULL) |
︙ | |||
7573 7574 7575 7576 7577 7578 7579 | 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 | - + - + - + - + | TAILQ_FOREACH(pt, parents, entry) len += strlen(pt->selected_entry->basename) + 1 /* slash */; if (te) len += strlen(te->basename); *path = calloc(1, len); if (path == NULL) |
︙ | |||
7718 7719 7720 7721 7722 7723 7724 | 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 | - + - + - | te = &s->tree->entries[idx]; mode = te->mode; if (s->show_id) { idstr = fsl_strdup(te->uuid); /* Directories don't have UUIDs; pad with "..." dots. */ if (idstr == NULL && !S_ISDIR(mode)) |
︙ | |||
7765 7766 7767 7768 7769 7770 7771 | 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 | - - + + | line = fsl_mprintf("%s%s%.*s %s%s%s%s", idstr ? idstr : "", (*iso8601 && idstr) ? " " : "", ISO8601_DATE_HHMM, *iso8601 ? iso8601 : "", te->basename, modestr, targetlnk ? " -> ": "", targetlnk ? targetlnk : ""); fsl_free(idstr); fsl_free(targetlnk); if (rc || line == NULL) |
︙ | |||
7821 7822 7823 7824 7825 7826 7827 | 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 | - + | fsl_buffer_cstr(&fb)); goto end; } bufsz = s.st_size ? (s.st_size + 1 /* NUL */) : PATH_MAX; buf = fsl_malloc(bufsz); if (buf == NULL) { |
︙ | |||
7874 7875 7876 7877 7878 7879 7880 | 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 | - + | switch (ch) { case 'b': if (view_is_parent(view)) start_col = view_split_start_col(view->start_col); branch_view = view_open(view->nlines, view->ncols, view->start_ln, start_col, FNC_VIEW_BRANCH); if (branch_view == NULL) |
︙ | |||
8071 8072 8073 8074 8075 8076 8077 | 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 | + - + - - + | fid = fsl_uuid_to_rid(f, s->selected_entry->uuid); rc = fsl_content_get(f, fid, &buf); if (rc) goto end; if (fsl_looks_like_binary(&buf)) sitrep(view, SR_UPDATE | SR_SLEEP, |
︙ | |||
8163 8164 8165 8166 8167 8168 8169 | 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 | - + | static int visit_subtree(struct fnc_tree_view_state *s, struct fnc_tree_object *subtree) { struct fnc_parent_tree *parent; parent = calloc(1, sizeof(*parent)); if (parent == NULL) |
︙ | |||
8194 8195 8196 8197 8198 8199 8200 | 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 | - + | rc = tree_entry_path(&path, parents, te); if (rc) return rc; blame_view = view_open(0, 0, start_ln, start_col, FNC_VIEW_BLAME); if (blame_view == NULL) { |
︙ | |||
8398 8399 8400 8401 8402 8403 8404 | 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 | - + + - + | cmd_config(const fcli_command *argv) { const char *opt = NULL, *value = NULL; char *prev, *v; enum fnc_opt_id setid; int rc = FSL_RC_OK; |
︙ | |||
8535 8536 8537 8538 8539 8540 8541 | 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 | - - + + | set_colours(struct fnc_colours *s, enum fnc_view_id vid) { int rc = FSL_RC_OK; switch (vid) { case FNC_VIEW_DIFF: { static const char *regexp_diff[] = { |
︙ | |||
8610 8611 8612 8613 8614 8615 8616 | 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 11288 11289 11290 | - + - + | init_colour(FNC_COLOUR_BRANCH_PRIVATE)} }; rc = set_colour_scheme(s, pairs_branch, regexp_branch, nitems(regexp_branch)); break; } default: |
︙ | |||
8702 8703 8704 8705 8706 8707 8708 | 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 | - + | fsl_db *db = NULL; char *optval = NULL, *envvar = NULL; db = fsl_needs_repo(f); if (!db) { /* Theoretically, this shouldn't happen. */ |
︙ | |||
8766 8767 8768 8769 8770 8771 8772 | 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 | - + | { fsl_cx *const f = fcli_cx(); fsl_db *db = NULL; db = fsl_needs_repo(f); if (!db) /* Theoretically, this shouldn't happen. */ |
︙ | |||
8895 8896 8897 8898 8899 8900 8901 | 11542 11543 11544 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 | - + - + - - + + - + | fsl_ckout_version_info(f, &rid, NULL); if (!rid) /* -R|--repo option used */ fsl_sym_to_rid(f, "tip", FSL_SATYPE_CHECKIN, &rid); } rc = map_repo_path(&path); if (rc) { |
︙ | |||
8944 8945 8946 8947 8948 8949 8950 | 11591 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 | - + | struct fnc_blame_view_state *s = &view->state.blame; int rc = 0; CONCAT(STAILQ, _INIT)(&s->blamed_commits); s->path = fsl_strdup(path); if (s->path == NULL) |
︙ | |||
9019 9020 9021 9022 9023 9024 9025 | 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 | - + - + | filepath, s->blamed_commit->id); goto end; } rc = fsl_card_F_content(f, cf, &buf); if (rc) goto end; if (fsl_looks_like_binary(&buf)) { |
︙ | |||
9071 9072 9073 9074 9075 9076 9077 | 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 | - + - + - + - + | if (rc) goto end; s->gtl = ln; } blame->lines = calloc(blame->nlines, sizeof(*blame->lines)); if (blame->lines == NULL) { |
︙ | |||
9158 9159 9160 9161 9162 9163 9164 | 11805 11806 11807 11808 11809 11810 11811 11812 11813 11814 11815 11816 11817 11818 11819 | - + | if (nlines) { if (line_offsets && *line_offsets == NULL) { *nlines = 1; nalloc = alloc_chunksz; *line_offsets = calloc(nalloc, sizeof(**line_offsets)); if (*line_offsets == NULL) return RC(fsl_errno_to_rc(errno, FSL_RC_ERROR), |
︙ | |||
9184 9185 9186 9187 9188 9189 9190 | 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 | - + - + - - + - + - + | n = *nlines + alloc_chunksz; oldsz = nalloc * sizeof(**line_offsets); newsz = n * sizeof(**line_offsets); if (newsz <= oldsz) { size_t b = oldsz - newsz; if (b < oldsz / 2 && |
︙ | |||
9261 9262 9263 9264 9265 9266 9267 | 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981 11982 11983 11984 | - + - - + - - + - + - + - + - + | int rc0, rc; rc = block_main_thread_signals(); if (rc) return (void *)(intptr_t)rc; rc = fsl_annotate(f, &cx->blame_opt); |
︙ | |||
9352 9353 9354 9355 9356 9357 9358 | 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 12006 12007 12008 12009 12010 | - + - | const int idfield = 11; /* Prefix + space. */ bool selected; rewind(blame->f); werase(view->window); if ((line = fsl_mprintf("checkin %s", s->blamed_commit->id)) == NULL) { |
︙ | |||
9409 9410 9411 9412 9413 9414 9415 | 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 | - + | if (linelen == -1) { if (feof(blame->f)) { s->eof = true; break; } fsl_free(line); return RC(ferror(blame->f) ? fsl_errno_to_rc(errno, |
︙ | |||
9434 9435 9436 9437 9438 9439 9440 | 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 | - + - | waddstr(view->window, " "); } else if (blame_line->annotated) { char *id_str; id_str = fsl_strndup(blame_line->id, idfield - 1); if (id_str == NULL) { fsl_free(line); |
︙ | |||
9471 9472 9473 9474 9475 9476 9477 | 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 | - + | wattroff(view->window, rx); waddch(view->window, ' '); if (view->ncols <= idfield) { wcstr = wcsdup(L""); if (wcstr == NULL) { rc = RC(fsl_errno_to_rc(errno, FSL_RC_RANGE), |
︙ | |||
9703 9704 9705 9706 9707 9708 9709 | 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 | - + - + + - + - - - - - - | if (pid == NULL) break; /* Check file exists in parent check-in. */ rc = fsl_deck_load_sym(f, &d, pid, FSL_SATYPE_CHECKIN); if (rc) { fsl_deck_finalize(&d); fsl_free(pid); |
︙ | |||
9772 9773 9774 9775 9776 9777 9778 | 12409 12410 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 12423 | - + | } case 'T': if (view_is_parent(view)) start_col = view_split_start_col(view->start_col); branch_view = view_open(view->nlines, view->ncols, view->start_ln, start_col, FNC_VIEW_BRANCH); if (branch_view == NULL) |
︙ | |||
9823 9824 9825 9826 9827 9828 9829 | 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 12473 12474 12475 12476 12477 12478 | - + - + | diff_view = *alt_view; } else { if (view_is_parent(view)) start_col = view_split_start_col(view->start_col); diff_view = view_open(0, 0, 0, start_col, FNC_VIEW_DIFF); if (diff_view == NULL) { fnc_commit_artifact_close(commit); |
︙ | |||
9889 9890 9891 9892 9893 9894 9895 | 12526 12527 12528 12529 12530 12531 12532 12533 12534 12535 12536 12537 12538 12539 12540 12541 12542 12543 12544 | - + - + | static int fnc_commit_qid_alloc(struct fnc_commit_qid **qid, fsl_uuid_cstr id) { int rc = 0; *qid = calloc(1, sizeof(**qid)); if (*qid == NULL) |
︙ | |||
9934 9935 9936 9937 9938 9939 9940 | 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 | - + - + - - - + + + - - - + - | int idx, rc = 0; if (blame->thread_id) { intptr_t retval; rc = pthread_mutex_unlock(&fnc_mutex); if (rc) return RC(fsl_errno_to_rc(rc, FSL_RC_ACCESS), |
︙ | |||
9980 9981 9982 9983 9984 9985 9986 | 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 12627 12628 12629 12630 12631 12632 12633 12634 12635 12636 | - + - + | { int *done = state; int rc = 0; rc = pthread_mutex_lock(&fnc_mutex); if (rc) return RC(fsl_errno_to_rc(rc, FSL_RC_ACCESS), |
︙ | |||
10014 10015 10016 10017 10018 10019 10020 | 12648 12649 12650 12651 12652 12653 12654 12655 12656 12657 12658 12659 12660 12661 12662 | - + | rc = fcli_process_flags(argv->flags); if (rc || (rc = fcli_has_unused_flags(false))) return rc; branch_flags = BRANCH_LS_OPEN_CLOSED; if (fnc_init.open && fnc_init.closed) |
︙ | |||
10036 10037 10038 10039 10040 10041 10042 | 12670 12671 12672 12673 12674 12675 12676 12677 12678 12679 12680 12681 12682 12683 12684 12685 12686 12687 12688 12689 12690 12691 12692 12693 12694 12695 12696 12697 12698 12699 12700 12701 12702 12703 12704 12705 12706 | - + - + + - + | } if (fnc_init.noprivate) FLAG_SET(branch_flags, BRANCH_LS_NO_PRIVATE); if (fnc_init.reverse) FLAG_SET(branch_flags, BRANCH_SORT_REVERSE); if (fnc_init.after && fnc_init.before) { |
︙ | |||
10172 10173 10174 10175 10176 10177 10178 | 12807 12808 12809 12810 12811 12812 12813 12814 12815 12816 12817 12818 12819 12820 12821 | - + | if (!rc && FLAG_CHK(s->branch_flags, BRANCH_SORT_REVERSE)) rc = fsl_buffer_append(&sql," DESC", -1); if (rc) goto end; stmt = fsl_stmt_malloc(); if (stmt == NULL) { |
︙ | |||
10246 10247 10248 10249 10250 10251 10252 | 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 12910 12911 12912 12913 12914 12915 12916 12917 12918 12919 12920 12921 12922 12923 12924 12925 12926 12927 12928 12929 12930 12931 12932 12933 12934 12935 12936 12937 12938 12939 12940 12941 12942 12943 12944 12945 12946 12947 12948 12949 | - + - + - - + - + - + - + | " AND tagxref.tagtype>0" " AND tag.tagname='branch'" " AND event.objid=tagxref.rid " "GROUP BY 1;"; int rc = 0; if (!db) |
︙ | |||
10355 10356 10357 10358 10359 10360 10361 | 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 | - + | if (limit == 0) return rc; be = s->first_branch_onscreen; if ((line = fsl_mprintf("branches [%d/%d]", be->idx + s->selected + 1, s->nbranches)) == NULL) |
︙ | |||
10397 10398 10399 10400 10401 10402 10403 | 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 | - + | s->show_id ? be->branch->id : "", s->show_id ? " " : "", s->show_date ? be->branch->date : "", s->show_date ? " " : "", be->branch->name, be->branch->private ? "*" : "", be->branch->current ? "@" : ""); if (line == NULL) |
︙ | |||
10592 10593 10594 10595 10596 10597 10598 | 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 | - + - + | fsl_id_t rid; int rc = 0; *new_view = NULL; rid = fsl_uuid_to_rid(fcli_cx(), be->branch->id); if (rid < 0) |
︙ | |||
10784 10785 10786 10787 10788 10789 10790 | 13418 13419 13420 13421 13422 13423 13424 13425 13426 13427 13428 13429 13430 13431 13432 | - + | int rc = 0; if (inserted) *inserted = NULL; new = fsl_malloc(sizeof(*new)); if (new == NULL) |
︙ | |||
10880 10881 10882 10883 10884 10885 10886 | 13514 13515 13516 13517 13518 13519 13520 13521 13522 13523 13524 13525 13526 13527 13528 | - + | free(pe); } } static void fnc_show_version(void) { |
︙ | |||
10914 10915 10916 10917 10918 10919 10920 | 13548 13549 13550 13551 13552 13553 13554 13555 13556 13557 13558 13559 13560 13561 13562 13563 13564 13565 13566 13567 13568 13569 13570 13571 13572 13573 13574 13575 13576 13577 13578 13579 13580 13581 13582 13583 13584 13585 13586 13587 13588 13589 13590 13591 13592 13593 13594 13595 13596 13597 13598 13599 13600 13601 13602 13603 13604 13605 13606 13607 13608 13609 13610 13611 13612 13613 13614 13615 13616 13617 13618 13619 13620 13621 13622 13623 13624 13625 13626 | - + - + - - + - + - + - - + + - + - + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - + + | static int fnc_prompt_input(struct fnc_view *view, struct input *input) { int rc = FSL_RC_OK; if (input->prompt) |
︙ | |||
11071 11072 11073 11074 11075 11076 11077 | 13707 13708 13709 13710 13711 13712 13713 13714 13715 13716 13717 13718 13719 13720 13721 13722 13723 13724 13725 13726 13727 13728 | - + - + - + | { if (fold) { *op = fsl_strdup("LIKE"); if (*op == NULL) return RC(FSL_RC_ERROR, "%s", "fsl_strdup"); *glob = fsl_mprintf("%%%%%s%%%%", str); if (*glob == NULL) |
︙ | |||
11116 11117 11118 11119 11120 11121 11122 | 13752 13753 13754 13755 13756 13757 13758 13759 13760 13761 13762 13763 13764 13765 13766 13767 13768 13769 13770 13771 13772 13773 13774 13775 13776 13777 13778 13779 13780 13781 13782 13783 13784 13785 | - + - + - - - - - - - - + + + + + - - - - + - - - + + + + - | * operations. Write and create permissions are briefly listed inline, but we * effectively veil the entire fs except the repo db, ckout, and /tmp dirs. * The create permissions for the repository and checkout dirs are (perhaps * unintuitively) needed as fossil(1) creates temporary journal files in both. */ #ifndef HAVE_LANDLOCK static int |
︙ | |||
11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 | 13800 13801 13802 13803 13804 13805 13806 13807 13808 13809 13810 13811 13812 13813 13814 | + | return ret; } /* * Sans libc wrappers, use the following shims provided by Landlock authors. * https://www.kernel.org/doc/html/latest/userspace-api/landlock.html */ #ifdef HAVE_LANDLOCK #ifndef landlock_create_ruleset static inline int landlock_create_ruleset(const struct landlock_ruleset_attr *const attr, const size_t size, const __u32 flags) { return syscall(__NR_landlock_create_ruleset, attr, size, flags); } |
︙ | |||
11225 11226 11227 11228 11229 11230 11231 | 13856 13857 13858 13859 13860 13861 13862 13863 13864 13865 13866 13867 13868 13869 13870 | - + | rfd = landlock_create_ruleset(&attr, sizeof(attr), 0); if (rfd == -1) { /* Landlock is not supported or disabled by the kernel. */ if (errno == ENOSYS || errno == EOPNOTSUPP) return rc; return RC(fsl_errno_to_rc(errno, FSL_RC_ACCESS), |
︙ | |||
11248 11249 11250 11251 11252 11253 11254 | 13879 13880 13881 13882 13883 13884 13885 13886 13887 13888 13889 13890 13891 13892 13893 13894 13895 13896 13897 13898 13899 13900 13901 13902 13903 | - + - + - + | path_beneath.allowed_access = LANDLOCK_ACCESS_DIR; if (!S_ISDIR(sb.st_mode)) path_beneath.allowed_access = LANDLOCK_ACCESS_FS_READ_FILE; if (landlock_add_rule(rfd, LANDLOCK_RULE_PATH_BENEATH, &path_beneath, 0)) rc = RC(fsl_errno_to_rc(errno, FSL_RC_ACCESS), |