Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Difference From 0.6 To 0.7
2022-01-08 13:33 | Bump version number: 0.8 (check-in: 9918bb8dab user: mark tags: trunk) | |
2022-01-08 13:30 | CHANGES for 0.7 (check-in: 2c45034580 user: mark tags: trunk, 0.7) | |
2022-01-08 13:10 | Bump year in license headers (check-in: 277b68b64f user: mark tags: trunk) | |
2021-11-21 15:32 | Bump version number: 0.7 (check-in: f3d6c2ff7b user: mark tags: trunk) | |
2021-11-21 15:28 | CHANGES for 0.6 (check-in: bbf8590008 user: mark tags: trunk, 0.6) | |
2021-11-21 14:40 | Add user-defined colour support to the branch view. (check-in: 3d1f3389a3 user: mark tags: trunk) | |
Changes to CHANGES.md.
|
Changes to GNUmakefile.
1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | # |
Changes to LICENSE.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 | - + |
|
Changes to Makefile.
1 2 3 4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | # # FNC Makefile # |
Changes to README.md.
1 2 | 1 2 3 4 5 6 7 8 9 10 | - + | # README |
︙ | |||
79 80 81 82 83 84 85 86 87 88 89 90 91 92 | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | + + + + + + + + + + | ![diff removed file](https://fnc.bsdbox.org/uv/resources/img/fnc-diff-split-file-removed.png "fnc diff file removed") ![blame split screen](https://fnc.bsdbox.org/uv/resources/img/fnc-blame-splitscreen.png "fnc blame split screen") ![tree split screen](https://fnc.bsdbox.org/uv/resources/img/fnc-tree-splitscreen.png "fnc tree split screen") ![branch split screen](https://fnc.bsdbox.org/uv/resources/img/fnc-branch-splitscreen.png "fnc branch split screen") ![in-app help](https://fnc.bsdbox.org/uv/resources/img/fnc-inapp_help.png "fnc in-app help") ![timeline help](https://fnc.bsdbox.org/uv/resources/img/fnc-timeline-help.png "fnc timeline help") # Trivia **fnc** [fɪŋk] *noun* (n.) 1. an ncurses browser for [Fossil][0] repositories in the terminal *verb* (v.) 2. to inform etymology From the German word *Fink*, meaning "finch", a type of bird. [0]: https://fossil-scm.org [1]: https://fossil.wanderinghorse.net/r/libfossil [2]: https://fossil-scm.org/home/help?cmd=ui [3]: https://fnc.bsdbox.org/uv/download.html [4]: https://fnc.bsdbox.org/uv/resources/doc/fnc.1.html [5]: https://fnc.bsdbox.org/uv/resources/img/fnc-timeline-fullscreen.png [6]: https://itac.bsdbox.org/fnc-demo.mp4 |
︙ |
Added fnc.bld.mk.
|
Changes to include/settings.h.
︙ | |||
10 11 12 13 14 15 16 17 18 | 10 11 12 13 14 15 16 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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - + + + + + + + + + + + + + + | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #define GEN_ENUM_SYM(pfx, id) pfx##_##id #define GEN_ENUM(name, pfx, info) \ enum name { info(pfx, GEN_ENUM_SYM) }; #define GEN_STR_SYM(pfx, id) #pfx"_"#id #define GEN_STR(name, pfx, info) \ static const char *name[] = { info(pfx, GEN_STR_SYM) }; /* * All configurable fnc settings, which can be stored in either the fossil(1) |
Changes to lib/libfossil-config.h.
︙ | |||
51 52 53 54 55 56 57 | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | - + | #if !defined(HAVE_STDINT_H) # define HAVE_STDINT_H 1 #endif #if !defined(_DEFAULT_SOURCE) # define _DEFAULT_SOURCE 1 #endif #if !defined(_XOPEN_SOURCE) |
︙ |
Changes to lib/libfossil.c.
1 | 1 2 3 4 5 6 7 8 9 | - + | #include "libfossil.h" |
︙ | |||
44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | + + | const fsl_buffer fsl_buffer_empty = fsl_buffer_empty_m; const fsl_card_F fsl_card_F_empty = fsl_card_F_empty_m; const fsl_card_F_list fsl_card_F_list_empty = fsl_card_F_list_empty_m; const fsl_card_J fsl_card_J_empty = fsl_card_J_empty_m; const fsl_card_Q fsl_card_Q_empty = fsl_card_Q_empty_m; const fsl_card_T fsl_card_T_empty = fsl_card_T_empty_m; const fsl_checkin_opt fsl_checkin_opt_empty = fsl_checkin_opt_empty_m; const fsl_cidiff_opt fsl_cidiff_opt_empty = fsl_cidiff_opt_empty_m; const fsl_cidiff_state fsl_cidiff_state_empty = fsl_cidiff_state_empty_m; const fsl_ckout_manage_opt fsl_ckout_manage_opt_empty = fsl_ckout_manage_opt_empty_m; const fsl_ckout_unmanage_opt fsl_ckout_unmanage_opt_empty = fsl_ckout_unmanage_opt_empty_m; const fsl_ckup_opt fsl_ckup_opt_empty = fsl_ckup_opt_m; const fsl_confirmer fsl_confirmer_empty = fsl_confirmer_empty_m; const fsl_cx fsl_cx_empty = fsl_cx_empty_m; |
︙ | |||
375 376 377 378 379 380 381 | 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | - - - + + + | } int fsl_stricmp_cmp( void const * lhs, void const * rhs ){ return fsl_stricmp((char const *)lhs, (char const *)rhs); } fsl_size_t fsl_strlen( char const * src ){ |
︙ | |||
922 923 924 925 926 927 928 | 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 | - + - - + + | } /** Convenience form of fsl_simplify_sql() which assumes b holds an SQL string. It gets processed by fsl_simplify_sql() and its 'used' length potentially gets adjusted to match the adjusted SQL string. */ |
︙ | |||
1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 | 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 | + + + + - - + + | return zEnd[-10]=='/' ? true : !!gotSuffix; } default:{ return false; } } } void fsl_randomness(unsigned int n, void *tgt){ sqlite3_randomness((int)n, tgt); } #undef MARKER #if defined(_WIN32) || defined(WIN32) #undef isatty #endif |
︙ | |||
1321 1322 1323 1324 1325 1326 1327 | 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 | - - + + + + + + | if(NULL==x){ rc = FSL_RC_OOM; goto end; } a->aVers = x; a->naVers = n; } |
︙ | |||
1487 1488 1489 1490 1491 1492 1493 | 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 | - - + + | fsl__cx_scratchpad_yield(f, scratch); fsl__annotator_clean(&ann); return rc; } #undef MARKER #undef blob_to_utf8_no_bom |
︙ | |||
2269 2270 2271 2272 2273 2274 2275 | 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 | + - - - - - - - - - - - - + + + + + + + + + + + + + + + | && (c=fsl_utf8_read_char(z, zEnd, &zNext)); z = zNext ){ if( c=='\\' || c=='"' ){ out("\\", 1); outc; }else if( c<' ' ){ out("\\",1); switch(c){ |
︙ | |||
2928 2929 2930 2931 2932 2933 2934 | 2942 2943 2944 2945 2946 2947 2948 2949 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 | - + - + | } case etSTRING: { bufpt = va_arg(ap,char*); length = bufpt ? StrNLen32(bufpt, (precision>0 && flag_alternateform) ? precision*4/*max bytes per char*/ |
︙ | |||
3215 3216 3217 3218 3219 3220 3221 | 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 | - - + + - + + | va_start( vargs, fmt ); rc = fsl_snprintfv( dest, n, fmt, vargs ); va_end( vargs ); return rc; } #undef MARKER |
︙ | |||
3266 3267 3268 3269 3270 3271 3272 | 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 | - + - + - + | fsl_sha1_update(&hash, zPw, fsl_strlen(zPw)); fsl_sha1_final(&hash, zResult); fsl_sha1_digest_to_base16(zResult, zDigest); return fsl_strndup( zDigest, FSL_STRLEN_SHA1 ); } } |
︙ | |||
3314 3315 3316 3317 3318 3319 3320 | 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 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 | - + - - + + | " AND login NOT IN ('anonymous','nobody','developer','reader')" " AND (pw=%Q OR (length(pw)<>40 AND pw=%Q))", zUsername, zSecret, zPasswd); fsl_free(zSecret); return rc; } |
︙ | |||
3535 3536 3537 3538 3539 3540 3541 | 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 | - - + + | void fsl_id_bag_swap(fsl_id_bag * const lhs, fsl_id_bag * const rhs){ fsl_id_bag x = *lhs; *lhs = *rhs; *rhs = x; } #undef fsl_id_bag_hash |
︙ | |||
3563 3564 3565 3566 3567 3568 3569 3570 | 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 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 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 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + - + - - - - - + + + + - - + + - + + - + + + + + + + + - - - + + + + + + + + - - - - - + + + + + + + + + + + + + + + + + + + - + - + - + - - - - + + + + - + - + - - + + - - - + - - - + + + + - - - - - - - - - - - - + + + + + + + + + - | #define MARKER(pfexp) \ do{ printf("MARKER: %s:%d:%s():\t",__FILE__,__LINE__,__func__); \ printf pfexp; \ } while(0) #define buffer_is_external(b) (b->mem && 0==b->capacity) /** Materializes external buffer b by allocating b->used+extra+1 bytes, copying b->used bytes from b->mem to the new block, NUL-terminating the block, and replacing b->mem with the new block. Returns 0 on success, else FSL_RC_OOM. Asserts that b is an external buffer. */ static int fsl__buffer_materialize( fsl_buffer * const b, fsl_size_t extra ){ assert(buffer_is_external(b)); fsl_size_t const n = b->used + extra + 1; unsigned char * x = (unsigned char *)fsl_malloc(n); if(!x) return FSL_RC_OOM; memcpy(x, b->mem, b->used); b->capacity = n; x[b->used] = 0; b->mem = x; return 0; } int fsl_buffer_materialize( fsl_buffer * const b ){ return buffer_is_external(b) ? fsl__buffer_materialize(b, 0) : 0; } #define buffer_materialize(B,N) (buffer_is_external(B) ? fsl__buffer_materialize((B),(N)) : 0) void fsl_buffer_external( fsl_buffer * const b, void const * mem, fsl_int_t n ){ if(b->mem) fsl_buffer_clear(b); if(n<0) n =(fsl_int_t)fsl_strlen((char const *)mem); b->used = n; b->cursor = 0; b->mem = (unsigned char *)mem; b->capacity = 0; } |
︙ | |||
3700 3701 3702 3703 3704 3705 3706 | 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 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 | - + - + - - + + + - - + + - - + + + - + | va_start(args,fmt); rc = fsl_buffer_appendfv( b, fmt, args ); va_end(args); return rc; } } |
︙ | |||
3894 3895 3896 3897 3898 3899 3900 | 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 | - + - + - - + + + + + + + + + + + + + + + + + + + + + + - - + + + + + - + - - - - - + + + + + - - - + + + - - + + - - - - + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + | }else{ fsl_buffer_reserve(&temp, 0); } return rc; } } |
︙ | |||
4024 4025 4026 4027 4028 4029 4030 | 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 | - - - - + + + + - - + + - - - + - - - + + + - + - - - - + + + - - + - - - + + + - - - - + + + - - - - - - - + + + + + + - - - + - - - - + + + - - + - - + - - + | fsl_buffer const * const src ){ fsl_buffer_reuse(dest); return src->used ? fsl_buffer_append( dest, src->mem, src->used ) : 0; } |
︙ | |||
4246 4247 4248 4249 4250 4251 4252 | 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 | + + - - + + + | fsl_buffer_clear(&fc); #endif return rc; } } char * fsl_buffer_take(fsl_buffer * const b){ char * z = NULL; if(0==buffer_materialize(b,0)){ |
︙ | |||
4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 | 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 | + + - + + + + - + + + - - + + | if(i++) rc = fsl_buffer_append(b, separator, sepLen); if(!rc) rc = fsl_buffer_appendf(b, "%" FSL_ID_T_PFMT, e); } return rc; } int fsl_buffer_append_tcl_literal(fsl_buffer * const b, bool escapeSquigglies, char const * z, fsl_int_t n){ int rc; if(n<0) n = fsl_strlen(z); rc = fsl_buffer_append(b, "\"", 1); for(fsl_int_t i=0; 0==rc && i<n; ++i){ char c = z[i]; bool skipSlash = false; switch( c ){ |
︙ | |||
4489 4490 4491 4492 4493 4494 4495 | 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 | - - + + | } assert(!"delta-loop in repository"); return fsl_cx_err_set(f, FSL_RC_CONSISTENCY, "Serious problem: delta-loop in repository"); } #undef MARKER |
︙ | |||
4538 4539 4540 4541 4542 4543 4544 | 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 | - + + + - + - + | ignore if (e.g.) the parent content is already a delta of something else. The wise caller will have a transaction in place when calling this. Returns 0 on success. On error rid and uuid are not modified. */ |
︙ | |||
4781 4782 4783 4784 4785 4786 4787 | 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 | - + | if(rc) fsl_db_transaction_rollback(db); else{ rc = fsl_cx_uplift_db_error2(f, db, fsl_db_transaction_commit(db)); } return rc; } |
︙ | |||
4822 4823 4824 4825 4826 4827 4828 | 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 | - + - - - + + | if(rc) fsl_db_transaction_rollback(db); else{ rc = fsl_cx_uplift_db_error2(f, db, fsl_db_transaction_commit(db)); } return rc; } |
︙ | |||
4851 4852 4853 4854 4855 4856 4857 | 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 | - - + | : false); } fsl__cx_scratchpad_yield(f, canon); return rv; } } |
︙ | |||
5675 5676 5677 5678 5679 5680 5681 | 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 | - + | "WHERE fsl_is_enqueued(id)", vid, d->rid); if(!rc) rc = fsl__ckout_version_write(f, d->rid, NULL); RC; assert(d->f == f); rc = fsl_checkin_add_unsent(f, d->rid); RC; |
︙ | |||
5769 5770 5771 5772 5773 5774 5775 | 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 | - - + + | fsl_checkin_discard(f); fsl_deck_finalize(d); return rc; } #undef MARKER |
︙ | |||
5806 5807 5808 5809 5810 5811 5812 | 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 | - - + + - + | /** Kludge for type-safe strncmp/strnicmp inconsistency. */ static int fsl_strnicmp_int(char const *zA, char const * zB, fsl_size_t nByte){ return fsl_strnicmp( zA, zB, (fsl_int_t)nByte); } |
︙ | |||
5853 5854 5855 5856 5857 5858 5859 | 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 | - + | "file name: %s\n", rc, fsl_rc_cstr(rc), zOrigName); } goto end; } zFull = fsl_buffer_cstr2(full, &nFull); |
︙ | |||
6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 | 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 | + + + + + + + + + + - - - + + + | return fsl_db_exists(fsl_cx_db_ckout(f), "SELECT 1 FROM vfile" " WHERE vid=%"FSL_ID_T_PFMT " AND pathname=%Q %s", f->ckout.rid, zFilename, fsl_cx_filename_collation(f)); } /** Initialized-with-defaults fsl_ckout_manage_state structure, intended for const-copy initialization. */ #define fsl_ckout_manage_state_empty_m {NULL,NULL,NULL} /** Initialized-with-defaults fsl_ckout_manage_state structure, intended for non-const copy initialization. */ static const fsl_ckout_manage_state fsl_ckout_manage_state_empty = fsl_ckout_manage_state_empty_m; /** Internal machinery for fsl_ckout_manage(). zFilename MUST be a checkout-relative file which is known to exist. fst MUST be an object populated by fsl_stat()'ing zFilename. isInVFile MUST be the result of having passed zFilename to fsl_co_is_in_vfile(). */ |
︙ | |||
6099 6100 6101 6102 6103 6104 6105 | 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 | - + | static int fsl_dircrawl_f_add(fsl_dircrawl_state const *); /** Attempts to add file or directory (recursively) cas->absBuf to the current repository. isCrawling must be true if this is a fsl_dircrawl()-invoked call, else false. */ |
︙ | |||
6130 6131 6132 6133 6134 6135 6136 | 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 | + - - + + + + | }else if(cas->opt->checkIgnoreGlobs){ char const * m = fsl_cx_glob_matches(cas->f, FSL_GLOBS_IGNORE, zCoRel); if(m) skipped = true; } if(!skipped && cas->opt->callback){ bool yes = false; fsl_ckout_manage_state mst = fsl_ckout_manage_state_empty; |
︙ | |||
6177 6178 6179 6180 6181 6182 6183 6184 | 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 | + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + | "fsl_fstat_type_e #%d", cas->fst.type); break; } end: return rc; } /** fsl_dircrawl_f() impl for fsl_ckout_manage(). */ static int fsl_dircrawl_f_add(fsl_dircrawl_state const *dst){ switch(dst->entryType){ case FSL_FSTAT_TYPE_DIR: |
︙ | |||
6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 | 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 | + + + + + + + + | fsl_stmt_finalize(&insId); return rc; dberr: assert(rc); rc = fsl_cx_uplift_db_error2(f, db, rc); goto end; } /** Initialized-with-defaults fsl_ckout_unmanage_state structure, intended for const-copy initialization. */ #define fsl_ckout_unmanage_state_empty_m {NULL,NULL,NULL} /** Initialized-with-defaults fsl_ckout_unmanage_state structure, intended for non-const copy initialization. */ static const fsl_ckout_unmanage_state fsl_ckout_unmanage_state_empty = fsl_ckout_unmanage_state_empty_m; int fsl_ckout_unmanage(fsl_cx * const f, fsl_ckout_unmanage_opt const * opt){ int rc; fsl_db * const db = fsl_needs_ckout(f); fsl_buffer * fname = 0; fsl_id_t const vid = f->ckout.rid; fsl_stmt q = fsl_stmt_empty; |
︙ | |||
6336 6337 6338 6339 6340 6341 6342 6343 | 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 | + + + - - + + + + + + | "/*%s()*/", vid, zNorm, zNorm, vid, __func__); if(rc) goto dberr; } }/*opt->filename*/ if(q.stmt){ fsl_ckout_unmanage_state ust = fsl_ckout_unmanage_state_empty; ust.opt = opt; ust.f = f; while(FSL_RC_STEP_ROW==fsl_stmt_step(&q)){ |
︙ | |||
6373 6374 6375 6376 6377 6378 6379 | 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 | - + - + | } int fsl_ckout_changes_scan(fsl_cx * const f){ return fsl_vfile_changes_scan(f, -1, 0); } |
︙ | |||
6414 6415 6416 6417 6418 6419 6420 | 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 | - + - - - + + - + + + + + + + + + + + - + - - - - + | return fsl_db_exists(db, "SELECT 1 FROM vfile WHERE chnged " "OR coalesce(origname != pathname, 0) " "/*%s()*/", __func__) || fsl_db_exists(db,"SELECT 1 FROM vmerge /*%s()*/", __func__); } |
︙ | |||
6473 6474 6475 6476 6477 6478 6479 | 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 | - + - + - - - - - - - + + + + + + + + + | /*MARKER(("Updated ckout.dir: %d %s\n", (int)f->ckout.dirLen, f->ckout.dir));*/ } return rc; } |
︙ | |||
6542 6543 6544 6545 6546 6547 6548 | 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 | - - - + - + - - - - + + - + + - + - | /** Create and attach ckout db... */ assert(!fsl_cx_db_ckout(f)); const char * dbName = opt->ckoutDbFile ? opt->ckoutDbFile : fsl_preferred_ckout_db_name(); fsl_cx_err_reset(f); |
︙ | |||
6814 6815 6816 6817 6818 6819 6820 | 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 | - + | RepoExtractCkup * const rec = (RepoExtractCkup *)xs->callbackState; const char * zFilename; fsl_ckup_state coState = fsl_ckup_state_empty; fsl_time_t mtime = 0; fsl_fstat fst = fsl_fstat_empty; fsl_ckup_localmod_e modType = FSL_RECO_MOD_UNKNOWN; bool loadedContent = false; |
︙ | |||
7161 7162 7163 7164 7165 7166 7167 | 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 | - + | if(rc) goto end; while(FSL_RC_STEP_ROW==(rc = fsl_stmt_step(&q))){ fsl_size_t nFn = 0; char const * fn = fsl_stmt_g_text(&q, 0, &nFn); absPath->used = ckdirLen; rc = fsl_buffer_append(absPath, fn, nFn); if(rc) break; |
︙ | |||
7277 7278 7279 7280 7281 7282 7283 | 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 | - + | if(rc) goto end; } rc = fsl_ckout_manifest_write(f, -1, -1, -1, NULL); end: if(!rc){ rc = fsl_vfile_unload_except(f, cOpt->checkinRid); |
︙ | |||
7351 7352 7353 7354 7355 7356 7357 | 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 | - - + - + + | } /* ** The record.fn field is used to match files against each other. The ** FV table contains one row for each each unique filename in ** in the current checkout, the pivot, and the version being merged. */ rc = fsl_db_exec_multi(dbC, |
︙ | |||
7949 7950 7951 7952 7953 7954 7955 | 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 | - - - + + + - + - + - - + + | || 0==fsl_strncmp(z,"true",4)){ z = "ru"/*historical default*/; }else if(!fsl_str_bool(z)){ z = ""; } for(;*z;++z){ switch(*z){ |
︙ | |||
8192 8193 8194 8195 8196 8197 8198 | 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 | - + - + | (int)errLen, zFilename); } end: fsl__cx_scratchpad_yield(f, fn); return rc; } |
︙ | |||
8239 8240 8241 8242 8243 8244 8245 | 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 | - + + - + - - - - - + + + + - + - - + + - + - - - - + - + - - + - - + - - - - | } /** Queues the directory part of the given filename into temp table fx_revert_rmdir for an eventual rmdir() attempt on it in fsl_revert_rmdir_fini(). */ |
︙ | |||
8333 8334 8335 8336 8337 8338 8339 | 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 | - - + + | if(fname->used) fsl_buffer_strip_slashes(fname); if(1==fname->used && '.'==*zNorm){ /* Special case: handle "." from ckout root intuitively */ fsl_buffer_reuse(fname); assert(0==*zNorm); } } |
︙ | |||
8373 8374 8375 8376 8377 8378 8379 | 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 | - + - - - - + - - + - + | " OR deleted<>0" " OR rid=0" " OR coalesce(origname,pathname)" " <>pathname" ")", -1); } assert(!rc); |
︙ | |||
8422 8423 8424 8425 8426 8427 8428 | 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 | - + - + | } } /* Ignore any errors: this operation is an optimization, not a requirement. Worse case, the entry with the old name is left in the filesystem. */ } if(!vfUpdate.stmt){ |
︙ | |||
8461 8462 8463 8464 8465 8466 8467 | 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 | - + + + + | end: if(fname) fsl__cx_scratchpad_yield(f, fname); if(sql) fsl__cx_scratchpad_yield(f, sql); fsl_stmt_finalize(&q); fsl_stmt_finalize(&vfUpdate); if(qRmdir.stmt){ fsl_stmt_finalize(&qRmdir); |
︙ | |||
8546 8547 8548 8549 8550 8551 8552 | 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 | - + | fsl_time_t * repoMtime, fsl_time_t * localMtime){ int rc = 0; fsl_id_t fid = 0; fsl_fstat fst = fsl_fstat_empty; if(!fsl_needs_ckout(f)) return FSL_RC_NOT_A_CKOUT; |
︙ | |||
8575 8576 8577 8578 8579 8580 8581 8582 8583 | 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 | + + + + + + + + + + + + + + + + + + + + + + + - - + + - + + + + + + + + | } if(repoMtime){ rc = fsl_mtime_of_manifest_file(f, vid, fid, repoMtime); } return rc; } char const ** fsl_ckout_dbnames(void){ static char const *dbNames[] = {".fslckout", "_FOSSIL_", NULL}; return dbNames; } char const * fsl_is_top_of_ckout(char const *zDirName){ // counterpart of fossil(1)'s vfile_top_of_checkout() enum {BufLen = 2048}; char nameBuf[BufLen]; char * z = &nameBuf[0]; fsl_size_t sz = fsl_strlcpy(z, zDirName, BufLen); if(sz>=(fsl_size_t)BufLen - 11/*_FOSSIL_/.fslckout suffix*/) return NULL; char const **dbNames = fsl_ckout_dbnames(); char const * dbName; z[sz++] = '/'; z[sz] = 0; for( int i = 0; NULL!=(dbName=dbNames[i]); ++i){ fsl_strlcpy(z + sz , dbName, (fsl_size_t)BufLen - sz); if(fsl_file_size(z)>=1024) return dbName; } return NULL; } #undef MARKER |
︙ | |||
8669 8670 8671 8672 8673 8674 8675 | 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 | - + - - - - | assert(f); if(fcli.transient.repoDbArg){ FCLI_V3(("Trying to open repo db file [%s]...\n", fcli.transient.repoDbArg)); rc = fsl_repo_open( f, fcli.transient.repoDbArg ); } else if(fcli.clientFlags.checkoutDir){ fsl_buffer dir = fsl_buffer_empty; |
︙ | |||
8741 8742 8743 8744 8745 8746 8747 | 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 | - + - + | static struct { fsl_list list; } FCliFree = { fsl_list_empty_m }; static void fcli_shutdown(void){ |
︙ | |||
8892 8893 8894 8895 8896 8897 8898 | 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 | - + - - - + + + | if(fcli.appHelp && fcli.appHelp->callback){ fcli.appHelp->callback(); f_out("\n"); } } if(showGlobal){ if(!showApp){ |
︙ | |||
9366 9367 9368 9369 9370 9371 9372 | 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 | - + - - + - - - - + + + - + + + + + + + + + + - - + + - - - - - - + + - - + | fsl_cx_user_set(f, u); fsl_free(u); } } return rc; } |
︙ | |||
9640 9641 9642 9643 9644 9645 9646 | 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 | - + + | f_out(" (aliases: "); while ( *alias!=0 ){ f_out("%s%s", alias, *(strchr(alias, 0) + 1) ? ", " : ")\n"); alias = strchr(alias, 0) + 1; } } |
︙ | |||
9669 9670 9671 9672 9673 9674 9675 | 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 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 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 | - + - + - - + - + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - | assert((uuid && (rid>0)) || (!uuid && (0==rid))); f_out("%*s %s\n", lblWidth, "repository-db:", fsl_cx_db_file_repo(f, NULL)); f_out("%*s %s\n", lblWidth, "checkout-root:", fsl_cx_ckout_dir_name(f, NULL)); |
︙ | |||
9819 9820 9821 9822 9823 9824 9825 | 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 | - + + | fsl_db * fcli_needs_repo(void){ if(fcli.f) return fsl_needs_repo(fcli.f); fcli_err_set(FSL_RC_NOT_A_REPO, "No repository db is opened."); return NULL; } |
︙ | |||
9862 9863 9864 9865 9866 9867 9868 | 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 | - + | return zEnd+1; default: break; } } return zEnd; } |
︙ | |||
9917 9918 9919 9920 9921 9922 9923 | 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 | - - + + | } #undef FCLI_V3 #undef fcli_empty_m #undef fcli__error #undef MARKER #undef FCLI_USE_SIGACTION |
︙ | |||
9945 9946 9947 9948 9949 9950 9951 | 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 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 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 | - + - - - - + + - + - - - + + + + - - - - + + + + - - - - + + + - - + - - + - + - + + - - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + - | #include <stdio.h> #define MARKER(pfexp) \ do{ printf("MARKER: %s:%d:%s():\t",__FILE__,__LINE__,__func__); \ printf pfexp; \ } while(0) |
︙ | |||
10084 10085 10086 10087 10088 10089 10090 | 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 | - - + - - + + - - + + + - - + + + + + - + - + - - + + + + - + - + - + + - - - - - - - - - - - - | "Fossil has no repo opened."); } else{ int rc; bool gotIt = 0; fsl_id_t nextRid; fsl__bccache * const ac = &f->cache.blobContent; |
︙ | |||
10221 10222 10223 10224 10225 10226 10227 | 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 | - + | #else if(mx){/*unused var*/} fsl_buffer_clear(tgt); #endif *tgt = next; } end_delta: |
︙ | |||
10253 10254 10255 10256 10257 10258 10259 | 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 | - + - - + - + - | /** Mark artifact rid as being available now. Update f's cache to show that everything that was formerly unavailable because rid was missing is now available. Returns 0 on success. f must have an opened repo and rid must be valid. */ |
︙ | |||
10589 10590 10591 10592 10593 10594 10595 | 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 | - + | if(!rc){ rc = fsl_db_exec(dbR, "DELETE FROM phantom " "WHERE rid=%"FSL_ID_T_PFMT, rid /* FIXME? use cached statement? */); if( !rc && (srcId==0 || 0==fsl__bccache_check_available(f, srcId)) ){ isDephantomize = true; |
︙ | |||
10653 10654 10655 10656 10657 10658 10659 | 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 | - + | if( !isDephantomize && fsl_id_bag_contains(&f->cache.blobContent.missing, rid) && (srcId==0 || (0==fsl__bccache_check_available(f,srcId)))){ /* TODO: document what this is for. TODO: figure out what that is. */ |
︙ | |||
10717 10718 10719 10720 10721 10722 10723 | 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 10952 10953 | - - + + | } /* TODO? cached query */ return 1==fsl_db_g_int32( db, 0, "SELECT 1 FROM shun WHERE uuid=%Q", zUuid); } |
︙ | |||
10797 10798 10799 10800 10801 10802 10803 | 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 | - + - - + - + - - - + - - - - - + - - + | } } return rc; } int fsl__content_undeltify(fsl_cx * const f, fsl_id_t rid){ int rc; |
︙ | |||
10870 10871 10872 10873 10874 10875 10876 | 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 11097 11098 11099 11100 11101 | - - + + - - + | } int fsl__content_deltify(fsl_cx * f, fsl_id_t rid, fsl_id_t srcid, bool force){ fsl_id_t s; fsl_buffer data = fsl_buffer_empty; fsl_buffer src = fsl_buffer_empty; |
︙ | |||
10921 10922 10923 10924 10925 10926 10927 | 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 | - - + - - + + - + - + | break; } } if(rc) return rc; /* As of here, don't return on error. Use (goto end) instead, or be really careful, b/c buffers might need cleaning. */ rc = fsl_content_get(f, srcid, &src); |
︙ | |||
10969 10970 10971 10972 10973 10974 10975 | 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 | - + - + + - + | } end: if(rc && db->error.code && !f->error.code){ fsl_cx_uplift_db_error(f,db); } fsl_buffer_clear(&src); fsl_buffer_clear(&data); |
︙ | |||
11037 11038 11039 11040 11041 11042 11043 | 11249 11250 11251 11252 11253 11254 11255 11256 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 11291 11292 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 | - - + + - - - - + - - - - + + + - - + + + - + | return rc ? fsl_cx_uplift_db_error(f, db) : 0; } /** Load the record ID rid and up to N-1 closest ancestors into the "fsl_computed_ancestors" table. */ |
︙ | |||
11115 11116 11117 11118 11119 11120 11121 | 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 | - - - + + + + - + | /* Computing (and keeping) ancestors is relatively costly, so we keep only the copy associated with f->cache.mtimeManifest around. For the general case, we will be feeding this function files from the same manifest. */ f->cache.mtimeManifest = vid; |
︙ | |||
11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 | 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 | + + - + | rc = 0; if(pMTime) *pMTime = (fsl_time_t)fsl_stmt_g_int64(q, 0); }else{ assert(rc); if(FSL_RC_STEP_DONE==rc) rc = FSL_RC_NOT_FOUND; } fsl_stmt_cached_yield(q); /* Reminder: DO NOT clean up fsl_computed ancestors here. Doing so is not only costly later on but also breaks test code. */ } return rc; } int fsl_card_F_content( fsl_cx * f, fsl_card_F const * fc, |
︙ | |||
11212 11213 11214 11215 11216 11217 11218 | 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 | - + - | */ int fsl_import_file( fsl_cx * f, char relativeToCwd, char const * zName, fsl_id_t parentRid, fsl_id_t *rid, fsl_uuid_str * uuid ){ fsl_buffer * canon = 0; // canonicalized filename fsl_buffer * nbuf = 0; // filename buffer |
︙ | |||
11371 11372 11373 11374 11375 11376 11377 | 11582 11583 11584 11585 11586 11587 11588 11589 11590 11591 11592 11593 11594 11595 11596 11597 | - - + + | ); end: fsl_stmt_finalize(&q); return rc; } #undef MARKER |
︙ | |||
12520 12521 12522 12523 12524 12525 12526 | 12731 12732 12733 12734 12735 12736 12737 12738 12739 12740 12741 12742 12743 12744 12745 12746 12747 12748 12749 12750 12751 12752 12753 12754 12755 12756 12757 12758 12759 12760 12761 12762 12763 12764 12765 12766 12767 12768 12769 12770 12771 12772 12773 12774 12775 12776 12777 12778 12779 12780 12781 12782 | - - + + - + + - | #undef fsl__configs_get_v #undef fsl__configs_get_x1 #undef fsl__configs_get_x2 #undef SELECT_FROM_CONFIG #undef MARKER #undef ARRAYLEN |
︙ | |||
12601 12602 12603 12604 12605 12606 12607 | 12812 12813 12814 12815 12816 12817 12818 12819 12820 12821 12822 12823 12824 12825 12826 12827 12828 12829 12830 | - - + | state or output channel. Results are undefined if !f or f's memory has not been properly initialized. */ static void fsl__cx_reset( fsl_cx * const f, bool closeDatabases ); |
︙ | |||
12670 12671 12672 12673 12674 12675 12676 | 12880 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 12950 12951 12952 12953 12954 12955 12956 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 | - - - + - - - - + - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + - + - + + + - - + + + + - + - | /* Clean up pseudo-leak valgrind complains about: https://www.sqlite.org/c3ref/auto_extension.html */; } #endif #if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER)); #endif |
︙ | |||
12757 12758 12759 12760 12761 12762 12763 | 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 | - + - + - | void fsl__cx_clear_mf_seen(fsl_cx * const f, bool freeMemory){ if(freeMemory) fsl_id_bag_clear(&f->cache.mfSeen); else fsl_id_bag_reset(&f->cache.mfSeen); } void fsl_cx_finalize( fsl_cx * const f ){ |
︙ | |||
12794 12795 12796 12797 12798 12799 12800 | 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 | - | sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER)); #endif } void fsl_cx_err_reset(fsl_cx * const f){ //f->interrupted = 0; // No! ONLY modify this via fsl_cx_interrupt() fsl_error_reset(&f->error); |
︙ | |||
12895 12896 12897 12898 12899 12900 12901 | 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 | - - - + - - - + | assert(db && "misuse: no DB handle to uplift error from!"); if(db->error.code) rc = fsl_cx_uplift_db_error(f, db); } return rc; } fsl_db * fsl_cx_db_config( fsl_cx * const f ){ |
︙ | |||
12927 12928 12929 12930 12931 12932 12933 | 13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 13193 13194 13195 13196 13197 13198 13199 13200 13201 13202 13203 13204 13205 13206 13207 13208 13209 13210 13211 13212 13213 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 13245 13246 13247 13248 13249 13250 13251 13252 13253 13254 13255 13256 13257 13258 13259 13260 13261 13262 13263 13264 13265 13266 13267 13268 13269 13270 13271 13272 13273 13274 13275 13276 13277 13278 13279 13280 13281 13282 13283 13284 13285 13286 13287 13288 13289 13290 13291 13292 13293 13294 13295 13296 13297 13298 13299 13300 13301 13302 13303 13304 13305 13306 13307 13308 13309 13310 13311 13312 13313 13314 13315 13316 13317 13318 13319 13320 13321 13322 13323 13324 13325 13326 13327 13328 13329 13330 13331 13332 13333 13334 13335 13336 13337 13338 13339 13340 13341 13342 13343 13344 13345 13346 13347 13348 13349 13350 13351 13352 13353 13354 13355 13356 13357 13358 13359 13360 13361 13362 13363 13364 13365 13366 13367 13368 13369 13370 13371 13372 13373 13374 13375 13376 13377 13378 13379 13380 13381 13382 13383 13384 13385 13386 13387 13388 13389 13390 13391 13392 13393 13394 13395 13396 13397 13398 13399 13400 13401 13402 13403 13404 13405 13406 13407 13408 13409 13410 13411 13412 13413 13414 13415 | - - + - + - - - - - - - - - - - - - - + - + + + + + + + + + + + + + + + + - - + + + + + - - - + + + + + + + + + - + - - - - + + + + + + - - - + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - + - - - - + + + + - + + + - - + + - - - - - - + + + + - - - - - + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + + + - - + - - - + - - + + + - + - + + + + + - + + + + + + - - - + + + - - + - - + - - - - - + - - - + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - + - - + - + | fsl_cx_err_set(f, FSL_RC_NOT_A_CKOUT, "Fossil context has no opened checkout db."); } return db; } fsl_db * fsl_cx_db_ckout( fsl_cx * const f ){ |
︙ | |||
13247 13248 13249 13250 13251 13252 13253 | 13488 13489 13490 13491 13492 13493 13494 13495 13496 13497 13498 13499 13500 13501 13502 13503 13504 13505 13506 13507 13508 13509 13510 13511 13512 13513 13514 13515 | - + - + | schema's tables. */ static int fsl_config_file_reset(fsl_cx * const f, char const * dbName){ fsl_db DB = fsl_db_empty; fsl_db * db = &DB; int rc = 0; bool isAttached = false; |
︙ | |||
13344 13345 13346 13347 13348 13349 13350 | 13585 13586 13587 13588 13589 13590 13591 13592 13593 13594 13595 13596 13597 13598 13599 13600 | - + + | int fsl_config_open( fsl_cx * const f, char const * openDbName ){ int rc = 0; const char * zDbName = 0; char * zPrefName = 0; if(fsl_cx_db_config(f)){ if(NULL==openDbName || 0==*openDbName) return 0/*nothing to do*/; |
︙ | |||
13373 13374 13375 13376 13377 13378 13379 | 13615 13616 13617 13618 13619 13620 13621 13622 13623 13624 13625 13626 13627 13628 13629 13630 13631 13632 13633 13634 13635 13636 13637 13638 13639 13640 13641 13642 | + + + + + + + - + + + + + + + | rc = fsl_cx_err_set(f, FSL_RC_ACCESS, "Configuration database [%s] " "must be writeable.", zDbName); goto end; } #endif assert(NULL==fsl_cx_db_config(f)); rc = fsl_db_open(&f->config.db, zDbName, FSL_OPEN_F_RW | (f->cxConfig.traceSql ? FSL_OPEN_F_TRACE_SQL : 0)); if(0==rc){ int const sqrc = sqlite3_db_config(f->config.db.dbh, SQLITE_DBCONFIG_MAINDBNAME, |
︙ | |||
13467 13468 13469 13470 13471 13472 13473 13474 13475 13476 13477 13478 13479 13480 13481 13482 13483 13484 13485 | 13722 13723 13724 13725 13726 13727 13728 13729 13730 13731 13732 13733 13734 13735 13736 13737 13738 13739 13740 13741 13742 13743 13744 13745 13746 13747 13748 13749 13750 13751 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 13786 13787 13788 13789 13790 13791 13792 13793 13794 13795 13796 13797 13798 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - - | case FSL_HPOLICY_SHA1: p = FSL_HPOLICY_SHA1; break; case FSL_HPOLICY_SHUN_SHA1: p = FSL_HPOLICY_SHUN_SHA1; break; default: p = FSL_HPOLICY_AUTO; break; } f->cxConfig.hashPolicy = p; } #if 0 /** Return true if the schema is out-of-date. db must be an opened repo db. */ static bool fsl__db_repo_schema_is_outofdate(fsl_db *db){ return fsl_db_exists(db, "SELECT 1 FROM config " "WHERE name='aux-schema' " "AND value<>'%s'", FSL_AUX_SCHEMA); } /* Returns 0 if db appears to have a current repository schema, 1 if it appears to have an out of date schema, and -1 if it appears to not be a repository. */ int fsl__db_repo_verify_schema(fsl_db * const db){ if(fsl__db_repo_schema_is_outofdate(db)) return 1; else return fsl_db_exists(db, "SELECT 1 FROM config " "WHERE name='project-code'") ? 0 : -1; } int fsl_repo_schema_validate(fsl_cx * const f, fsl_db * const db){ int rc = 0; int const check = fsl__db_repo_verify_schema(db); if(0 != check){ rc = (check<0) ? fsl_cx_err_set(f, FSL_RC_NOT_A_REPO, "DB file [%s] does not appear to be " "a repository.", db->filename) : fsl_cx_err_set(f, FSL_RC_REPO_NEEDS_REBUILD, "DB file [%s] appears to be a fossil " "repsitory, but is out-of-date and needs " "a rebuild.", db->filename); } return rc; } #endif int fsl_repo_open( fsl_cx * const f, char const * repoDbFile /* , bool readOnlyCurrentlyIgnored */ ){ if(fsl_cx_db_repo(f)){ return fsl_cx_err_set(f, FSL_RC_ACCESS, "Context already has an opened repository."); }else{ int rc; if(0!=fsl_file_access( repoDbFile, F_OK )){ rc = fsl_cx_err_set(f, FSL_RC_NOT_FOUND, "Repository db [%s] not found or cannot be read.", repoDbFile); }else{ |
︙ | |||
13561 13562 13563 13564 13565 13566 13567 13568 13569 13570 13571 13572 13573 13574 | 13856 13857 13858 13859 13860 13861 13862 13863 13864 13865 13866 13867 13868 13869 13870 13871 13872 13873 13874 13875 13876 13877 13878 13879 13880 13881 13882 13883 13884 | + + + + + + + - - + - - | f->ckout.mtime = f->ckout.rid>0 ? fsl_db_g_double(fsl_cx_db_repo(f), 0.0, "SELECT mtime FROM event " "WHERE objid=%" FSL_ID_T_PFMT, f->ckout.rid) : 0.0; } void fsl__cx_ckout_clear( fsl_cx * const f ){ fsl_free(f->ckout.uuid); f->ckout.rid = -1; f->ckout.uuid = NULL; f->ckout.mtime = 0.0; } int fsl__ckout_version_fetch( fsl_cx * const f ){ fsl_id_t rid = 0; int rc = 0; fsl_db * dbC = fsl_cx_db_ckout(f); fsl_db * dbR = dbC ? fsl_needs_repo(f) : NULL; assert(!dbC || (dbC && dbR)); |
︙ | |||
13685 13686 13687 13688 13689 13690 13691 | 13984 13985 13986 13987 13988 13989 13990 13991 13992 13993 13994 13995 13996 13997 | - | fsl_buffer * const pOut ){ int rc; fsl_int_t dLen = 0, i; enum { DbCount = 2 }; const char aDbName[DbCount][10] = { "_FOSSIL_", ".fslckout" }; fsl_buffer Buf = fsl_buffer_empty; fsl_buffer * buf = &Buf; |
︙ | |||
13772 13773 13774 13775 13776 13777 13778 | 14070 14071 14072 14073 14074 14075 14076 14077 14078 14079 14080 14081 14082 14083 14084 14085 14086 14087 14088 14089 14090 14091 14092 14093 14094 14095 14096 14097 14098 14099 14100 14101 14102 14103 14104 14105 14106 14107 14108 14109 14110 14111 14112 14113 14114 14115 14116 14117 14118 14119 14120 14121 14122 14123 14124 14125 14126 14127 | - + - + - - + + - - - + + + + + + + + + - - + - - + + - - - | } } } fsl_buffer_clear(buf); return FSL_RC_NOT_FOUND; } |
︙ | |||
13838 13839 13840 13841 13842 13843 13844 | 14138 14139 14140 14141 14142 14143 14144 14145 14146 14147 14148 14149 14150 14151 14152 14153 14154 14155 14156 14157 14158 14159 14160 14161 14162 14163 14164 14165 14166 14167 14168 14169 14170 14171 14172 14173 14174 14175 14176 14177 14178 14179 14180 | - + + + + - + - + - - - - - + + + + + + + | rc = fsl_repo_open_for_ckout(f); f->flags &= ~FSL_CX_F_IS_OPENING_CKOUT; if(!rc) rc = fsl_cx_after_open(f); if(rc){ /* Is this sane? Is not doing it sane? */ fsl_ckout_close(f); } |
︙ | |||
14071 14072 14073 14074 14075 14076 14077 | 14376 14377 14378 14379 14380 14381 14382 14383 14384 14385 14386 14387 14388 14389 14390 14391 14392 14393 14394 14395 14396 14397 14398 14399 14400 14401 14402 14403 14404 14405 14406 14407 14408 14409 14410 14411 14412 14413 14414 14415 14416 14417 14418 14419 14420 14421 14422 14423 14424 14425 14426 14427 14428 14429 14430 14431 14432 14433 14434 14435 14436 14437 14438 14439 14440 14441 14442 14443 14444 14445 14446 14447 | + + + + - - - + + + + + + - - + + + + + + + - + + + + + - + + + + - + - - - + + + - + - + - - + + + + - - - - - - - - - + - - - - - - - - - - - - - - + | } int fsl_cx_stat(fsl_cx * const f, bool relativeToCwd, char const * zName, fsl_fstat * const tgt){ return fsl_cx_stat2(f, relativeToCwd, zName, tgt, NULL, false); } bool fsl_cx_allows_symlinks(fsl_cx * const f, bool forceRecheck){ if(forceRecheck || f->cache.allowSymlinks<0){ f->cache.allowSymlinks = fsl_config_get_bool(f, FSL_CONFDB_REPO, false, "allow-symlinks"); |
︙ | |||
14186 14187 14188 14189 14190 14191 14192 | 14491 14492 14493 14494 14495 14496 14497 14498 14499 14500 14501 14502 14503 14504 14505 | - + | } int fsl_cx_hash_filename( fsl_cx * f, bool useAlternate, const char * zFilename, fsl_buffer * pOut){ /* FIXME: reimplement this to stream the content in bite-sized chunks. That requires duplicating most of fsl_buffer_fill_from() and fsl_cx_hash_buffer(). */ |
︙ | |||
14294 14295 14296 14297 14298 14299 14300 | 14599 14600 14601 14602 14603 14604 14605 14606 14607 14608 14609 14610 14611 14612 14613 14614 14615 14616 14617 14618 14619 14620 14621 14622 14623 14624 14625 14626 14627 14628 14629 14630 14631 14632 14633 14634 14635 14636 14637 14638 14639 14640 14641 14642 14643 14644 14645 14646 14647 14648 14649 14650 14651 14652 14653 14654 14655 14656 14657 14658 14659 14660 14661 14662 14663 14664 14665 14666 | - + - - + + - + + + - + | f->cache.seenDeltaManifest = 1; rc = fsl_config_set_bool(f, FSL_CONFDB_REPO, "seen-delta-manifest", 1); } return rc; } |
︙ | |||
14423 14424 14425 14426 14427 14428 14429 | 14730 14731 14732 14733 14734 14735 14736 14737 14738 14739 14740 14741 14742 14743 14744 | - + | "Fatal internal fsl_cx::scratchpads misuse: " "passed a non-scratchpad buffer."); } /** @internal |
︙ | |||
14446 14447 14448 14449 14450 14451 14452 | 14753 14754 14755 14756 14757 14758 14759 14760 14761 14762 14763 14764 14765 14766 14767 14768 14769 14770 14771 14772 14773 14774 14775 14776 14777 14778 14779 14780 14781 14782 14783 14784 14785 14786 14787 14788 14789 14790 14791 14792 14793 14794 14795 14796 14797 14798 14799 14800 14801 14802 14803 14804 14805 14806 14807 14808 14809 14810 14811 14812 14813 14814 14815 14816 14817 14818 14819 14820 | - - - + + + + - + - + + - + - + - + - - - - - - + | Results are undefined if tgtDir is not an absolute path or does not have coRoot as its initial prefix. There are any number of valid reasons removal of a directory might fail, and this routine stops at the first one which does. */ |
︙ | |||
14594 14595 14596 14597 14598 14599 14600 | 14898 14899 14900 14901 14902 14903 14904 14905 14906 14907 14908 14909 14910 14911 14912 14913 | - - + + | struct tm * tm = fsl_cx_localtime(f, &clock); return tm ? mktime(tm) : 0; } #endif #undef MARKER #undef FSL_CX_NSCRATCH |
︙ | |||
14639 14640 14641 14642 14643 14644 14645 14646 14647 14648 14649 14650 14651 14652 14653 14654 | 14943 14944 14945 14946 14947 14948 14949 14950 14951 14952 14953 14954 14955 14956 14957 14958 14959 14960 14961 14962 14963 14964 14965 14966 14967 14968 14969 14970 14971 14972 14973 14974 14975 14976 14977 14978 14979 14980 14981 14982 14983 14984 14985 14986 14987 14988 14989 14990 14991 14992 14993 14994 14995 14996 14997 14998 14999 15000 15001 15002 15003 15004 15005 15006 15007 15008 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + - - + - - - - - - - - - - - - - - - - - - + - | */ static int fsl_list_v_fsl_stmt_finalize(void * obj, void * visitorState ){ if(obj) fsl_stmt_finalize( (fsl_stmt*)obj ); return 0; } #endif int fsl__db_errcode(fsl_db * const db, int sqliteCode){ int rc = 0; if(!sqliteCode) sqliteCode = sqlite3_errcode(db->dbh); switch(sqliteCode & 0xff){ case SQLITE_ROW: case SQLITE_DONE: case SQLITE_OK: rc = 0; break; case SQLITE_NOMEM: rc = FSL_RC_OOM; break; case SQLITE_INTERRUPT: rc = FSL_RC_INTERRUPTED; break; case SQLITE_TOOBIG: case SQLITE_FULL: case SQLITE_NOLFS: case SQLITE_RANGE: rc = FSL_RC_RANGE; break; case SQLITE_NOTFOUND: rc = FSL_RC_NOT_FOUND; break; case SQLITE_PERM: case SQLITE_AUTH: case SQLITE_LOCKED: case SQLITE_READONLY: rc = FSL_RC_ACCESS; break; case SQLITE_CORRUPT: rc = FSL_RC_CONSISTENCY; break; case SQLITE_CANTOPEN: case SQLITE_IOERR: rc = FSL_RC_IO; break; default: //MARKER(("sqlite3_errcode()=0x%04x\n", rc)); rc = FSL_RC_DB; break; } return rc ? fsl_error_set(&db->error, rc, "sqlite3 error #%d: %s", sqliteCode, sqlite3_errmsg(db->dbh)) : (fsl_error_reset(&db->error), 0); } void fsl__db_clear_strings(fsl_db * const db, bool alsoErrorState ){ fsl_free(db->filename); db->filename = NULL; fsl_free(db->name); db->name = NULL; if(alsoErrorState) fsl_error_clear(&db->error); } int fsl_db_err_get( fsl_db const * const db, char const ** msg, fsl_size_t * len ){ |
︙ | |||
14726 14727 14728 14729 14730 14731 14732 | 15044 15045 15046 15047 15048 15049 15050 15051 15052 15053 15054 15055 15056 15057 15058 15059 15060 15061 15062 15063 15064 15065 15066 15067 15068 15069 15070 15071 15072 15073 15074 15075 15076 15077 15078 15079 15080 15081 | - - + + - - - + + + | } db->cacheHead = 0; } return rc; } void fsl_db_close( fsl_db * const db ){ |
︙ | |||
14789 14790 14791 14792 14793 14794 14795 | 15107 15108 15109 15110 15111 15112 15113 15114 15115 15116 15117 15118 15119 15120 15121 15122 15123 15124 15125 15126 15127 15128 15129 15130 15131 15132 15133 15134 | - + - | char const * fsl_db_name(fsl_db const * const db){ return db ? db->name : NULL; } /** Returns the db name for the given role. */ |
︙ | |||
15035 15036 15037 15038 15039 15040 15041 | 15352 15353 15354 15355 15356 15357 15358 15359 15360 15361 15362 15363 15364 15365 15366 | - + | st->flags = FSL_STMT_F_CACHE_HELD; *rv = st; } end: return rc; } |
︙ | |||
15088 15089 15090 15091 15092 15093 15094 | 15405 15406 15407 15408 15409 15410 15411 15412 15413 15414 15415 15416 15417 15418 15419 | - + | return rc; } int fsl_stmt_finalize( fsl_stmt * const stmt ){ if(!stmt) return FSL_RC_MISUSE; else{ void const * allocStamp = stmt->allocStamp; |
︙ | |||
15169 15170 15171 15172 15173 15174 15175 | 15486 15487 15488 15489 15490 15491 15492 15493 15494 15495 15496 15497 15498 15499 15500 15501 15502 15503 15504 15505 15506 15507 15508 15509 15510 15511 15512 15513 15514 15515 15516 15517 15518 15519 15520 15521 15522 15523 15524 15525 15526 15527 15528 15529 15530 15531 15532 15533 15534 15535 15536 15537 15538 15539 15540 15541 15542 15543 15544 15545 15546 15547 15548 15549 15550 15551 15552 15553 15554 15555 15556 15557 15558 15559 15560 15561 15562 15563 15564 15565 15566 15567 15568 15569 15570 15571 15572 15573 15574 15575 15576 | - + - - - + - + - + - + - + - + - + - + - + | fsl_stmt_finalize(s); break; } return rc; } int fsl_stmt_step( fsl_stmt * const stmt ){ |
︙ | |||
15400 15401 15402 15403 15404 15405 15406 | 15715 15716 15717 15718 15719 15720 15721 15722 15723 15724 15725 15726 15727 15728 15729 15730 15731 15732 15733 15734 15735 15736 15737 15738 15739 15740 15741 15742 15743 15744 15745 15746 15747 15748 15749 15750 15751 15752 15753 15754 15755 15756 15757 15758 15759 15760 15761 15762 15763 15764 15765 15766 15767 15768 15769 15770 15771 15772 15773 15774 15775 15776 15777 15778 | - + - + - + - + - + - + - + | #define BIND_PARAM_CHECK \ if(!(stmt && stmt->stmt && stmt->db && stmt->db->dbh)) return FSL_RC_MISUSE; else #define BIND_PARAM_CHECK2 BIND_PARAM_CHECK \ if(ndx<1 || ndx>stmt->paramCount) return FSL_RC_RANGE; else int fsl_stmt_bind_null( fsl_stmt * const stmt, int ndx ){ BIND_PARAM_CHECK2 { int const rc = sqlite3_bind_null( stmt->stmt, ndx ); |
︙ | |||
15571 15572 15573 15574 15575 15576 15577 | 15886 15887 15888 15889 15890 15891 15892 15893 15894 15895 15896 15897 15898 15899 15900 15901 15902 15903 15904 15905 15906 15907 15908 15909 15910 15911 15912 15913 15914 15915 15916 15917 15918 | - + - + | ? sqlite3_column_text(stmt->stmt, ndx) : NULL; if(out) *out = (char const *)t; if(outLen){ int const x = sqlite3_column_bytes(stmt->stmt, ndx); *outLen = (x>0) ? (fsl_size_t)x : 0; } |
︙ | |||
15625 15626 15627 15628 15629 15630 15631 | 15940 15941 15942 15943 15944 15945 15946 15947 15948 15949 15950 15951 15952 15953 15954 15955 15956 15957 15958 15959 15960 15961 15962 15963 15964 15965 15966 15967 15968 15969 15970 15971 15972 15973 15974 15975 15976 15977 15978 15979 15980 15981 15982 15983 15984 15985 15986 15987 15988 15989 15990 15991 15992 15993 15994 15995 15996 15997 15998 15999 16000 16001 16002 16003 16004 16005 16006 16007 16008 16009 16010 16011 16012 16013 16014 16015 16016 16017 16018 16019 16020 16021 16022 16023 16024 16025 16026 16027 16028 16029 16030 16031 16032 16033 16034 16035 16036 16037 16038 16039 16040 16041 16042 16043 | - - - + + + - - - - - - - - - - + - - - + - - - - - - - - - - - - - - - - - - - + - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - + - - - + - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - + - - - - - + - - - + - - - + - - - - - + - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + - - + - - - - - - - - - - - - - + + + + + + + + + + - | char const * rv = NULL; fsl_stmt_get_text(stmt, index, &rv, outLen); return rv; } /** |
︙ | |||
16183 16184 16185 16186 16187 16188 16189 | 16071 16072 16073 16074 16075 16076 16077 16078 16079 16080 16081 16082 16083 16084 16085 16086 16087 16088 16089 16090 16091 16092 16093 16094 16095 16096 16097 16098 16099 16100 16101 16102 16103 16104 16105 16106 16107 16108 16109 16110 16111 16112 16113 16114 16115 16116 16117 16118 16119 16120 16121 16122 16123 16124 16125 16126 16127 16128 16129 16130 16131 16132 16133 16134 16135 16136 16137 16138 16139 16140 16141 16142 16143 16144 16145 16146 16147 16148 16149 16150 16151 16152 16153 16154 16155 16156 16157 16158 16159 16160 16161 16162 16163 16164 16165 16166 16167 16168 16169 16170 16171 16172 16173 16174 16175 16176 16177 16178 16179 16180 16181 16182 16183 16184 16185 16186 16187 16188 16189 16190 16191 16192 16193 16194 16195 16196 16197 16198 16199 16200 16201 16202 16203 16204 16205 16206 16207 16208 16209 | - - - - - - - - - - - - - - - + - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - + + - + - + - + + - + + - + - - - - - - + + + + + + + + + + + - + + - + - + | goto end; }else if(!db->filename){ rc = FSL_RC_OOM; goto end; } } db->dbh = dbh; |
︙ | |||
16412 16413 16414 16415 16416 16417 16418 | 16227 16228 16229 16230 16231 16232 16233 16234 16235 16236 16237 16238 16239 16240 16241 16242 16243 16244 16245 16246 16247 16248 16249 16250 16251 16252 16253 16254 16255 16256 16257 16258 16259 16260 16261 16262 16263 16264 16265 16266 16267 16268 16269 16270 16271 16272 16273 16274 16275 16276 16277 16278 16279 16280 16281 16282 16283 16284 16285 16286 16287 16288 16289 16290 16291 16292 16293 16294 16295 16296 16297 16298 16299 16300 16301 16302 16303 16304 16305 16306 16307 16308 16309 16310 16311 16312 16313 16314 16315 16316 16317 16318 16319 16320 16321 16322 16323 16324 16325 16326 16327 16328 16329 16330 16331 16332 | - + - + - - + + + - - + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | } int fsl_db_transaction_level(fsl_db * const db){ return db->doRollback ? -db->beginCount : db->beginCount; } int fsl_db_transaction_commit(fsl_db * const db){ |
︙ | |||
16552 16553 16554 16555 16556 16557 16558 | 16393 16394 16395 16396 16397 16398 16399 16400 16401 16402 16403 16404 16405 16406 16407 | - + | va_list args; va_start(args,sql); rc = fsl_db_get_int32v(db, rv, sql, args); va_end(args); return rc; } |
︙ | |||
16577 16578 16579 16580 16581 16582 16583 | 16418 16419 16420 16421 16422 16423 16424 16425 16426 16427 16428 16429 16430 16431 16432 16433 16434 16435 16436 16437 16438 16439 16440 16441 16442 16443 16444 16445 16446 16447 16448 16449 16450 16451 16452 16453 16454 16455 16456 16457 16458 16459 16460 16461 16462 16463 16464 16465 16466 16467 16468 16469 16470 16471 16472 16473 16474 16475 16476 16477 16478 | - + - + - - + - + | break; } fsl_stmt_finalize(&st); return rc; } } |
︙ | |||
16656 16657 16658 16659 16660 16661 16662 | 16496 16497 16498 16499 16500 16501 16502 16503 16504 16505 16506 16507 16508 16509 16510 16511 16512 16513 16514 16515 16516 16517 16518 16519 16520 16521 | - + - + | break; } fsl_stmt_finalize(&st); return rc; } } |
︙ | |||
16692 16693 16694 16695 16696 16697 16698 | 16532 16533 16534 16535 16536 16537 16538 16539 16540 16541 16542 16543 16544 16545 16546 16547 16548 16549 16550 16551 16552 16553 16554 16555 16556 16557 16558 | - + - + | break; } fsl_stmt_finalize(&st); return rc; } } |
︙ | |||
16747 16748 16749 16750 16751 16752 16753 | 16587 16588 16589 16590 16591 16592 16593 16594 16595 16596 16597 16598 16599 16600 16601 16602 16603 16604 16605 16606 16607 16608 16609 16610 16611 16612 | - + - + | break; } fsl_stmt_finalize(&st); return rc; } } |
︙ | |||
16799 16800 16801 16802 16803 16804 16805 | 16639 16640 16641 16642 16643 16644 16645 16646 16647 16648 16649 16650 16651 16652 16653 16654 16655 16656 16657 16658 16659 16660 16661 16662 16663 16664 16665 16666 16667 16668 16669 16670 16671 16672 16673 16674 16675 16676 16677 16678 16679 16680 16681 16682 16683 16684 16685 16686 16687 16688 16689 16690 16691 16692 16693 16694 16695 16696 16697 16698 16699 16700 16701 16702 16703 16704 16705 16706 16707 16708 16709 16710 16711 16712 16713 16714 16715 16716 16717 16718 16719 16720 16721 16722 16723 16724 16725 16726 16727 16728 16729 16730 16731 16732 16733 16734 16735 16736 16737 16738 16739 16740 16741 16742 16743 16744 16745 16746 16747 16748 16749 16750 16751 16752 16753 16754 16755 16756 16757 16758 16759 16760 16761 16762 16763 16764 16765 16766 16767 16768 16769 16770 16771 16772 16773 16774 16775 16776 16777 16778 16779 16780 16781 16782 16783 16784 16785 16786 16787 16788 16789 16790 16791 16792 16793 16794 16795 16796 16797 | - + - - + + + + + - - - + + + + - - - + + - + - + - + - + - + - + - + - + | break; } fsl_stmt_finalize(&st); return rc; } } |
︙ | |||
16978 16979 16980 16981 16982 16983 16984 | 16821 16822 16823 16824 16825 16826 16827 16828 16829 16830 16831 16832 16833 16834 16835 | - + | return rc; } bool fsl_db_table_exists(fsl_db * const db, fsl_dbrole_e whichDb, const char *zTable ){ |
︙ | |||
17005 17006 17007 17008 17009 17010 17011 | 16848 16849 16850 16851 16852 16853 16854 16855 16856 16857 16858 16859 16860 16861 16862 16863 16864 16865 16866 16867 16868 16869 16870 16871 16872 16873 16874 16875 16876 16877 16878 16879 16880 16881 16882 | - - + + - + - + + | break; } } fsl_stmt_finalize(&q); return rv; } |
︙ | |||
17048 17049 17050 17051 17052 17053 17054 | 16892 16893 16894 16895 16896 16897 16898 16899 16900 16901 16902 16903 16904 16905 16906 16907 16908 16909 16910 16911 16912 16913 16914 16915 16916 16917 16918 16919 | - + - - + + + | } } fsl_stmt_finalize(&st); return rc; } } |
︙ | |||
17128 17129 17130 17131 17132 17133 17134 | 16973 16974 16975 16976 16977 16978 16979 16980 16981 16982 16983 16984 16985 16986 16987 16988 16989 16990 16991 16992 16993 16994 16995 16996 16997 16998 16999 17000 17001 | - - + + - + - - - - + + + + - - + - - - - + - + + | } fsl_output(f, "\n", 1); return 0; } #undef MARKER |
︙ | |||
17174 17175 17176 17177 17178 17179 17180 | 17016 17017 17018 17019 17020 17021 17022 17023 17024 17025 17026 17027 17028 17029 17030 17031 17032 17033 17034 17035 | - + + - + | FSL_CARD_F_LIST_NEEDS_SORT = 0x01 }; /** Transfers the contents of d into f->cache.mcache. If d is dynamically allocated then it is also freed. In any case, after calling this the caller must behave as if the deck had been passed |
︙ | |||
17214 17215 17216 17217 17218 17219 17220 | 17057 17058 17059 17060 17061 17062 17063 17064 17065 17066 17067 17068 17069 17070 17071 | - + | mc->decks[i] = *d; *d = fsl_deck_empty; if(&fsl_deck_empty == mc->decks[i].allocStamp){ /* d was fsl_deck_malloc()'d so we need to free it, but cannot send it through fsl_deck_finalize() because that would try to clean up the memory we just transferred ownership of to mc->decks[i]. So... */ |
︙ | |||
17599 17600 17601 17602 17603 17604 17605 | 17442 17443 17444 17445 17446 17447 17448 17449 17450 17451 17452 17453 17454 17455 17456 17457 17458 17459 17460 | + - + + + + | static void fsl_deck_clean_T(fsl_deck * const m){ fsl_list_clear(&m->T, fsl_list_v_card_T_free, NULL); } static void fsl_deck_clean_U(fsl_deck * const m){ fsl_deck_clean_string(m, &m->U); } static void fsl_deck_clean_W(fsl_deck * const m){ if(m->W.capacity/*dynamically-allocated buffer*/){ |
︙ | |||
17898 17899 17900 17901 17902 17903 17904 | 17745 17746 17747 17748 17749 17750 17751 17752 17753 17754 17755 17756 17757 17758 17759 | - + | /** If fsl_card_is_legal(d->type, card), returns true, else updates d->f->error with a description of the constraint violation and returns 0. */ |
︙ | |||
18041 18042 18043 18044 18045 18046 18047 | 17888 17889 17890 17891 17892 17893 17894 17895 17896 17897 17898 17899 17900 17901 17902 17903 17904 17905 17906 17907 17908 17909 17910 17911 17912 17913 17914 17915 17916 17917 17918 17919 17920 17921 17922 17923 17924 17925 17926 17927 17928 17929 17930 17931 | - + + - - - - + + + + + + + + + + + | int fsl_deck_I_set( fsl_deck * const mf, fsl_uuid_cstr uuid){ if(uuid && mf->H) return FSL_RC_SYNTAX; int const uLen = uuid ? fsl_is_uuid(uuid) : 0; return fsl_deck_sethex_impl(mf, uuid, 'I', uLen, &mf->I); } |
︙ | |||
18230 18231 18232 18233 18234 18235 18236 | 18085 18086 18087 18088 18089 18090 18091 18092 18093 18094 18095 18096 18097 18098 18099 | - + | }else if(!mf->F.used){ theHash = FSL_MD5_INITIAL_HASH; /* fall through and set hash */ }else{ int rc = 0; fsl_card_F const * fc; fsl_id_t fileRid; |
︙ | |||
18388 18389 18390 18391 18392 18393 18394 | 18243 18244 18245 18246 18247 18248 18249 18250 18251 18252 18253 18254 18255 18256 18257 | - + | unsigned len = 0; for(; z[len]; ++len){ if(z[len] <= 32) return false; } return len>0; } |
︙ | |||
18544 18545 18546 18547 18548 18549 18550 | 18399 18400 18401 18402 18403 18404 18405 18406 18407 18408 18409 18410 18411 18412 18413 | - + | if(rc){ fsl_card_F_list_pop(&mf->F); } return rc; } } |
︙ | |||
18643 18644 18645 18646 18647 18648 18649 | 18498 18499 18500 18501 18502 18503 18504 18505 18506 18507 18508 18509 18510 18511 18512 18513 18514 18515 18516 18517 18518 18519 18520 18521 18522 18523 18524 18525 18526 18527 18528 18529 18530 18531 18532 18533 18534 18535 18536 18537 18538 18539 18540 18541 18542 18543 18544 18545 18546 18547 18548 18549 18550 18551 18552 18553 18554 18555 18556 18557 18558 18559 18560 18561 18562 18563 18564 18565 18566 18567 18568 18569 18570 18571 18572 18573 | - + - + - + - + - + - + | return os->rc; } /** Internal helper for fsl_deck_output(). Appends formatted output to os->out() via fsl_output_f_mf(). Returns os->rc (0 on success). */ |
︙ | |||
18740 18741 18742 18743 18744 18745 18746 | 18595 18596 18597 18598 18599 18600 18601 18602 18603 18604 18605 18606 18607 18608 18609 18610 18611 18612 18613 18614 18615 18616 18617 18618 18619 18620 18621 18622 18623 18624 18625 18626 18627 18628 18629 18630 18631 18632 18633 18634 18635 18636 18637 18638 18639 18640 18641 18642 18643 18644 18645 18646 | - + - + - + - + | /** Internal helper for outputing cards which are simple strings. str is the card to output (NULL values are ignored), letter is the card letter being output. If doFossilize is true then the output gets fossilize-formatted. */ |
︙ | |||
18801 18802 18803 18804 18805 18806 18807 | 18656 18657 18658 18659 18660 18661 18662 18663 18664 18665 18666 18667 18668 18669 18670 18671 18672 18673 18674 18675 18676 18677 18678 18679 18680 18681 18682 18683 18684 | - + - + - + | fsl_deck_append(os, "E %s %s\n", ds, os->d->E.uuid); } } return os->rc; } /* Appends the G card to os from os->d->G. */ |
︙ | |||
18887 18888 18889 18890 18891 18892 18893 | 18742 18743 18744 18745 18746 18747 18748 18749 18750 18751 18752 18753 18754 18755 18756 18757 18758 18759 18760 18761 18762 18763 18764 18765 18766 | - + - + | if(!rc) rc = fsl_deck_append( os, " %b", os->scratch); } } if(!rc) fsl_output_f_mf(os, "\n", 1); return os->rc; } |
︙ | |||
18938 18939 18940 18941 18942 18943 18944 | 18793 18794 18795 18796 18797 18798 18799 18800 18801 18802 18803 18804 18805 18806 18807 18808 18809 18810 18811 18812 18813 18814 18815 18816 18817 18818 18819 18820 18821 18822 18823 18824 18825 18826 18827 18828 18829 18830 18831 18832 18833 18834 18835 18836 18837 18838 18839 18840 18841 18842 18843 18844 18845 18846 18847 18848 18849 18850 18851 18852 18853 18854 18855 18856 18857 18858 18859 18860 18861 18862 18863 18864 18865 18866 18867 18868 18869 18870 18871 18872 18873 18874 18875 18876 18877 18878 18879 | - + - + - + - + - + - + - + | } /** fsl_list_visitor_f() impl for outputing J cards. obj must be a (fsl_card_J *). */ static int fsl_list_v_mf_output_card_J(void * obj, void * visitorState ){ |
︙ | |||
19054 19055 19056 19057 19058 19059 19060 | 18909 18910 18911 18912 18913 18914 18915 18916 18917 18918 18919 18920 18921 18922 18923 18924 18925 18926 18927 18928 18929 18930 18931 18932 18933 18934 18935 18936 18937 | - + - - + | assert(l); assert(r); if(!l) return r ? 1 : 0; else if(!r) return -1; else{ /* Lexical sorting must account for the +/- characters, and a '+' sorts before '-', which is why this next part may seem |
︙ | |||
19101 19102 19103 19104 19105 19106 19107 | 18955 18956 18957 18958 18959 18960 18961 18962 18963 18964 18965 18966 18967 18968 18969 18970 18971 18972 18973 18974 18975 18976 18977 18978 18979 18980 18981 18982 18983 18984 18985 18986 18987 18988 18989 18990 18991 18992 18993 18994 18995 18996 | - + - + - + | } }else{ fsl_deck_append(os, "Q %c%s\n", prefix, cp->target); } return os->rc; } |
︙ | |||
19330 19331 19332 19333 19334 19335 19336 | 19184 19185 19186 19187 19188 19189 19190 19191 19192 19193 19194 19195 19196 19197 19198 19199 19200 19201 19202 19203 19204 19205 19206 19207 19208 19209 19210 19211 19212 19213 19214 19215 19216 19217 19218 19219 19220 19221 19222 19223 19224 19225 19226 19227 19228 19229 19230 19231 19232 19233 19234 19235 19236 19237 19238 19239 19240 19241 19242 19243 19244 19245 19246 19247 19248 19249 19250 19251 19252 19253 19254 19255 19256 19257 19258 19259 19260 19261 19262 19263 19264 19265 19266 19267 19268 19269 19270 19271 19272 19273 19274 19275 19276 19277 19278 19279 19280 19281 19282 19283 19284 19285 19286 19287 19288 19289 19290 19291 19292 19293 19294 19295 19296 19297 19298 19299 19300 19301 19302 19303 19304 19305 19306 19307 19308 19309 19310 19311 19312 19313 19314 19315 19316 19317 19318 19319 19320 19321 19322 19323 19324 19325 19326 19327 19328 19329 19330 19331 19332 19333 19334 19335 19336 19337 19338 19339 19340 19341 19342 19343 19344 19345 19346 19347 19348 19349 19350 19351 19352 19353 19354 19355 19356 19357 | - + - + - + - + - + - + - + - + - + - + - + - + - + - + | } } return rc; } } /* Appends the T cards to os from os->d->T. */ |
︙ | |||
19513 19514 19515 19516 19517 19518 19519 | 19367 19368 19369 19370 19371 19372 19373 19374 19375 19376 19377 19378 19379 19380 19381 | - + | DOUT(W); return os->rc; } #undef DOUT |
︙ | |||
19555 19556 19557 19558 19559 19560 19561 | 19409 19410 19411 19412 19413 19414 19415 19416 19417 19418 19419 19420 19421 19422 19423 19424 19425 19426 19427 19428 19429 19430 19431 19432 19433 19434 19435 19436 19437 19438 19439 | - + + + + + + | */; } } } return rc; } |
︙ | |||
19657 19658 19659 19660 19661 19662 19663 | 19516 19517 19518 19519 19520 19521 19522 19523 19524 19525 19526 19527 19528 19529 19530 19531 19532 19533 19534 | - - + - - | /** Adds a record in the pending_xlink temp table, to be processed when crosslinking is completed. Returns 0 on success, non-0 for db error. */ static int fsl__deck_crosslink_add_pending(fsl_cx * f, char cType, fsl_uuid_cstr uuid){ |
︙ | |||
19974 19975 19976 19977 19978 19979 19980 | 19830 19831 19832 19833 19834 19835 19836 19837 19838 19839 19840 19841 19842 19843 19844 19845 19846 19847 19848 19849 19850 19851 19852 19853 19854 19855 19856 19857 19858 19859 19860 19861 19862 19863 19864 | - - + + + + + + + | fc->perm = perms; return 0; }else{ return fsl_deck_F_add(d, zName, uuid, perms, priorName); } } |
︙ | |||
20727 20728 20729 20730 20731 20732 20733 20734 20735 20736 20737 20738 20739 20740 20741 20742 | 20588 20589 20590 20591 20592 20593 20594 20595 20596 20597 20598 20599 20600 20601 20602 20603 20604 20605 20606 20607 20608 20609 20610 20611 20612 20613 20614 20615 20616 20617 20618 20619 20620 20621 20622 20623 20624 20625 20626 20627 20628 20629 20630 20631 20632 20633 20634 20635 20636 20637 20638 20639 20640 20641 20642 20643 20644 20645 20646 20647 20648 20649 20650 20651 20652 20653 20654 20655 20656 20657 20658 20659 20660 20661 20662 20663 20664 20665 20666 20667 20668 20669 20670 20671 20672 20673 20674 20675 20676 20677 20678 20679 20680 20681 20682 20683 20684 20685 20686 20687 20688 20689 20690 20691 20692 20693 20694 20695 | + + + + + + + + + + + + + + + + + + - - + + - + - + - + - + - + - + - + - + | } if(!rc && parentId){ rc = fsl__tag_propagate_all(d->f, parentId); } return rc; } int fsl__call_xlink_listeners(fsl_deck * const d){ int rc = 0; fsl_xlinker * xl = NULL; fsl_cx_err_reset(d->f); for( fsl_size_t i = 0; !rc && (i < d->f->xlinkers.used); ++i ){ xl = d->f->xlinkers.list+i; rc = xl->f( d, xl->state ); } if(rc && !d->f->error.code){ assert(xl); rc = fsl_cx_err_set(d->f, rc, "Crosslink callback handler " "'%s' failed with code %d (%s) for " "artifact RID #%" FSL_ID_T_PFMT ".", xl->name, rc, fsl_rc_cstr(rc), d->rid); } return rc; } /** Overrideable crosslink listener which updates the timeline for attachment records. */ static int fsl_deck_xlink_f_attachment(fsl_deck * const d, void * state){ if(FSL_SATYPE_ATTACHMENT!=d->type) return 0; int rc; fsl_db * const db = fsl_cx_db_repo(d->f); |
︙ | |||
20869 20870 20871 20872 20873 20874 20875 | 20748 20749 20750 20751 20752 20753 20754 20755 20756 20757 20758 20759 20760 20761 20762 | - + | construct. Note that we are using a lot of historical code which hard-codes english-lanuage text and links which only work in fossil(1). i would prefer to farm this out to a crosslink callback, and provide a default implementation which more or less mimics fossil(1). */ int rc = 0; |
︙ | |||
20906 20907 20908 20909 20910 20911 20912 | 20785 20786 20787 20788 20789 20790 20791 20792 20793 20794 20795 20796 20797 20798 20799 20800 20801 20802 20803 20804 20805 20806 20807 20808 20809 20810 20811 20812 20813 20814 20815 20816 20817 20818 20819 20820 20821 20822 20823 20824 20825 20826 20827 20828 20829 20830 20831 20832 20833 20834 20835 20836 20837 20838 20839 20840 20841 20842 20843 20844 20845 20846 20847 20848 20849 20850 20851 20852 20853 20854 20855 20856 20857 20858 20859 20860 20861 20862 20863 20864 20865 20866 20867 20868 20869 20870 20871 20872 20873 20874 20875 20876 20877 20878 20879 20880 20881 20882 20883 20884 20885 20886 20887 20888 20889 20890 20891 20892 20893 | - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + | That said, sorting by UUID would have a nice side-effect on the output of grouping tags by the UUID they tag. So far (201404) such groups of tags have not appeared in the wild because fossil(1) has no mechanism for creating them. */ for( i = 0; !rc && (i < li->used); ++i, prevTag = tag){ |
︙ | |||
21198 21199 21200 21201 21202 21203 21204 | 21077 21078 21079 21080 21081 21082 21083 21084 21085 21086 21087 21088 21089 21090 21091 | - + | to do all updates to the event (timeline) table via these crosslinkers and perform the core, UI-agnostic, crosslinking bits in the internal fsl__deck_crosslink_XXX() functions. That should allow clients to override how the timeline is updated without requiring them to understand the rest of the required schema updates. */ |
︙ | |||
21500 21501 21502 21503 21504 21505 21506 | 21379 21380 21381 21382 21383 21384 21385 21386 21387 21388 21389 21390 21391 21392 21393 21394 21395 21396 21397 21398 21399 21400 21401 21402 21403 21404 21405 21406 21407 21408 21409 21410 21411 21412 21413 21414 21415 21416 21417 21418 21419 21420 21421 21422 21423 21424 21425 21426 21427 21428 21429 21430 21431 21432 21433 21434 21435 21436 21437 21438 | - - - + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + | end: return rc; } static int fsl__deck_crosslink_ticket(fsl_deck * const d){ int rc; fsl_cx * const f = d->f; |
︙ | |||
21606 21607 21608 21609 21610 21611 21612 | 21512 21513 21514 21515 21516 21517 21518 21519 21520 21521 21522 21523 21524 21525 21526 21527 21528 21529 21530 21531 21532 21533 21534 21535 21536 21537 21538 21539 21540 21541 21542 21543 | - - - - - + + + + - - + - - + - - - - - - - - - - - - - - - - + - | rc = fsl__deck_crosslink_attachment(d); break; /* FSL_SATYPE_CONTROL is handled above except for the timeline update, which is handled by a callback below */ default: break; } |
︙ | |||
21745 21746 21747 21748 21749 21750 21751 | 21632 21633 21634 21635 21636 21637 21638 21639 21640 21641 21642 21643 21644 21645 21646 21647 21648 21649 21650 21651 21652 21653 21654 21655 21656 21657 21658 21659 21660 21661 21662 21663 21664 21665 21666 21667 21668 21669 21670 21671 21672 21673 21674 21675 21676 21677 21678 21679 21680 21681 21682 21683 21684 21685 21686 21687 21688 21689 21690 21691 21692 21693 21694 21695 21696 21697 21698 21699 21700 | - + - + - + - - + + - - - + + + + + - - - + + + + + + - - - - + - + - + - + - + | *pn = (fsl_size_t)n; return; } /** Internal helper for parsing manifests. Holds a source file (memory |
︙ | |||
21878 21879 21880 21881 21882 21883 21884 | 21767 21768 21769 21770 21771 21772 21773 21774 21775 21776 21777 21778 21779 21780 21781 21782 21783 21784 21785 21786 21787 21788 21789 21790 21791 21792 21793 21794 21795 21796 21797 21798 21799 21800 21801 21802 21803 21804 21805 21806 21807 21808 21809 21810 21811 21812 21813 21814 21815 21816 21817 21818 21819 21820 21821 21822 21823 21824 21825 21826 21827 21828 21829 21830 21831 21832 21833 21834 21835 21836 21837 21838 21839 21840 21841 21842 21843 21844 21845 21846 | - + - - - + + - + - - - - - - - - - - - - - + + + + + + + - - + - - + - - + + + + + - - - - - - - + - + - - + + + | #ifdef ERROR # undef ERROR #endif #define ERROR(RC,MSG) do{ rc = (RC); zMsg = (MSG); goto bailout; } while(0) #define SYNTAX(MSG) ERROR(rc ? rc : FSL_RC_SYNTAX,MSG) bool isRepeat = 0/* , hasSelfRefTag = 0 */; int rc = 0; |
︙ | |||
21980 21981 21982 21983 21984 21985 21986 | 21858 21859 21860 21861 21862 21863 21864 21865 21866 21867 21868 21869 21870 21871 21872 21873 21874 21875 21876 21877 21878 21879 21880 21881 21882 21883 21884 21885 21886 21887 21888 21889 21890 21891 21892 21893 21894 21895 21896 21897 21898 21899 | - + - + - + - + | if( !isRepeat ) g.parseCnt[0]++; */ /* Reminder: parsing modifies the input (to simplify the tokenization/parsing). As of mid-201403, we recycle as much as possible from the source |
︙ | |||
22029 22030 22031 22032 22033 22034 22035 | 21907 21908 21909 21910 21911 21912 21913 21914 21915 21916 21917 21918 21919 21920 21921 | - + | ++lettersSeen[cType-'A']; }else{ SYNTAX("Invalid card name"); } switch(cType){ /* A <filename> <target> ?<source>? |
︙ | |||
22064 22065 22066 22067 22068 22069 22070 | 21942 21943 21944 21945 21946 21947 21948 21949 21950 21951 21952 21953 21954 21955 21956 21957 21958 21959 21960 21961 21962 21963 21964 21965 21966 21967 21968 21969 21970 21971 21972 21973 21974 21975 21976 21977 21978 21979 21980 21981 21982 21983 21984 21985 21986 21987 21988 21989 21990 21991 21992 | - + - + - + | /*rc = fsl_deck_A_set(d, (char const *)name, (char const *)uuid, (char const *)src);*/ d->type = FSL_SATYPE_ATTACHMENT; break; } /* B <uuid> |
︙ | |||
22123 22124 22125 22126 22127 22128 22129 | 22001 22002 22003 22004 22005 22006 22007 22008 22009 22010 22011 22012 22013 22014 22015 22016 22017 22018 22019 22020 22021 22022 22023 22024 22025 22026 22027 22028 22029 22030 22031 22032 22033 22034 22035 22036 22037 22038 22039 22040 22041 22042 22043 22044 22045 22046 22047 22048 22049 22050 22051 22052 22053 22054 22055 22056 22057 22058 | - - - - - - + + + + + + + - + + + - - - - - + + + + + + - - | TOKEN_DATETIME(D,D); rc = fsl_deck_D_set(d, ts); break; } /* E <timestamp> <uuid> |
︙ | |||
22195 22196 22197 22198 22199 22200 22201 | 22075 22076 22077 22078 22079 22080 22081 22082 22083 22084 22085 22086 22087 22088 22089 22090 22091 22092 22093 22094 22095 22096 22097 22098 22099 22100 22101 22102 22103 22104 22105 22106 22107 22108 22109 22110 22111 22112 22113 22114 22115 22116 22117 22118 22119 22120 22121 22122 22123 22124 22125 22126 22127 22128 22129 22130 22131 22132 22133 22134 22135 22136 22137 22138 22139 22140 22141 22142 22143 22144 22145 22146 22147 22148 22149 22150 22151 22152 22153 22154 22155 22156 22157 22158 22159 22160 22161 22162 22163 22164 22165 22166 22167 22168 22169 | - + - + - + - + - - + + | /*MARKER(("Unmatched perms string character: %d / %c !", (int)*perms, *perms));*/ SYNTAX("Invalid perms string character"); } TOKEN(0); if(token) priorName = (char *)token; } fsl_bytes_defossilize( (unsigned char *)name, 0 ); |
︙ | |||
22298 22299 22300 22301 22302 22303 22304 | 22178 22179 22180 22181 22182 22183 22184 22185 22186 22187 22188 22189 22190 22191 22192 22193 22194 22195 22196 22197 22198 22199 22200 22201 22202 22203 22204 22205 22206 22207 22208 22209 22210 22211 22212 22213 22214 22215 22216 22217 22218 22219 22220 22221 22222 22223 22224 22225 22226 22227 22228 22229 22230 22231 22232 22233 22234 22235 22236 22237 22238 22239 22240 22241 22242 22243 22244 22245 22246 22247 22248 22249 22250 22251 22252 22253 22254 22255 22256 22257 22258 22259 22260 22261 22262 22263 22264 | - - + + - - + + - - + + - - + + - - + + | TOKEN(1); rc = fsl_deck_J_add(d, isAppend, field, (char const *)token); d->type = FSL_SATYPE_TICKET; break; } /* |
︙ | |||
22400 22401 22402 22403 22404 22405 22406 | 22280 22281 22282 22283 22284 22285 22286 22287 22288 22289 22290 22291 22292 22293 22294 22295 | - - + + | if(!rc){ TOKEN(0); } } break; } /* |
︙ | |||
22428 22429 22430 22431 22432 22433 22434 | 22308 22309 22310 22311 22312 22313 22314 22315 22316 22317 22318 22319 22320 22321 22322 22323 22324 22325 22326 22327 22328 22329 22330 22331 22332 22333 22334 22335 22336 22337 22338 22339 22340 22341 22342 22343 22344 22345 22346 22347 22348 22349 22350 22351 | - - + + - - - + + + - - - + + + - + | } d->type = FSL_SATYPE_CHECKIN; rc = fsl_deck_Q_add(d, qType, (char const *)uuid, (char const *)token); break; } /* |
︙ | |||
22494 22495 22496 22497 22498 22499 22500 | 22374 22375 22376 22377 22378 22379 22380 22381 22382 22383 22384 22385 22386 22387 22388 22389 22390 22391 22392 22393 22394 22395 22396 22397 22398 22399 22400 22401 22402 22403 22404 22405 22406 22407 22408 22409 22410 22411 22412 22413 22414 22415 22416 22417 22418 22419 22420 22421 22422 | - + - - + + + + + + + + + + + + + + + + + + + + + + + + + - - + + | case '+': tagType = FSL_TAGTYPE_ADD; ++nSimpleTag; break; case '-': tagType = FSL_TAGTYPE_CANCEL; break; default: SYNTAX("Malformed tag name"); } ++name /* skip type marker byte */; |
︙ | |||
22543 22544 22545 22546 22547 22548 22549 | 22446 22447 22448 22449 22450 22451 22452 22453 22454 22455 22456 22457 22458 22459 22460 22461 22462 22463 22464 22465 22466 22467 22468 22469 22470 22471 22472 22473 22474 | - - + + + + - + | wlen = fsl_str_to_size((char const *)token); if((fsl_size_t)-1==wlen){ SYNTAX("Wiki size token is invalid"); } if( (&x.z[wlen+1]) > x.zEnd){ SYNTAX("Not enough content after W-card"); } |
︙ | |||
22610 22611 22612 22613 22614 22615 22616 | 22515 22516 22517 22518 22519 22520 22521 22522 22523 22524 22525 22526 22527 22528 22529 | - + - | rc = d->f->error.code; goto bailout; } if(FSL_SATYPE_ANY==d->type){ rc = fsl_cx_err_set(f, FSL_RC_ERROR, "Internal error: could not determine type of " |
︙ | |||
22645 22646 22647 22648 22649 22650 22651 | 22549 22550 22551 22552 22553 22554 22555 22556 22557 22558 22559 22560 22561 22562 22563 22564 22565 22566 22567 22568 22569 22570 22571 22572 22573 22574 22575 22576 22577 22578 22579 | - + - + - + - + | FSL_SATYPE_FORUMPOST==d->type); assert(0==rc); /* Additional checks based on artifact type */ switch( d->type ){ case FSL_SATYPE_CONTROL: { if( nSelfTag ){ |
︙ | |||
22930 22931 22932 22933 22934 22935 22936 | 22834 22835 22836 22837 22838 22839 22840 22841 22842 22843 22844 22845 22846 22847 22848 | - + | #undef FCARD } int fsl_deck_save( fsl_deck * const d, bool isPrivate ){ int rc; fsl_cx * const f = d->f; fsl_db * const db = fsl_needs_repo(f); |
︙ | |||
23108 23109 23110 23111 23112 23113 23114 | 23012 23013 23014 23015 23016 23017 23018 23019 23020 23021 23022 23023 23024 23025 23026 23027 23028 23029 23030 23031 23032 23033 23034 23035 23036 23037 23038 23039 23040 23041 23042 23043 | - - + - - + - - + + + | if(rc) break; } fsl_stmt_finalize(&q); if(rc) goto end; /* Process entries from pending_xlink temp table... */ rc = fsl_cx_prepare(f, &q, "SELECT id FROM pending_xlink"); |
︙ | |||
23164 23165 23166 23167 23168 23169 23170 | 23067 23068 23069 23070 23071 23072 23073 23074 23075 23076 23077 23078 23079 23080 23081 23082 23083 23084 23085 23086 23087 23088 23089 23090 23091 23092 23093 23094 23095 23096 23097 23098 23099 23100 23101 23102 23103 23104 23105 23106 23107 23108 23109 23110 23111 23112 23113 23114 23115 23116 23117 23118 23119 23120 23121 | - - + - + - - + + - + + + - - + + | rc = fsl_cx_exec(f, "UPDATE event SET" " mtime=(SELECT m1 FROM time_fudge WHERE mid=objid)" " WHERE objid IN (SELECT mid FROM time_fudge)" " AND (mtime=omtime OR omtime IS NULL)" ); } end: |
︙ | |||
23454 23455 23456 23457 23458 23459 23460 | 23358 23359 23360 23361 23362 23363 23364 23365 23366 23367 23368 23369 23370 23371 23372 23373 23374 23375 23376 23377 23378 23379 23380 23381 | - - + | unsigned int i, base; unsigned int nHash; /* Number of hash table entries */ unsigned int *landmark; /* Primary hash table */ unsigned int *collide = NULL; /* Collision chain */ int lastRead = -1; /* Last byte of zSrc read by a COPY command */ int rc; /* generic return code checker. */ unsigned int olen = 0; /* current output length. */ |
︙ | |||
23850 23851 23852 23853 23854 23855 23856 | 23753 23754 23755 23756 23757 23758 23759 23760 23761 23762 23763 23764 23765 23766 23767 23768 | - - + + | ){ return fsl_delta_apply2(zSrc, lenSrc_, zDelta, lenDelta_, zOut, NULL); } #undef NHASH #undef DEBUG1 #undef DEBUG2 |
︙ | |||
23873 23874 23875 23876 23877 23878 23879 | 23776 23777 23778 23779 23780 23781 23782 23783 23784 23785 23786 23787 23788 23789 23790 23791 23792 23793 23794 23795 23796 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | the delta-generation). */ #include <assert.h> #include <memory.h> #include <stdlib.h> #include <string.h> /* for memmove()/strlen() */ |
︙ | |||
24200 24201 24202 24203 24204 24205 24206 24207 24208 24209 24210 24211 24212 24213 24214 24215 | 23866 23867 23868 23869 23870 23871 23872 23873 23874 23875 23876 23877 23878 23879 23880 23881 23882 23883 23884 23885 23886 23887 23888 23889 23890 23891 23892 23893 23894 23895 23896 23897 23898 23899 23900 23901 23902 23903 23904 23905 23906 23907 23908 23909 23910 23911 23912 23913 23914 23915 23916 23917 23918 23919 23920 23921 23922 23923 23924 23925 23926 23927 23928 23929 23930 23931 23932 23933 23934 23935 23936 23937 23938 23939 23940 23941 23942 23943 23944 23945 | + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + - - - - | int dist = 0; /* Distance of match from center */ int mid; /* Center of the chng */ int iSXb, iSYb, iEXb, iEYb; /* Best match so far */ int iSXp, iSYp, iEXp, iEYp; /* Previous match */ sqlite3_int64 bestScore; /* Best score so far */ sqlite3_int64 score; /* Score for current candidate LCS */ int span; /* combined width of the input sequences */ int cutoff = 4; /* Max hash chain entries to follow */ int nextCutoff = -1; /* Value of cutoff for next iteration */ span = (iE1 - iS1) + (iE2 - iS2); bestScore = -10000; score = 0; iSXb = iSXp = iS1; iEXb = iEXp = iS1; iSYb = iSYp = iS2; iEYb = iEYp = iS2; mid = (iE1 + iS1)/2; do{ nextCutoff = 0; |
︙ | |||
24533 24534 24535 24536 24537 24538 24539 24540 24541 24542 24543 24544 24545 24546 | 24193 24194 24195 24196 24197 24198 24199 24200 24201 24202 24203 24204 24205 24206 24207 24208 24209 24210 24211 24212 24213 24214 24215 24216 24217 24218 24219 24220 24221 24222 24223 24224 24225 24226 24227 24228 24229 24230 24231 24232 24233 24234 24235 24236 24237 24238 24239 24240 24241 24242 24243 24244 24245 24246 24247 24248 24249 24250 24251 24252 24253 24254 24255 24256 24257 24258 24259 24260 24261 24262 24263 24264 24265 24266 24267 24268 24269 24270 24271 24272 24273 24274 24275 24276 24277 24278 24279 24280 24281 24282 24283 24284 24285 24286 24287 24288 24289 24290 24291 24292 24293 24294 24295 24296 24297 24298 24299 24300 24301 24302 24303 24304 24305 24306 24307 24308 24309 24310 24311 24312 24313 24314 24315 24316 24317 24318 24319 24320 24321 24322 24323 24324 24325 24326 24327 24328 24329 24330 24331 24332 24333 24334 24335 24336 24337 24338 24339 24340 24341 24342 24343 24344 24345 24346 24347 24348 24349 24350 24351 24352 24353 24354 24355 24356 24357 24358 24359 24360 24361 24362 24363 24364 24365 24366 24367 24368 24369 24370 24371 24372 24373 24374 24375 24376 24377 24378 24379 24380 24381 24382 24383 24384 24385 24386 24387 24388 24389 24390 24391 24392 24393 24394 24395 24396 24397 24398 24399 24400 24401 24402 24403 24404 24405 24406 24407 24408 24409 24410 24411 24412 24413 24414 24415 24416 24417 24418 24419 24420 24421 24422 24423 24424 24425 24426 24427 24428 24429 24430 24431 24432 24433 24434 24435 24436 24437 24438 24439 24440 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | lnFrom += del; lnTo += ins; } //fsl__dump_triples(p, __FILE__, __LINE__); } #if !defined(FSL_OMIT_DEPRECATED) #define MARKER(pfexp) \ do{ printf("MARKER: %s:%d:%s():\t",__FILE__,__LINE__,__func__); \ printf pfexp; \ } while(0) typedef uint64_t u64; typedef void ReCompiled /* porting crutch. i would strongly prefer to replace the regex support with a stateful predicate callback. */; #define DIFF_CONTEXT_MASK ((u64)0x0000ffff) /* Lines of context. Default if 0 */ #define DIFF_WIDTH_MASK ((u64)0x00ff0000) /* side-by-side column width */ #define DIFF_IGNORE_EOLWS ((u64)0x01000000) /* Ignore end-of-line whitespace */ #define DIFF_IGNORE_ALLWS ((u64)0x03000000) /* Ignore all whitespace */ #define DIFF_SIDEBYSIDE ((u64)0x04000000) /* Generate a side-by-side diff */ #define DIFF_VERBOSE ((u64)0x08000000) /* Missing shown as empty files */ #define DIFF_BRIEF ((u64)0x10000000) /* Show filenames only */ #define DIFF_HTML ((u64)0x20000000) /* Render for HTML */ #define DIFF_LINENO ((u64)0x40000000) /* Show line numbers */ #define DIFF_NOOPT (((u64)0x01)<<32) /* Suppress optimizations (debug) */ #define DIFF_INVERT (((u64)0x02)<<32) /* Invert the diff (debug) */ #define DIFF_CONTEXT_EX (((u64)0x04)<<32) /* Use context even if zero */ #define DIFF_NOTTOOBIG (((u64)0x08)<<32) /* Only display if not too big */ #define DIFF_STRIP_EOLCR (((u64)0x10)<<32) /* Strip trailing CR */ /* ANSI escape codes: https://en.wikipedia.org/wiki/ANSI_escape_code */ #define ANSI_COLOR_BLACK(BOLD) ((BOLD) ? "\x1b[30m" : "\x1b[30m") #define ANSI_COLOR_RED(BOLD) ((BOLD) ? "\x1b[31;1m" : "\x1b[31m") #define ANSI_COLOR_GREEN(BOLD) ((BOLD) ? "\x1b[32;1m" : "\x1b[32m") #define ANSI_COLOR_YELLOW(BOLD) ((BOLD) ? "\x1b[33;1m" : "\x1b[33m") #define ANSI_COLOR_BLUE(BOLD) ((BOLD) ? "\x1b[34;1m" : "\x1b[34m") #define ANSI_COLOR_MAGENTA(BOLD) ((BOLD) ? "\x1b[35;1m" : "\x1b[35m") #define ANSI_COLOR_CYAN(BOLD) ((BOLD) ? "\x1b[36;1m" : "\x1b[36m") #define ANSI_COLOR_WHITE(BOLD) ((BOLD) ? "\x1b[37;1m" : "\x1b[37m") #define ANSI_DIFF_ADD(BOLD) ANSI_COLOR_GREEN(BOLD) #define ANSI_DIFF_RM(BOLD) ANSI_COLOR_RED(BOLD) #define ANSI_DIFF_MOD(BOLD) ANSI_COLOR_BLUE(BOLD) #define ANSI_BG_BLACK(BOLD) ((BOLD) ? "\x1b[40;1m" : "\x1b[40m") #define ANSI_BG_RED(BOLD) ((BOLD) ? "\x1b[41;1m" : "\x1b[41m") #define ANSI_BG_GREEN(BOLD) ((BOLD) ? "\x1b[42;1m" : "\x1b[42m") #define ANSI_BG_YELLOW(BOLD) ((BOLD) ? "\x1b[43;1m" : "\x1b[43m") #define ANSI_BG_BLUE(BOLD) ((BOLD) ? "\x1b[44;1m" : "\x1b[44m") #define ANSI_BG_MAGENTA(BOLD) ((BOLD) ? "\x1b[45;1m" : "\x1b[45m") #define ANSI_BG_CYAN(BOLD) ((BOLD) ? "\x1b[46;1m" : "\x1b[46m") #define ANSI_BG_WHITE(BOLD) ((BOLD) ? "\x1b[47;1m" : "\x1b[47m") #define ANSI_RESET_COLOR "\x1b[39;49m" #define ANSI_RESET_ALL "\x1b[0m" #define ANSI_RESET ANSI_RESET_ALL /*#define ANSI_BOLD ";1m"*/ /** Converts mask of public fsl_diff_flag_t (32-bit) values to the Fossil-internal 64-bit bitmask used by the DIFF_xxx macros. Why? (A) fossil(1) uses the macro approach and a low-level encoding of data in the bitmask (e.g. the context lines count). The public API hides the lower-level flags and allows the internal API to take care of the encoding. */ static uint64_t fsl_diff_flags_convert( int mask ){ uint64_t rc = 0U; #define DO(F) if( (mask & F)==F ) rc |= (((u64)F) << 24) DO(FSL_DIFF2_IGNORE_EOLWS); DO(FSL_DIFF2_IGNORE_ALLWS); DO(FSL_DIFF2_LINE_NUMBERS); DO(FSL_DIFF_SIDEBYSIDE); DO(FSL_DIFF2_NOTTOOBIG); DO(FSL_DIFF2_STRIP_EOLCR); DO(FSL_DIFF_VERBOSE); DO(FSL_DIFF_BRIEF); DO(FSL_DIFF_HTML); DO(FSL_DIFF_NOOPT); DO(FSL_DIFF_INVERT); #undef DO return rc; } /** Holds output state for diff generation. */ struct DiffOutState { /** Output callback. */ fsl_output_f out; /** State for this->out(). */ void * oState; /** For propagating output errors. */ int rc; char ansiColor; }; typedef struct DiffOutState DiffOutState; static const DiffOutState DiffOutState_empty = { NULL/*out*/, NULL/*oState*/, 0/*rc*/, 0/*useAnsiColor*/ }; /** Internal helper. Sends src to o->out(). If n is negative, fsl_strlen() is used to determine the length. */ static int diff_out( DiffOutState * const o, void const * src, fsl_int_t n ){ return o->rc = n ? o->out(o->oState, src, n<0 ? fsl_strlen((char const *)src) : (fsl_size_t)n) : 0; } /** fsl_output_f() impl for use with diff_outf(). state must be a (DiffOutState*). */ static int fsl_output_f_diff_out( void * state, void const * src, fsl_size_t n ){ DiffOutState * const os = (DiffOutState *)state; return os->rc = os->out(os->oState, src, n); } static int diff_outf( DiffOutState * o, char const * fmt, ... ){ va_list va; va_start(va,fmt); fsl_appendfv(fsl_output_f_diff_out, o, fmt, va); va_end(va); return o->rc; } /* Append a single line of context-diff output to pOut. */ static int appendDiffLine( DiffOutState *const pOut, /* Where to write the line of output */ char cPrefix, /* One of " ", "+", or "-" */ fsl_dline *pLine, /* The line to be output */ int html, /* True if generating HTML. False for plain text */ ReCompiled *pRe /* Colorize only if line matches this Regex */ ){ int rc = 0; char const * ansiPrefix = !pOut->ansiColor ? NULL : (('+'==cPrefix) ? ANSI_DIFF_ADD(0) : (('-'==cPrefix) ? ANSI_DIFF_RM(0) : NULL)) ; if(ansiPrefix) rc = diff_out(pOut, ansiPrefix, -1 ); if(!rc) rc = diff_out(pOut, &cPrefix, 1); if(rc) return rc; else if( html ){ #if 0 if( pRe /*MISSING: && re_dline_match(pRe, pLine, 1)==0 */ ){ cPrefix = ' '; }else #endif if( cPrefix=='+' ){ rc = diff_out(pOut, "<span class=\"fsl-diff-add\">", -1); }else if( cPrefix=='-' ){ rc = diff_out(pOut, "<span class=\"fsl-diff-rm\">", -1); } if(!rc){ /* unsigned short n = pLine->n; */ /* while( n>0 && (pLine->z[n-1]=='\n' || pLine->z[n-1]=='\r') ) n--; */ rc = pOut->rc = fsl_htmlize(pOut->out, pOut->oState, pLine->z, pLine->n); if( !rc && cPrefix!=' ' ){ rc = diff_out(pOut, "</span>", -1); } } }else{ rc = diff_out(pOut, pLine->z, pLine->n); } if(!rc){ if(ansiPrefix){ rc = diff_out(pOut, ANSI_RESET, -1 ); } if(!rc) rc = diff_out(pOut, "\n", 1); } return rc; } /* Add two line numbers to the beginning of an output line for a context diff. One or the other of the two numbers might be zero, which means to leave that number field blank. The "html" parameter means to format the output for HTML. */ static int appendDiffLineno(DiffOutState *pOut, int lnA, int lnB, int html){ int rc = 0; if( html ){ rc = diff_out(pOut, "<span class=\"fsl-diff-lineno\">", -1); } if(!rc){ if( lnA>0 ){ rc = diff_outf(pOut, "%6d ", lnA); }else{ rc = diff_out(pOut, " ", 7); } } if(!rc){ if( lnB>0 ){ rc = diff_outf(pOut, "%6d ", lnB); }else{ rc = diff_out(pOut, " ", 8); } if( !rc && html ){ rc = diff_out(pOut, "</span>", -1); } } return rc; } /** Extract the number of lines of context from diffFlags. */ static int diff_context_lines(uint64_t diffFlags){ int n = diffFlags & DIFF_CONTEXT_MASK; if( n==0 && (diffFlags & DIFF_CONTEXT_EX)==0 ) n = 5; return n; } /* Extract the width of columns for side-by-side diff. Supply an appropriate default if no width is given. */ static int diff_width(uint64_t diffFlags){ int w = (diffFlags & DIFF_WIDTH_MASK)/(DIFF_CONTEXT_MASK+1); if( w==0 ) w = 80; return w; } /* Given a raw diff p[] in which the p->aEdit[] array has been filled in, compute a context diff into pOut. */ static int contextDiff( fsl__diff_cx *p, /* The difference */ |
︙ | |||
25435 25436 25437 25438 25439 25440 25441 | 25329 25330 25331 25332 25333 25334 25335 25336 25337 25338 25339 25340 25341 25342 | - | int rc = 0; int a = 0; /* Index of next line in A[] */ int b = 0; /* Index of next line in B[] */ int *R; /* Array of COPY/DELETE/INSERT triples */ int r; /* Index into R[] */ int nr; /* Number of COPY/DELETE/INSERT triples to process */ int mxr; /* Maximum value for r */ |
︙ | |||
25505 25506 25507 25508 25509 25510 25511 | 25398 25399 25400 25401 25402 25403 25404 25405 25406 25407 25408 25409 25410 25411 25412 25413 25414 25415 25416 25417 | - + - - - - - - - - - - - - - - - - - - | a = xa; b = xb; continue; } } #endif /* For the current block comprising nr triples, figure out |
︙ | |||
25842 25843 25844 25845 25846 25847 25848 | 25717 25718 25719 25720 25721 25722 25723 25724 25725 25726 25727 25728 25729 25730 | - - | short contextLines, short sbsWidth, int diffFlags ){ return fsl_diff_text_impl(pA, pB, out, outState, contextLines, sbsWidth, diffFlags, NULL ); } |
︙ | |||
25876 25877 25878 25879 25880 25881 25882 | 25749 25750 25751 25752 25753 25754 25755 25756 25757 25758 25759 25760 25761 25762 | - - | #undef DIFF_NOTTOOBIG #undef DIFF_STRIP_EOLCR #undef SBS_LNA #undef SBS_TXTA #undef SBS_MKR #undef SBS_LNB #undef SBS_TXTB |
︙ | |||
25901 25902 25903 25904 25905 25906 25907 | 25772 25773 25774 25775 25776 25777 25778 25779 25780 25781 25782 25783 25784 25785 25786 25787 25788 25789 25790 25791 25792 25793 25794 25795 25796 25797 25798 25799 25800 25801 25802 25803 25804 25805 25806 25807 25808 25809 25810 25811 25812 25813 25814 25815 25816 25817 25818 25819 | + - - + + - - - + + | #undef ANSI_BG_WHITE #undef ANSI_RESET_COLOR #undef ANSI_RESET_ALL #undef ANSI_RESET #undef ANSI_DIFF_ADD #undef ANSI_DIFF_MOD #undef ANSI_DIFF_RM #endif /*FSL_OMIT_DEPRECATED*/ |
︙ | |||
26387 26388 26389 26390 26391 26392 26393 26394 26395 26396 26397 26398 26399 26400 26401 26402 26403 26404 26405 26406 26407 | 26258 26259 26260 26261 26262 26263 26264 26265 26266 26267 26268 26269 26270 26271 26272 26273 26274 26275 26276 26277 26278 26279 26280 26281 26282 26283 26284 26285 26286 26287 26288 26289 26290 26291 26292 26293 26294 26295 26296 26297 26298 26299 26300 26301 26302 26303 26304 26305 26306 26307 26308 26309 26310 26311 26312 26313 26314 26315 26316 26317 26318 26319 26320 26321 26322 26323 26324 26325 26326 26327 26328 26329 26330 26331 26332 26333 26334 26335 26336 26337 26338 26339 26340 26341 26342 26343 26344 26345 26346 26347 26348 26349 26350 26351 26352 26353 26354 26355 26356 26357 26358 26359 26360 26361 26362 26363 26364 26365 26366 26367 26368 26369 26370 26371 26372 26373 26374 26375 26376 26377 26378 26379 26380 26381 26382 26383 26384 26385 26386 26387 26388 26389 26390 26391 26392 26393 26394 26395 26396 26397 26398 26399 26400 26401 26402 26403 26404 26405 26406 26407 26408 26409 26410 26411 26412 26413 26414 26415 26416 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + | /* ** The threshold at which diffBlockAlignment transitions from the ** O(N*N) Wagner minimum-edit-distance algorithm to a less process ** O(NlogN) divide-and-conquer approach. */ #define DIFF_ALIGN_MX 1225 /** FSL_DIFF_SMALL_GAP=0 is a temporary(? as of 2022-01-04) patch for a cosmetic-only (but unsightly) quirk of the diff engine where it produces a pair of identical DELETE/INSERT lines. Richard's preliminary solution for it is to remove the "small gap merging," but he notes (in fossil /chat) that he's not recommending this as "the" fix. PS: we colloquially know this as "the lineno diff" because it was first reported in a diff which resulted in: ``` - int lineno; + int lineno; ``` (No, there are no whitespace changes there.) To reiterate, though: this is not a "bug," in that it does not cause incorrect results when applying the resulting unfified-diff patches. It does, however, cause confusion for human users. Here are two inputs which, when diffed, expose the lineno behavior: #1: ``` struct fnc_diff_view_state { int first_line_onscreen; int last_line_onscreen; int diff_flags; int context; int sbs; int matched_line; int current_line; int lineno; size_t ncols; size_t nlines; off_t *line_offsets; bool eof; bool colour; bool showmeta; bool showln; }; ``` #2: ``` struct fnc_diff_view_state { int first_line_onscreen; int last_line_onscreen; int diff_flags; int context; int sbs; int matched_line; int selected_line; int lineno; int gtl; size_t ncols; size_t nlines; off_t *line_offsets; bool eof; bool colour; bool showmeta; bool showln; }; ``` Result without this patch: ``` Index: X.0 ================================================================== --- X.0 +++ X.1 @@ -3,15 +3,16 @@ int last_line_onscreen; int diff_flags; int context; int sbs; int matched_line; + int selected_line; - int current_line; - int lineno; + int lineno; + int gtl; size_t ncols; size_t nlines; off_t *line_offsets; bool eof; bool colour; bool showmeta; bool showln; }; ``` And with the patch: ``` Index: X.0 ================================================================== --- X.0 +++ X.1 @@ -3,15 +3,16 @@ int last_line_onscreen; int diff_flags; int context; int sbs; int matched_line; - int current_line; + int selected_line; int lineno; + int gtl; size_t ncols; size_t nlines; off_t *line_offsets; bool eof; bool colour; bool showmeta; bool showln; }; ``` */ #define FSL_DIFF_SMALL_GAP 0 #if FSL_DIFF_SMALL_GAP /* ** R[] is an array of six integer, two COPY/DELETE/INSERT triples for a ** pair of adjacent differences. Return true if the gap between these ** two differences is so small that they should be rendered as a single ** edit. */ static int smallGap2(const int *R, int ma, int mb){ int m = R[3]; ma += R[4] + m; mb += R[5] + m; if( ma*mb>DIFF_ALIGN_MX ) return 0; return m<=2 || m<=(R[1]+R[2]+R[4]+R[5])/8; } #endif |
︙ | |||
26520 26521 26522 26523 26524 26525 26526 | 26521 26522 26523 26524 26525 26526 26527 26528 26529 26530 26531 26532 26533 26534 26535 | - + | ** each other. Insertion and deletion costs are 50. Match costs ** are between 0 and 100 where 0 is a perfect match 100 is a complete ** mismatch. */ static int diffBlockAlignment( const fsl_dline *aLeft, int nLeft, /* Text on the left */ const fsl_dline *aRight, int nRight, /* Text on the right */ |
︙ | |||
26703 26704 26705 26706 26707 26708 26709 | 26704 26705 26706 26707 26708 26709 26710 26711 26712 26713 26714 26715 26716 26717 26718 26719 26720 26721 26722 26723 26724 26725 26726 26727 26728 26729 26730 26731 26732 26733 26734 26735 26736 26737 26738 26739 26740 26741 26742 26743 26744 26745 26746 26747 26748 26749 26750 26751 26752 26753 26754 26755 26756 26757 26758 26759 26760 26761 26762 26763 26764 26765 26766 26767 | - + - + - + - + + + - + - - + | end: fsl_free(pToFree); return rc; } /* |
︙ | |||
26806 26807 26808 26809 26810 26811 26812 | 26808 26809 26810 26811 26812 26813 26814 26815 26816 26817 26818 26819 26820 26821 26822 26823 26824 26825 26826 26827 26828 26829 26830 26831 26832 26833 26834 26835 26836 26837 26838 26839 26840 | - - - - - + + + + + + + + + + + + + + + + + + + | for(i=1; i<nr; i++){ na += R[r+i*3]; nb += R[r+i*3]; } //MARKER(("Chunk header... a=%u, b=%u, na=%u, nb=%u, skip=%d\n", a, b, na, nb, skip)); if(pBuilder->chunkHeader |
︙ | |||
26834 26835 26836 26837 26838 26839 26840 | 26850 26851 26852 26853 26854 26855 26856 26857 26858 26859 26860 26861 26862 26863 26864 26865 26866 26867 | - - + + + + | //MARKER(("Show the initial common... a=%u, b=%u, m=%u, r=%u, skip=%d\n", a, b, m, r, skip)); if( skip>0 ){ if( NULL==pBuilder->chunkHeader && skip<(int)contextLines ){ /* 2021-09-27: BUG: this is incompatible with unified diff format. The generated header lines say we're skipping X lines but we then end up including lines which that header says to skip. As a workaround, we'll only run this when |
︙ | |||
26871 26872 26873 26874 26875 26876 26877 | 26889 26890 26891 26892 26893 26894 26895 26896 26897 26898 26899 26900 26901 26902 26903 26904 26905 26906 26907 26908 26909 26910 26911 26912 26913 26914 26915 26916 26917 26918 26919 26920 26921 26922 26923 26924 26925 26926 26927 26928 26929 26930 26931 26932 26933 26934 26935 26936 26937 26938 26939 26940 26941 26942 26943 26944 26945 26946 26947 26948 26949 26950 26951 26952 26953 26954 26955 26956 26957 26958 26959 | + - + + + + - + + + | /* Show the differences */ for(i=0; i<nr; i++){ unsigned int nAlign; unsigned char *alignment = 0; ma = R[r+i*3+1]; /* Lines on left but not on right */ mb = R[r+i*3+2]; /* Lines on right but not on left */ #if FSL_DIFF_SMALL_GAP |
︙ | |||
26966 26967 26968 26969 26970 26971 26972 26973 26974 26975 26976 26977 26978 26979 | 26990 26991 26992 26993 26994 26995 26996 26997 26998 26999 27000 27001 27002 27003 27004 | + | RC; } if( R[r]>(int)contextLines ){ rc = pBuilder->skip(pBuilder, R[r] - contextLines); } end: #undef RC #undef METRIC if(0==rc){ if(pBuilder->finish) pBuilder->finish(pBuilder); if(pBuilder->twoPass && 1==passNumber){ goto pass_again; } } return rc; |
︙ | |||
26994 26995 26996 26997 26998 26999 27000 | 27019 27020 27021 27022 27023 27024 27025 27026 27027 27028 27029 27030 27031 27032 27033 27034 27035 27036 27037 27038 27039 27040 | - - + + - + | it. On error, *outRaw is not modified but pBuilder may have emitted partial output. That is not knowable for the general case. Ownership of pBuilder is not changed. If pBuilder is not NULL then pBuilder->opt must be non-NULL. */ static int fsl_diff2_text_impl(fsl_buffer const *pA, fsl_buffer const *pB, |
︙ | |||
27082 27083 27084 27085 27086 27087 27088 | 27107 27108 27109 27110 27111 27112 27113 27114 27115 27116 27117 27118 27119 27120 27121 27122 27123 27124 27125 27126 27127 27128 27129 27130 27131 27132 27133 27134 27135 27136 27137 27138 27139 27140 27141 27142 27143 27144 27145 27146 27147 27148 27149 27150 27151 27152 27153 27154 27155 27156 27157 27158 27159 27160 27161 27162 27163 27164 27165 27166 27167 27168 27169 27170 27171 27172 27173 27174 27175 27176 27177 27178 27179 27180 27181 27182 27183 27184 27185 27186 27187 27188 27189 27190 27191 27192 27193 27194 27195 27196 27197 27198 27199 27200 27201 27202 27203 27204 27205 27206 27207 27208 27209 27210 27211 27212 27213 27214 27215 27216 27217 27218 27219 27220 27221 27222 27223 27224 27225 27226 27227 27228 27229 27230 27231 27232 27233 27234 27235 27236 27237 27238 27239 27240 27241 27242 27243 27244 27245 27246 27247 27248 27249 27250 27251 27252 27253 27254 27255 27256 27257 27258 27259 27260 27261 27262 27263 27264 27265 27266 27267 27268 27269 27270 27271 27272 27273 27274 27275 27276 27277 27278 27279 27280 27281 27282 27283 27284 27285 27286 27287 27288 27289 27290 27291 27292 27293 27294 27295 27296 27297 27298 27299 27300 27301 27302 27303 27304 27305 27306 27307 27308 27309 27310 27311 27312 27313 27314 27315 27316 27317 27318 27319 27320 27321 27322 27323 27324 27325 27326 27327 27328 27329 27330 27331 27332 27333 27334 27335 27336 27337 27338 27339 27340 27341 27342 27343 27344 27345 27346 27347 27348 27349 27350 27351 27352 27353 27354 27355 27356 27357 27358 27359 27360 27361 27362 27363 27364 27365 27366 27367 27368 27369 27370 27371 27372 27373 27374 27375 27376 27377 27378 27379 27380 27381 27382 27383 27384 27385 27386 27387 27388 27389 27390 27391 27392 27393 27394 27395 27396 27397 27398 27399 27400 27401 27402 27403 27404 27405 27406 27407 27408 27409 27410 27411 27412 27413 27414 27415 27416 27417 27418 27419 27420 27421 27422 27423 27424 27425 27426 27427 27428 27429 27430 27431 27432 27433 27434 27435 27436 27437 27438 27439 27440 27441 27442 27443 27444 27445 27446 27447 27448 27449 27450 27451 27452 27453 27454 27455 27456 27457 27458 27459 27460 27461 27462 27463 27464 27465 27466 27467 27468 27469 27470 27471 27472 27473 27474 27475 27476 27477 27478 27479 27480 27481 27482 27483 27484 27485 27486 27487 27488 27489 27490 27491 27492 27493 27494 27495 27496 27497 27498 27499 27500 27501 27502 27503 27504 27505 27506 27507 27508 27509 27510 27511 27512 | - + - + - + - + + + - - - - - - - - + + + - + - + - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + - + + + + + + - - + + - - - - - + + + + + + + + + + + + - - - - - + + + + + + + + + + + + - - - - + + + + + + + + + + - - - - + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + + + + - - + + + - - - + + + + + + + + + + + + + + + + + + - - - + - + - + - + - + - + - + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - + + + - - + + + + + | - DIFF_NUMSTAT flag is not implemented. For that matter, flags which result in output going anywhere except for pBuilder->out are not implemented here, e.g. DIFF_RAW. That last point makes this impl tiny compared to the original! */ if(pBuilder){ |
︙ | |||
27342 27343 27344 27345 27346 27347 27348 | 27530 27531 27532 27533 27534 27535 27536 27537 27538 27539 27540 27541 27542 27543 27544 27545 27546 27547 27548 27549 27550 27551 27552 27553 27554 27555 27556 27557 27558 27559 27560 27561 27562 27563 27564 27565 27566 27567 27568 27569 27570 27571 27572 27573 27574 27575 27576 27577 27578 27579 27580 27581 27582 27583 27584 27585 27586 27587 27588 27589 27590 27591 27592 27593 27594 27595 27596 27597 27598 27599 27600 27601 27602 27603 27604 27605 27606 27607 27608 27609 27610 27611 27612 27613 27614 27615 27616 27617 27618 27619 27620 27621 27622 27623 27624 27625 27626 27627 27628 27629 27630 27631 27632 27633 27634 27635 27636 27637 27638 27639 27640 27641 27642 27643 27644 27645 27646 27647 27648 27649 27650 27651 27652 27653 27654 27655 27656 27657 27658 27659 27660 27661 27662 27663 27664 27665 27666 27667 27668 27669 27670 27671 27672 27673 27674 27675 27676 27677 27678 27679 27680 27681 27682 27683 27684 27685 27686 27687 27688 27689 27690 27691 27692 27693 27694 27695 27696 27697 27698 27699 27700 27701 27702 27703 27704 27705 27706 27707 27708 27709 27710 27711 27712 27713 27714 27715 27716 27717 27718 27719 27720 27721 27722 27723 27724 27725 27726 27727 27728 27729 27730 27731 27732 27733 27734 27735 27736 27737 27738 27739 27740 27741 27742 27743 27744 27745 27746 27747 27748 27749 27750 27751 27752 27753 27754 27755 27756 27757 27758 27759 27760 27761 27762 27763 27764 27765 27766 27767 27768 27769 27770 27771 27772 27773 27774 27775 27776 27777 27778 27779 27780 27781 27782 27783 27784 27785 27786 27787 27788 27789 27790 27791 27792 27793 27794 27795 27796 27797 27798 27799 27800 27801 27802 27803 27804 27805 27806 27807 27808 27809 27810 27811 27812 27813 27814 27815 27816 27817 27818 27819 27820 27821 27822 27823 27824 27825 27826 27827 27828 27829 27830 27831 27832 27833 27834 27835 27836 27837 27838 27839 27840 27841 27842 27843 27844 27845 27846 27847 27848 27849 27850 27851 27852 27853 27854 27855 27856 27857 27858 27859 27860 27861 27862 27863 27864 27865 27866 27867 27868 27869 27870 27871 27872 27873 27874 27875 27876 27877 27878 27879 27880 27881 27882 27883 27884 27885 27886 27887 27888 27889 27890 27891 27892 27893 27894 27895 27896 27897 27898 27899 27900 27901 27902 27903 27904 27905 27906 27907 27908 27909 27910 27911 27912 27913 27914 27915 27916 27917 27918 27919 27920 27921 27922 27923 27924 27925 27926 27927 27928 27929 27930 27931 27932 27933 27934 27935 27936 27937 27938 27939 27940 27941 27942 27943 27944 27945 27946 27947 27948 27949 27950 27951 27952 27953 27954 27955 27956 27957 27958 27959 27960 27961 27962 27963 27964 27965 27966 27967 27968 27969 27970 27971 27972 27973 27974 27975 27976 27977 27978 27979 27980 27981 27982 27983 27984 27985 27986 27987 27988 27989 27990 27991 27992 27993 27994 27995 27996 27997 27998 27999 28000 28001 28002 28003 28004 28005 28006 28007 28008 28009 28010 28011 28012 28013 28014 28015 28016 28017 28018 28019 28020 28021 28022 28023 28024 28025 28026 28027 28028 28029 28030 28031 28032 28033 28034 28035 28036 28037 28038 28039 28040 28041 28042 28043 28044 28045 28046 28047 28048 28049 28050 28051 28052 28053 28054 28055 28056 28057 28058 28059 28060 28061 28062 28063 28064 28065 28066 28067 28068 28069 28070 28071 28072 28073 28074 28075 28076 28077 28078 28079 28080 28081 28082 28083 28084 28085 28086 28087 28088 28089 28090 28091 28092 28093 28094 28095 28096 28097 28098 28099 28100 28101 28102 28103 28104 28105 28106 28107 28108 28109 28110 28111 28112 28113 28114 28115 28116 28117 28118 28119 28120 28121 28122 28123 28124 28125 28126 28127 28128 28129 28130 28131 28132 28133 28134 28135 28136 28137 28138 28139 28140 28141 28142 28143 28144 28145 28146 28147 28148 28149 28150 28151 28152 28153 28154 28155 28156 28157 28158 28159 28160 28161 28162 28163 28164 28165 28166 28167 28168 28169 28170 28171 28172 28173 28174 28175 28176 28177 28178 28179 28180 28181 28182 28183 28184 28185 28186 28187 28188 28189 28190 28191 28192 28193 28194 28195 28196 28197 28198 28199 28200 28201 28202 28203 28204 28205 28206 28207 28208 28209 28210 28211 28212 28213 28214 28215 28216 28217 28218 28219 28220 28221 28222 28223 28224 28225 28226 28227 28228 28229 28230 28231 28232 28233 28234 28235 28236 28237 28238 28239 28240 28241 28242 28243 28244 28245 28246 28247 28248 28249 28250 28251 28252 28253 28254 28255 28256 28257 28258 28259 28260 28261 28262 28263 28264 28265 28266 28267 28268 28269 28270 28271 28272 28273 28274 28275 28276 28277 28278 28279 28280 28281 28282 28283 28284 28285 28286 28287 28288 28289 28290 28291 28292 28293 28294 28295 28296 28297 28298 28299 28300 28301 28302 28303 28304 28305 28306 28307 28308 28309 28310 28311 28312 28313 28314 28315 28316 28317 28318 28319 28320 28321 28322 28323 28324 28325 28326 28327 28328 28329 28330 28331 28332 28333 28334 28335 28336 28337 28338 28339 28340 28341 28342 28343 28344 28345 28346 28347 28348 28349 28350 28351 28352 28353 28354 28355 28356 | - + - + - + - + - + - + - + - - - + + + - + + + + - + - + - + - + - + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + - + + + - + + - + + - - + + + + + + + + - - - - - - + + + + + + + + + + + - - - - - - + + + + + + + + + + + - + + + - - - + + + + + - + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - + + + - + - + + + + + + + + - + + + - - + + + + + + + + - + + - + - + - + - + + + - + - - + + + + + - + - + - + - + - + - - - + + + - + - + - + - + - + - + - + + - + + + + + + + + + + + + - + - + - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + - + - + - - + + - + - + - - - + + + - + - + - + - - + + - + - - - - - - - - - - - - - - - + - + - - + + - + - + - + - + - + - + - + - + - - + + - - + + - + - - + + - + - - + + - - - + + + - - + + - - + + - + - + - + - + - + - + + - - - + + + + | ** ** The SUBARRAY is an array of 3*N+1 strings with N>=0. The triples ** represent common-text, left-text, and right-text. The last string ** in SUBARRAY is the common-suffix. Any string can be empty if it does ** not apply. */ |
︙ | |||
28347 28348 28349 28350 28351 28352 28353 | 28621 28622 28623 28624 28625 28626 28627 28628 28629 28630 28631 28632 28633 28634 28635 28636 | - - + + | return (char *)b.mem /* transfer ownership */; }else{ fsl_buffer_clear(&b); return NULL; } } |
︙ | |||
28394 28395 28396 28397 28398 28399 28400 | 28668 28669 28670 28671 28672 28673 28674 28675 28676 28677 28678 28679 28680 28681 28682 28683 | - - + + | } return rc; } } #undef MARKER |
︙ | |||
28418 28419 28420 28421 28422 28423 28424 | 28692 28693 28694 28695 28696 28697 28698 28699 28700 28701 28702 28703 28704 28705 28706 28707 28708 28709 28710 28711 28712 28713 28714 28715 28716 28717 28718 28719 | - + - + | #include <assert.h> #include <string.h> /* strlen() */ #include <stddef.h> /* NULL on linux */ #include <ctype.h> #include <errno.h> #include <dirent.h> |
︙ | |||
28534 28535 28536 28537 28538 28539 28540 | 28808 28809 28810 28811 28812 28813 28814 28815 28816 28817 28818 28819 28820 28821 28822 | - + - | memcpy(zBuf, zPwdUtf8, nPwd+1); fsl_filename_free(zPwdUtf8); if(outLen) *outLen = nPwd; return 0; #else if(!zBuf) return FSL_RC_MISUSE; else if(!nBuf) return FSL_RC_RANGE; |
︙ | |||
28564 28565 28566 28567 28568 28569 28570 | 28837 28838 28839 28840 28841 28842 28843 28844 28845 28846 28847 28848 28849 28850 28851 | - + | #if !defined(S_ISLNK) # define S_ISLNK(x) (0) #endif /* Reminder: the semantics of the 3rd parameter are reversed from v1's fossil_stat(). */ |
︙ | |||
28663 28664 28665 28666 28667 28668 28669 28670 | 28936 28937 28938 28939 28940 28941 28942 28943 28944 28945 28946 28947 28948 28949 28950 28951 28952 28953 28954 28955 28956 28957 28958 | + + + + - + - - + + + | fsl_fstat fst; return ( 0 != fsl_stat(zFilename, &fst, 1) ) ? false : (FSL_FSTAT_TYPE_FILE == fst.type); } bool fsl_is_symlink(const char *zFilename){ #if FSL_PLATFORM_IS_WINDOWS if(zFilename){/*unused var*/} return false; #else fsl_fstat fst; |
︙ | |||
28777 28778 28779 28780 28781 28782 28783 28784 28785 28786 28787 28788 28789 28790 | 29055 29056 29057 29058 29059 29060 29061 29062 29063 29064 29065 29066 29067 29068 29069 29070 29071 29072 29073 29074 29075 29076 29077 | + - - + - | fsl_size_t fsl_file_simplify_name(char *z, fsl_int_t n_, bool slash){ fsl_size_t i; fsl_size_t n = (n_<0) ? fsl_strlen(z) : (fsl_size_t)n_; fsl_int_t j; bool const hadSlash = n && (z[n-1]=='/'); /* On windows and cygwin convert all \ characters to / */ #if defined(_WIN32) || defined(__CYGWIN__) for(i=0; i<n; i++){ if( z[i]=='\\' ) z[i] = '/'; } #endif /* Removing trailing "/" characters */ |
︙ | |||
28822 28823 28824 28825 28826 28827 28828 28829 28830 28831 28832 28833 28834 | 29099 29100 29101 29102 29103 29104 29105 29106 29107 29108 29109 29110 29111 29112 29113 29114 29115 29116 29117 29118 29119 29120 | + - + | continue; } } if( j>=0 ) z[j] = z[i]; j++; } if( j==0 ) z[j++] = '.'; if(slash && hadSlash && '/'!=z[j-1]) z[j++] = '/'; z[j] = 0; return (fsl_size_t)j; } int fsl_file_canonical_name2(const char *zRoot, const char *zOrigName, |
︙ | |||
28880 28881 28882 28883 28884 28885 28886 | 29158 29159 29160 29161 29162 29163 29164 29165 29166 29167 29168 29169 29170 29171 29172 29173 29174 29175 29176 29177 29178 29179 | + - + - + | pOut->used = newLen; } return rc; } int fsl_file_canonical_name(const char *zOrigName, fsl_buffer * const pOut, |
︙ | |||
29165 29166 29167 29168 29169 29170 29171 29172 29173 29174 29175 29176 29177 29178 | 29444 29445 29446 29447 29448 29449 29450 29451 29452 29453 29454 29455 29456 29457 29458 29459 29460 29461 29462 29463 | + + + + + + | FILE_ATTRIBUTE_ENCRYPTED | FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED ); return dwAttributes==FILE_ATTRIBUTE_DIRECTORY; } #endif bool fsl_file_isexec(const char *zFilename){ fsl_fstat st = fsl_fstat_empty; int const s = fsl_stat(zFilename, &st, true); return 0==s ? (st.perm & FSL_FSTAT_PERM_EXE) : false; } int fsl_rmdir(const char *zFilename){ int rc = fsl_dir_check(zFilename); if(rc<1) return rc ? FSL_RC_TYPE : FSL_RC_NOT_FOUND; #ifdef _WIN32 wchar_t *z = (wchar_t*)fsl_utf8_to_filename(zFilename); if(w32_file_is_normal_dir(z)){ |
︙ | |||
29517 29518 29519 29520 29521 29522 29523 | 29802 29803 29804 29805 29806 29807 29808 29809 29810 29811 29812 29813 29814 29815 29816 29817 29818 29819 29820 29821 29822 | + + + + - - - + + + | } } if(err) rc = fsl_errno_to_rc(errno, FSL_RC_IO); return rc; #endif } /** fsl_dircrawl() part for handling a single directory. fst must be valid state from a freshly-fsl_fstat()'d DIRECTORY. */ |
︙ | |||
29567 29568 29569 29570 29571 29572 29573 29574 29575 29576 29577 29578 29579 29580 | 29856 29857 29858 29859 29860 29861 29862 29863 29864 29865 29866 29867 29868 29869 29870 29871 | + + | rc = cb( dst ); if(!rc){ dbuf->mem[dbuf->used] = '/'; dbuf->used = newLen; if(FSL_FSTAT_TYPE_DIR==fst->type){ rc = fsl_dircrawl_impl( dbuf, fst, cb, cbState, dst, depth+1 ); } }else if(FSL_RC_NOOP == rc){ rc = 0; } } closedir(dir); return rc; } int fsl_dircrawl(char const * dirName, fsl_dircrawl_f callback, |
︙ | |||
29601 29602 29603 29604 29605 29606 29607 | 29892 29893 29894 29895 29896 29897 29898 29899 29900 29901 29902 29903 29904 29905 29906 29907 29908 29909 | - - - + + + + | } fsl_buffer_clear(&dbuf); return rc; } bool fsl_is_file_or_link(const char *zFilename){ fsl_fstat fst = fsl_fstat_empty; |
︙ | |||
29628 29629 29630 29631 29632 29633 29634 | 29920 29921 29922 29923 29924 29925 29926 29927 29928 29929 29930 29931 29932 29933 29934 29935 29936 29937 29938 29939 29940 29941 29942 29943 29944 29945 29946 29947 29948 29949 29950 29951 29952 29953 29954 29955 29956 29957 29958 29959 29960 29961 29962 29963 29964 29965 29966 29967 29968 29969 29970 29971 29972 29973 29974 29975 29976 29977 29978 29979 29980 29981 29982 29983 29984 29985 29986 29987 29988 29989 29990 29991 29992 29993 29994 29995 29996 29997 29998 29999 30000 30001 30002 30003 30004 30005 30006 30007 30008 30009 30010 30011 30012 30013 30014 30015 30016 30017 30018 30019 30020 30021 30022 30023 30024 30025 30026 30027 30028 30029 30030 30031 30032 30033 30034 30035 30036 30037 30038 30039 30040 30041 30042 30043 30044 30045 30046 30047 30048 30049 30050 30051 30052 30053 30054 30055 30056 30057 30058 30059 30060 30061 30062 30063 30064 30065 30066 30067 30068 30069 30070 30071 30072 30073 30074 30075 30076 30077 30078 30079 30080 30081 30082 30083 30084 30085 30086 30087 30088 30089 30090 30091 30092 30093 30094 30095 30096 30097 30098 30099 30100 30101 30102 30103 30104 30105 30106 30107 30108 30109 30110 30111 30112 30113 30114 30115 30116 30117 30118 30119 30120 30121 30122 30123 30124 30125 30126 30127 30128 30129 30130 30131 30132 30133 30134 30135 30136 30137 30138 30139 30140 30141 30142 30143 30144 30145 30146 30147 30148 30149 30150 30151 30152 30153 30154 30155 30156 30157 30158 | - - - + + + + - - + - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | (fsl_int_t)b->used); } int fsl_file_rename(const char *zFrom, const char *zTo){ int rc; #if defined(_WIN32) /** 2021-03-24: fossil's impl of this routine has 2 additional |
︙ | |||
29672 29673 29674 29675 29676 29677 29678 | 30169 30170 30171 30172 30173 30174 30175 30176 30177 30178 30179 30180 30181 30182 30183 30184 | - - + + | #ifdef _WIN32 # undef DIR # undef dirent # undef opendir # undef readdir # undef closedir #endif |
︙ | |||
29718 29719 29720 29721 29722 29723 29724 | 30215 30216 30217 30218 30219 30220 30221 30222 30223 30224 30225 30226 30227 30228 30229 30230 | - - + + | } return rc; } #undef MARKER |
︙ | |||
29807 29808 29809 29810 29811 29812 29813 | 30304 30305 30306 30307 30308 30309 30310 30311 30312 30313 30314 30315 30316 30317 30318 30319 | - - + + | } } return *z==0; #endif } |
︙ | |||
29864 29865 29866 29867 29868 29869 29870 | 30361 30362 30363 30364 30365 30366 30367 30368 30369 30370 30371 30372 30373 30374 30375 30376 30377 30378 30379 30380 30381 30382 30383 30384 30385 30386 30387 30388 30389 30390 30391 30392 30393 30394 | - + - - + + | glob = (char const *)globList->list[i]; if( fsl_str_glob( glob, zNeedle ) ) return glob; } return NULL; } } |
︙ | |||
30023 30024 30025 30026 30027 30028 30029 | 30520 30521 30522 30523 30524 30525 30526 30527 30528 30529 30530 30531 30532 30533 30534 30535 | - - + + | if(rc) break; rn1 = rn2 = BufSize; } return rc; } #undef MARKER |
︙ | |||
30050 30051 30052 30053 30054 30055 30056 | 30547 30548 30549 30550 30551 30552 30553 30554 30555 30556 30557 30558 30559 30560 30561 30562 30563 30564 30565 30566 30567 30568 30569 30570 30571 30572 30573 30574 30575 | - - - + + + + | /* Only for debugging */ #define MARKER(pfexp) \ do{ printf("MARKER: %s:%d:%s():\t",__FILE__,__LINE__,__func__); \ printf pfexp; \ } while(0) |
︙ | |||
30201 30202 30203 30204 30205 30206 30207 | 30699 30700 30701 30702 30703 30704 30705 30706 30707 30708 30709 30710 30711 30712 30713 | - + | !rc && rid; rid=fsl_id_bag_next(&f->cache.leafCheck,rid)){ rc = fsl__repo_leafcheck(f, rid); } fsl_id_bag_reset(&f->cache.leafCheck); return rc; } |
︙ | |||
30343 30344 30345 30346 30347 30348 30349 | 30841 30842 30843 30844 30845 30846 30847 30848 30849 30850 30851 30852 30853 30854 30855 30856 30857 30858 30859 30860 30861 30862 30863 30864 30865 30866 30867 30868 30869 30870 30871 30872 30873 30874 30875 30876 30877 30878 30879 30880 30881 30882 30883 30884 30885 30886 30887 30888 30889 30890 30891 30892 30893 30894 30895 30896 30897 30898 30899 30900 30901 30902 30903 30904 30905 30906 30907 30908 30909 30910 30911 30912 30913 30914 30915 30916 30917 30918 30919 30920 30921 30922 | - + - + - + - - - + + + - - + + + + + + + - - + + - + | return rc; dberr: assert(rc); rc = fsl_cx_uplift_db_error2(f, db, rc); goto end; } |
︙ | |||
30428 30429 30430 30431 30432 30433 30434 | 30931 30932 30933 30934 30935 30936 30937 30938 30939 30940 30941 30942 30943 30944 30945 30946 30947 30948 30949 30950 30951 30952 30953 30954 30955 30956 30957 30958 30959 30960 30961 30962 30963 30964 30965 30966 30967 30968 30969 30970 30971 30972 30973 30974 30975 30976 30977 30978 30979 30980 30981 30982 30983 30984 30985 | - + - + - + - + | memset( m + self->capacity, 0, (sizeof(void*)*(n-self->capacity))); self->capacity = n; self->list = m; return 0; } } |
︙ | |||
30497 30498 30499 30500 30501 30502 30503 | 31000 31001 31002 31003 31004 31005 31006 31007 31008 31009 31010 31011 31012 31013 31014 | - + | } } } return rc; } |
︙ | |||
30529 30530 30531 30532 30533 30534 30535 | 31032 31033 31034 31035 31036 31037 31038 31039 31040 31041 31042 31043 31044 31045 31046 | - + | } } } } return rc; } |
︙ | |||
30561 30562 30563 30564 30565 30566 30567 | 31064 31065 31066 31067 31068 31069 31070 31071 31072 31073 31074 31075 31076 31077 31078 31079 | - - + + | } fsl_int_t fsl_list_index_of_cstr( fsl_list const * li, char const * key ){ return fsl_list_index_of(li, key, fsl_strcmp_cmp); } |
︙ | |||
30619 30620 30621 30622 30623 30624 30625 30626 30627 30628 30629 30630 30631 30632 | 31122 31123 31124 31125 31126 31127 31128 31129 31130 31131 31132 31133 31134 31135 31136 31137 31138 31139 31140 | + + + + + | #undef US2B #undef US3A #undef US3B #undef US4A #undef US4B #undef US4C #undef US0A bool fsl_looks_like_binary(fsl_buffer const * const b){ return (fsl_looks_like_utf8(b, FSL_LOOKSLIKE_BINARY) & FSL_LOOKSLIKE_BINARY) != FSL_LOOKSLIKE_NONE; } int fsl_looks_like_utf8(fsl_buffer const * const b, int stopFlags){ fsl_size_t n = 0; const char *z = fsl_buffer_cstr2(b, &n); int j, c, flags = FSL_LOOKSLIKE_NONE; /* Assume UTF-8 text, prove otherwise */ if( n==0 ) return flags; /* Empty file -> text */ |
︙ | |||
30709 30710 30711 30712 30713 30714 30715 | 31217 31218 31219 31220 31221 31222 31223 31224 31225 31226 31227 31228 31229 31230 31231 31232 | - - + + | c = (c>=0xC0) ? (c|3) : ' '; /* determine next lead byte */ } else { c = *++z; } } return c<0x80 /* Final lead byte must be ASCII. */; } |
︙ | |||
31152 31153 31154 31155 31156 31157 31158 | 31660 31661 31662 31663 31664 31665 31666 31667 31668 31669 31670 31671 31672 31673 31674 31675 31676 31677 31678 31679 31680 31681 31682 31683 31684 31685 31686 31687 31688 31689 31690 31691 31692 31693 31694 31695 31696 31697 31698 31699 31700 31701 31702 31703 31704 31705 31706 31707 31708 31709 31710 31711 31712 31713 31714 31715 31716 31717 31718 31719 31720 31721 31722 31723 31724 31725 31726 31727 31728 31729 31730 31731 31732 31733 31734 31735 31736 31737 31738 31739 31740 31741 31742 31743 31744 31745 31746 31747 31748 31749 31750 31751 31752 31753 31754 31755 31756 31757 31758 31759 31760 31761 31762 31763 31764 31765 31766 31767 31768 31769 31770 31771 31772 31773 31774 31775 31776 31777 31778 31779 31780 31781 31782 31783 31784 31785 31786 31787 31788 31789 31790 31791 31792 31793 31794 31795 31796 31797 31798 31799 31800 31801 31802 31803 31804 31805 31806 31807 31808 31809 31810 31811 31812 31813 31814 31815 31816 31817 31818 31819 31820 31821 31822 31823 31824 31825 31826 31827 31828 31829 31830 31831 31832 31833 31834 31835 31836 31837 31838 31839 31840 31841 31842 31843 31844 31845 31846 31847 31848 31849 31850 31851 31852 31853 31854 31855 31856 31857 31858 31859 31860 31861 31862 31863 31864 31865 31866 31867 31868 31869 31870 31871 31872 31873 31874 31875 31876 31877 31878 31879 31880 31881 31882 31883 31884 31885 31886 31887 31888 31889 31890 31891 31892 31893 31894 31895 31896 31897 31898 31899 31900 31901 31902 31903 31904 31905 31906 31907 31908 31909 31910 31911 31912 31913 31914 31915 31916 31917 31918 31919 31920 31921 31922 31923 31924 31925 31926 31927 31928 31929 31930 31931 31932 31933 31934 31935 31936 31937 31938 31939 31940 31941 31942 31943 31944 31945 31946 31947 31948 31949 31950 31951 31952 31953 31954 31955 31956 31957 31958 31959 31960 31961 31962 31963 31964 31965 31966 31967 31968 31969 31970 31971 31972 31973 31974 31975 31976 31977 31978 31979 31980 31981 31982 31983 31984 31985 31986 31987 31988 31989 31990 31991 31992 31993 31994 31995 31996 31997 31998 31999 32000 32001 32002 32003 32004 32005 32006 32007 32008 32009 32010 32011 32012 32013 32014 32015 32016 32017 32018 32019 32020 32021 32022 32023 32024 32025 32026 32027 32028 32029 32030 32031 32032 32033 32034 32035 32036 32037 32038 32039 32040 32041 32042 32043 32044 32045 32046 32047 32048 32049 32050 32051 32052 32053 32054 32055 32056 32057 32058 32059 32060 32061 32062 32063 32064 32065 32066 32067 32068 32069 32070 32071 32072 32073 32074 32075 32076 32077 32078 32079 32080 32081 32082 32083 32084 32085 32086 32087 32088 32089 32090 32091 32092 32093 32094 32095 32096 32097 32098 32099 32100 32101 32102 32103 32104 32105 32106 32107 32108 32109 32110 32111 32112 32113 32114 32115 32116 32117 32118 32119 32120 32121 32122 32123 32124 32125 32126 32127 32128 32129 32130 32131 32132 32133 32134 32135 32136 32137 32138 32139 32140 32141 32142 32143 32144 32145 32146 32147 32148 32149 32150 32151 32152 32153 32154 32155 32156 32157 32158 32159 32160 32161 32162 32163 32164 32165 32166 32167 32168 32169 32170 32171 32172 32173 32174 32175 32176 32177 32178 32179 32180 32181 32182 32183 32184 32185 32186 32187 32188 32189 32190 32191 32192 32193 32194 32195 32196 32197 32198 32199 32200 32201 32202 32203 32204 32205 32206 32207 32208 32209 32210 32211 32212 32213 32214 32215 32216 32217 32218 32219 32220 32221 32222 32223 32224 32225 32226 32227 32228 32229 32230 32231 32232 32233 32234 32235 32236 32237 32238 32239 32240 32241 32242 32243 32244 32245 32246 32247 32248 32249 32250 32251 32252 32253 32254 32255 32256 32257 32258 32259 32260 32261 32262 32263 32264 32265 32266 32267 32268 32269 32270 32271 32272 32273 32274 32275 32276 32277 32278 32279 32280 32281 32282 32283 32284 32285 32286 32287 32288 32289 32290 32291 32292 32293 32294 32295 32296 32297 32298 32299 32300 32301 32302 32303 32304 32305 32306 32307 32308 32309 32310 32311 32312 32313 32314 32315 32316 32317 32318 32319 32320 32321 32322 32323 32324 32325 32326 32327 32328 32329 32330 32331 32332 32333 32334 32335 32336 32337 32338 32339 32340 32341 32342 32343 32344 32345 32346 32347 32348 32349 32350 32351 32352 32353 32354 32355 32356 32357 32358 32359 32360 32361 32362 32363 32364 32365 32366 32367 32368 32369 32370 32371 32372 32373 32374 32375 32376 32377 32378 32379 32380 32381 32382 32383 32384 32385 32386 32387 32388 32389 32390 32391 32392 32393 32394 32395 32396 32397 32398 32399 32400 32401 32402 32403 32404 32405 32406 32407 32408 32409 32410 32411 32412 32413 32414 32415 32416 32417 32418 32419 32420 32421 32422 32423 32424 32425 32426 32427 32428 32429 32430 32431 32432 32433 32434 32435 32436 32437 32438 32439 32440 32441 32442 32443 32444 32445 32446 32447 32448 32449 32450 32451 32452 32453 32454 32455 32456 32457 32458 32459 32460 32461 32462 32463 32464 32465 32466 32467 32468 32469 32470 32471 32472 32473 32474 32475 32476 32477 32478 32479 32480 32481 32482 32483 32484 32485 32486 32487 32488 32489 32490 32491 32492 32493 32494 32495 32496 32497 32498 32499 32500 32501 32502 32503 32504 32505 32506 32507 32508 32509 32510 32511 32512 32513 32514 32515 32516 32517 32518 32519 32520 32521 32522 32523 32524 32525 32526 32527 32528 32529 32530 32531 32532 32533 32534 32535 32536 32537 32538 32539 32540 32541 32542 32543 32544 32545 32546 32547 32548 32549 32550 32551 32552 32553 32554 32555 32556 32557 32558 32559 32560 32561 32562 32563 32564 32565 32566 32567 32568 32569 32570 32571 32572 32573 32574 32575 32576 32577 32578 32579 32580 32581 32582 32583 32584 32585 32586 32587 32588 32589 32590 32591 32592 32593 32594 32595 32596 32597 32598 32599 32600 32601 32602 32603 32604 32605 32606 32607 32608 32609 32610 32611 32612 32613 32614 32615 32616 32617 32618 32619 32620 32621 32622 32623 32624 32625 32626 32627 32628 32629 32630 32631 32632 32633 32634 32635 32636 32637 32638 32639 32640 32641 32642 32643 32644 32645 32646 32647 32648 32649 32650 32651 32652 32653 32654 32655 32656 32657 32658 32659 32660 32661 32662 32663 32664 32665 32666 32667 32668 32669 32670 32671 32672 32673 32674 32675 32676 32677 32678 32679 32680 32681 32682 32683 32684 32685 32686 32687 32688 32689 32690 32691 32692 32693 32694 32695 32696 32697 32698 32699 32700 32701 32702 32703 32704 32705 32706 32707 32708 32709 32710 32711 32712 32713 32714 32715 32716 32717 32718 32719 32720 32721 32722 32723 32724 32725 32726 32727 32728 32729 32730 32731 32732 32733 32734 32735 32736 32737 32738 32739 32740 32741 32742 32743 32744 32745 32746 32747 32748 32749 32750 32751 32752 32753 32754 32755 32756 32757 32758 32759 32760 32761 32762 32763 32764 32765 32766 32767 32768 32769 32770 32771 32772 32773 32774 32775 32776 32777 32778 32779 32780 32781 32782 32783 32784 32785 32786 32787 32788 32789 32790 32791 32792 32793 32794 32795 32796 32797 32798 32799 32800 32801 32802 32803 32804 32805 32806 32807 32808 32809 32810 32811 32812 32813 32814 32815 32816 32817 32818 32819 32820 32821 32822 32823 32824 32825 32826 32827 32828 32829 32830 32831 32832 32833 32834 32835 32836 32837 32838 32839 32840 32841 32842 32843 32844 32845 32846 32847 32848 32849 32850 32851 32852 32853 32854 32855 32856 32857 32858 32859 32860 32861 32862 32863 32864 32865 32866 32867 32868 32869 32870 32871 32872 32873 32874 32875 32876 32877 32878 32879 32880 32881 32882 32883 32884 32885 32886 32887 32888 32889 32890 32891 32892 32893 32894 32895 32896 32897 32898 32899 32900 32901 32902 32903 32904 32905 32906 32907 32908 32909 32910 32911 32912 32913 32914 32915 32916 32917 32918 32919 32920 32921 32922 32923 32924 32925 32926 32927 32928 32929 32930 32931 32932 32933 32934 32935 32936 32937 32938 32939 32940 32941 32942 32943 32944 32945 32946 32947 32948 | - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | #undef F1 #undef F2 #undef F3 #undef F4 #undef MD5STEP #undef byteReverse |
︙ | |||
31269 31270 31271 31272 31273 31274 31275 | 33050 33051 33052 33053 33054 33055 33056 33057 33058 33059 33060 33061 33062 33063 33064 33065 33066 33067 33068 33069 33070 33071 33072 33073 33074 33075 33076 33077 33078 33079 33080 33081 33082 33083 33084 33085 33086 33087 33088 33089 33090 33091 33092 33093 33094 33095 33096 33097 33098 33099 33100 33101 33102 33103 33104 | - - - - + + + + - + + - + + + + + - + + + | sz -= aC[1]; aC += 3; } return true; } /** |
︙ | |||
31338 31339 31340 31341 31342 31343 31344 | 33126 33127 33128 33129 33130 33131 33132 33133 33134 33135 33136 33137 33138 33139 33140 | - - + | } /** Ensure that the text in p, if not empty, ends with a new line. If useCrLf is true adds "\r\n" otherwise "\n". Returns 0 on success or p is empty, and FSL_RC_OOM on OOM. */ |
︙ | |||
31386 31387 31388 31389 31390 31391 31392 | 33173 33174 33175 33176 33177 33178 33179 33180 33181 33182 33183 33184 33185 33186 33187 33188 33189 33190 33191 33192 33193 33194 33195 33196 33197 33198 33199 33200 33201 33202 33203 33204 33205 33206 33207 33208 33209 33210 33211 33212 33213 33214 33215 33216 33217 33218 33219 33220 33221 33222 33223 33224 33225 33226 33227 33228 33229 33230 33231 33232 33233 33234 33235 33236 33237 33238 33239 33240 33241 33242 33243 | - - - - + + + + - - + + + + + + + + + - - - - - + + + + + + + + + + + + + + + + + + + + - + + - + | NEVER, EVER change these. They MUST match the ones used by fossil. */ static const char *const mergeMarker[] = { /*123456789 123456789 123456789 123456789 123456789 123456789 123456789*/ |
︙ | |||
31451 31452 31453 31454 31455 31456 31457 | 33261 33262 33263 33264 33265 33266 33267 33268 33269 33270 33271 33272 33273 33274 33275 33276 | - - + + | ** and pPivot => pV2 (into aC2). Each of the aC1 and aC2 arrays is ** an array of integer triples. Within each triple, the first integer ** is the number of lines of text to copy directly from the pivot, ** the second integer is the number of lines of text to omit from the ** pivot, and the third integer is the number of lines of text that are ** inserted. The edit array ends with a triple of 0,0,0. */ |
︙ | |||
31482 31483 31484 31485 31486 31487 31488 31489 31490 31491 31492 31493 31494 31495 31496 31497 31498 31499 31500 31501 31502 31503 31504 31505 31506 31507 31508 31509 31510 31511 31512 31513 31514 31515 31516 31517 31518 31519 31520 31521 31522 31523 31524 31525 31526 31527 31528 31529 31530 31531 31532 31533 31534 31535 31536 31537 31538 | 33292 33293 33294 33295 33296 33297 33298 33299 33300 33301 33302 33303 33304 33305 33306 33307 33308 33309 33310 33311 33312 33313 33314 33315 33316 33317 33318 33319 33320 33321 33322 33323 33324 33325 33326 33327 33328 33329 33330 33331 33332 33333 33334 33335 33336 33337 33338 33339 33340 33341 33342 33343 33344 33345 33346 33347 33348 33349 33350 33351 33352 33353 33354 33355 33356 33357 33358 33359 33360 33361 33362 33363 33364 33365 33366 33367 33368 33369 33370 33371 33372 33373 33374 33375 33376 33377 33378 33379 33380 33381 33382 33383 33384 33385 33386 33387 33388 33389 33390 33391 33392 33393 | + + + + + + + + + + + + + - + - - + - - - - + - - - + + - + - - - - + + + + - - - - + | /* Loop over the two edit vectors and use them to compute merged text ** which is written into pOut. i1 and i2 are multiples of 3 which are ** indices into aC1[] and aC2[] to the edit triple currently being ** processed */ i1 = i2 = 0; ln1 = ln2 = lnPivot = 1; while( i1<limit1 && i2<limit2 ){ FDEBUG( printf("%d: %2d %2d %2d %d: %2d %2d %2d\n", i1/3, aC1[i1], aC1[i1+1], aC1[i1+2], i2/3, aC2[i2], aC2[i2+1], aC2[i2+2]); ) if( aC1[i1]>0 && aC2[i2]>0 ){ /* Output text that is unchanged in both V1 and V2 */ nCpy = mymin(aC1[i1], aC2[i2]); FDEBUG( printf("COPY %d\n", nCpy); ) rc = fsl_buffer_copy_lines(pOut, pPivot, (fsl_size_t)nCpy); lnPivot += nCpy; if(!rc) rc = fsl_buffer_copy_lines(0, pV1, (fsl_size_t)nCpy); ln1 += nCpy; if(!rc) rc = fsl_buffer_copy_lines(0, pV2, (fsl_size_t)nCpy); ln2 += nCpy; RC; aC1[i1] -= nCpy; aC2[i2] -= nCpy; }else if( aC1[i1] >= aC2[i2+1] && aC1[i1]>0 && aC2[i2+1]+aC2[i2+2]>0 ){ /* Output edits to V2 that occurs within unchanged regions of V1 */ nDel = aC2[i2+1]; nIns = aC2[i2+2]; FDEBUG( printf("EDIT -%d+%d left\n", nDel, nIns); ) rc = fsl_buffer_copy_lines(0, pPivot, (fsl_size_t)nDel); lnPivot += nDel; if(!rc) rc = fsl_buffer_copy_lines(0, pV1, (fsl_size_t)nDel); ln1 += nDel; if(!rc) rc = fsl_buffer_copy_lines(pOut, pV2, (fsl_size_t)nIns); ln2 += nIns; RC; aC1[i1] -= nDel; i2 += 3; }else if( aC2[i2] >= aC1[i1+1] && aC2[i2]>0 && aC1[i1+1]+aC1[i1+2]>0 ){ /* Output edits to V1 that occur within unchanged regions of V2 */ nDel = aC1[i1+1]; nIns = aC1[i1+2]; FDEBUG( printf("EDIT -%d+%d right\n", nDel, nIns); ) rc = fsl_buffer_copy_lines(0, pPivot, (fsl_size_t)nDel); lnPivot += nDel; if(!rc) fsl_buffer_copy_lines(0, pV2, (fsl_size_t)nDel); ln2 += nDel; if(!rc) fsl_buffer_copy_lines(pOut, pV1, (fsl_size_t)nIns); ln1 += nIns; aC2[i2] -= nDel; i1 += 3; }else if( sameEdit(&aC1[i1], &aC2[i2], pV1, pV2) ){ /* Output edits that are identical in both V1 and V2. */ assert( aC1[i1]==0 ); nDel = aC1[i1+1]; nIns = aC1[i1+2]; FDEBUG( printf("EDIT -%d+%d both\n", nDel, nIns); ) rc = fsl_buffer_copy_lines(0, pPivot, (fsl_size_t)nDel); lnPivot += nDel; if(!rc) fsl_buffer_copy_lines(pOut, pV1, (fsl_size_t)nIns); ln1 += nIns; if(!rc) fsl_buffer_copy_lines(0, pV2, (fsl_size_t)nIns); ln2 += nIns; i1 += 3; i2 += 3; |
︙ | |||
31609 31610 31611 31612 31613 31614 31615 | 33424 33425 33426 33427 33428 33429 33430 33431 33432 33433 33434 33435 33436 33437 33438 33439 33440 33441 33442 33443 33444 33445 33446 33447 33448 33449 33450 33451 33452 33453 | - - + + + - - + + | fsl_size_t const len = (fsl_size_t)assert_mema_lengths(); if(p->used <= len) return false; fsl_size_t j; const char * const z = (const char *)p->mem; fsl_size_t const n = p->used - len + 1; for(i=0; i<n; ){ for(j=0; j<4; ++j){ |
︙ | |||
31651 31652 31653 31654 31655 31656 31657 | 33467 33468 33469 33470 33471 33472 33473 33474 33475 33476 33477 33478 33479 33480 33481 33482 33483 | - + - - - - - - | */ /************************************************************************* This copy has been modified slightly for use in the libfossil project. */ #undef __STRICT_ANSI__ #include <errno.h> |
︙ | |||
31694 31695 31696 31697 31698 31699 31700 | 33504 33505 33506 33507 33508 33509 33510 33511 33512 33513 33514 33515 33516 33517 33518 | - + | # define PTR_TO_INT(X) ((int)(intptr_t)(X)) #else /* Generates a warning - but it always works */ # define INT_TO_PTR(X) ((void*)(X)) # define PTR_TO_INT(X) ((int)(X)) #endif |
︙ | |||
31738 31739 31740 31741 31742 31743 31744 | 33548 33549 33550 33551 33552 33553 33554 33555 33556 33557 33558 33559 33560 33561 33562 33563 33564 33565 33566 33567 33568 33569 33570 33571 33572 33573 33574 33575 33576 33577 33578 33579 33580 33581 33582 33583 33584 33585 33586 33587 33588 33589 33590 33591 33592 33593 33594 33595 33596 33597 33598 33599 33600 33601 33602 33603 | - + + - + - + + - + + | &pi /* Process Info */ ); if( rc ){ CloseHandle( pi.hProcess ); CloseHandle( pi.hThread ); *pChildPid = pi.dwProcessId; }else{ |
︙ | |||
31830 31831 31832 31833 31834 31835 31836 | 33643 33644 33645 33646 33647 33648 33649 33650 33651 33652 33653 33654 33655 33656 33657 33658 33659 33660 33661 33662 33663 33664 33665 33666 33667 33668 33669 33670 33671 33672 33673 33674 33675 33676 33677 33678 33679 33680 33681 33682 33683 33684 33685 33686 33687 33688 33689 33690 33691 33692 33693 33694 33695 33696 33697 33698 33699 33700 | - + + + + + - + + + + + + - + + - - + + - - + + | close(pout[0]); close(pout[1]); close(1); fd = dup(pin[1]); if( fd!=1 ) nErr++; close(pin[0]); close(pin[1]); |
︙ | |||
31939 31940 31941 31942 31943 31944 31945 | 33762 33763 33764 33765 33766 33767 33768 33769 33770 33771 33772 33773 33774 33775 33776 33777 | - - + + | if( pp ) *pp = p->list[0].data; for(i=0; i<((fsl_id_t)p->used-1); ++i){ p->list[i] = p->list[i+1]; } --p->used; return e; } |
︙ | |||
32002 32003 32004 32005 32006 32007 32008 | 33825 33826 33827 33828 33829 33830 33831 33832 33833 33834 33835 33836 33837 33838 33839 33840 33841 33842 33843 33844 33845 33846 33847 33848 33849 33850 33851 33852 33853 33854 33855 33856 33857 33858 33859 33860 33861 33862 33863 33864 33865 33866 33867 33868 | - - - - - - + + - - - - + + - + - + - - + + - - - - + + - - - - - - - + + + + + + + + + + + + | " WHERE tagid=%d AND tagxref.rid=ancestor.rid" " AND value=%Q AND tagtype>0)" " LIMIT 1", rid, rid, FSL_TAGID_BRANCH, zBranch ); } |
︙ | |||
32115 32116 32117 32118 32119 32120 32121 | 33935 33936 33937 33938 33939 33940 33941 33942 33943 33944 33945 33946 33947 33948 33949 33950 33951 | + - - + + - - | */ static fsl_id_t fsl_start_of_branch(fsl_cx * f, fsl_id_t rid, enum fsl_stobr_type eType){ fsl_db * db; fsl_stmt q = fsl_stmt_empty; int rc; fsl_id_t ans = rid; char * zBr = 0; |
︙ | |||
32150 32151 32152 32153 32154 32155 32156 | 33969 33970 33971 33972 33973 33974 33975 33976 33977 33978 33979 33980 33981 33982 33983 33984 33985 33986 33987 | - - + + + - - | break; } ans = fsl_stmt_g_id(&q, 0); }while( fsl_stmt_g_int32(&q, 1)==1 && ans>0 ); fsl_stmt_finalize(&q); end: if( ans>0 && eType==FSL_STOBR_YOAN ){ |
︙ | |||
32457 32458 32459 32460 32461 32462 32463 | 34275 34276 34277 34278 34279 34280 34281 34282 34283 34284 34285 34286 34287 34288 34289 34290 34291 34292 34293 34294 34295 34296 34297 34298 34299 34300 34301 34302 34303 34304 34305 34306 34307 34308 34309 34310 34311 34312 34313 34314 34315 34316 34317 34318 34319 34320 34321 34322 34323 34324 34325 34326 34327 34328 34329 34330 34331 34332 34333 34334 34335 34336 34337 34338 34339 34340 34341 34342 34343 34344 34345 34346 34347 34348 34349 34350 | - - - - + + + - - + - - + - - - - - - - - + + + + + + + + + + + - - + - - - - + - - - - - - - + + + + + + + - - - - + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + - - - - + + + - - + - | } else if(uuidLen>FSL_STRLEN_K256){ fsl_cx_err_set(f, FSL_RC_RANGE, "UUID is too long: %s", uuid); return -4; } else { fsl_id_t rid = -5; |
︙ | |||
32601 32602 32603 32604 32605 32606 32607 | 34410 34411 34412 34413 34414 34415 34416 34417 34418 34419 34420 34421 34422 34423 34424 34425 34426 34427 34428 34429 34430 34431 34432 34433 34434 34435 34436 34437 34438 34439 34440 34441 34442 34443 34444 34445 34446 34447 34448 34449 | - + - - - - + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - + - - + - | }else if(db->error.code){ fsl_cx_uplift_db_error(f, db); } return rc; } int fsl_delta_src_id( fsl_cx * const f, fsl_id_t deltaRid, |
︙ | |||
32868 32869 32870 32871 32872 32873 32874 | 34677 34678 34679 34680 34681 34682 34683 34684 34685 34686 34687 34688 34689 34690 34691 34692 34693 34694 34695 34696 34697 34698 34699 34700 34701 34702 34703 34704 34705 34706 34707 34708 34709 34710 34711 34712 34713 34714 34715 34716 34717 34718 34719 34720 34721 34722 34723 34724 34725 34726 34727 34728 34729 34730 34731 34732 | - - + + - - - - - - - - - - - - - - - - - + + | int fsl_repo_create(fsl_cx * f, fsl_repo_create_opt const * opt ){ fsl_db * db = 0; fsl_cx F = fsl_cx_empty /* used if !f */; int rc = 0; char const * userName = 0; fsl_time_t const unixNow = (fsl_time_t)time(0); |
︙ | |||
32959 32960 32961 32962 32963 32964 32965 | 34753 34754 34755 34756 34757 34758 34759 34760 34761 34762 34763 34764 34765 34766 34767 34768 34769 34770 34771 34772 34773 34774 34775 34776 34777 34778 34779 34780 34781 34782 34783 34784 34785 34786 | - + - + - - + + - - - + - + | in fossil this is optional, so we will presumably eventually have to make it so here as well. Not yet sure where this routine is used in fossil (i.e. whether the option is actually exercised). */ rc = fsl_db_exec_multi(db, |
︙ | |||
33019 33020 33021 33022 33023 33024 33025 | 34811 34812 34813 34814 34815 34816 34817 34818 34819 34820 34821 34822 34823 34824 34825 | - + | rc = fsl_cx_uplift_db_error(f, db); } if(inTrans){ if(!rc) rc = fsl_db_transaction_end(db, 0); else fsl_db_transaction_end(db, 1); inTrans = 0; } |
︙ | |||
33076 33077 33078 33079 33080 33081 33082 | 34868 34869 34870 34871 34872 34873 34874 34875 34876 34877 34878 34879 34880 34881 34882 34883 34884 34885 34886 34887 34888 34889 34890 34891 34892 34893 34894 34895 34896 34897 34898 34899 34900 34901 34902 34903 34904 34905 34906 34907 34908 34909 34910 34911 34912 34913 34914 34915 34916 34917 34918 34919 34920 34921 34922 34923 34924 34925 34926 34927 | - + - + - - + + + - + - - + + - - + - - - - - - - - - | goto detach; } inTrans2 = 1; /* Copy all settings from the supplied template repository. */ rc = fsl_db_exec(db, |
︙ | |||
33161 33162 33163 33164 33165 33166 33167 | 34944 34945 34946 34947 34948 34949 34950 34951 34952 34953 34954 34955 34956 34957 34958 34959 | - + + | if(f == &F){ fsl_cx_finalize(f); if(rc) fsl_file_unlink(opt->filename); } return rc; } |
︙ | |||
33188 33189 33190 33191 33192 33193 33194 | 34972 34973 34974 34975 34976 34977 34978 34979 34980 34981 34982 34983 34984 34985 34986 34987 34988 34989 34990 34991 34992 34993 | - - + - + | } rc = fsl_buffer_appendf(&tname, "tmp_filelist_for_rid_%d", (int)rid); if(rc) goto end; rc = fsl_deck_F_rewind(d); while( !rc && !(rc=fsl_deck_F_next(d, &fc)) && fc ){ |
︙ | |||
33218 33219 33220 33221 33222 33223 33224 | 35001 35002 35003 35004 35005 35006 35007 35008 35009 35010 35011 35012 35013 35014 35015 | - + | fsl_stmt_reset(&st); fc = 0; } if(!rc && (count>0)){ fsl_stmt_finalize(&st); rc = fsl_db_prepare(dbR, &st, |
︙ | |||
33251 33252 33253 33254 33255 33256 33257 | 35034 35035 35036 35037 35038 35039 35040 35041 35042 35043 35044 35045 35046 35047 35048 35049 35050 35051 35052 35053 35054 35055 35056 35057 35058 | - + - + - + - - + + | end: if(rc && !f->error.code && dbR->error.code){ fsl_cx_uplift_db_error(f, dbR); } fsl_stmt_finalize(&st); fsl_deck_clean(d); if(tname.used){ |
︙ | |||
33315 33316 33317 33318 33319 33320 33321 | 35098 35099 35100 35101 35102 35103 35104 35105 35106 35107 35108 35109 35110 35111 35112 | - + | /* UNTESTED */ char fsl_repo_is_readonly(fsl_cx const * f){ if(!f || !f->dbMain) return 0; else{ int const roleId = f->ckout.db.dbh ? FSL_DBROLE_MAIN : FSL_DBROLE_REPO /* If CKOUT is attached, it is the main DB and REPO is ATTACHed. */ ; |
︙ | |||
33348 33349 33350 33351 33352 33353 33354 | 35131 35132 35133 35134 35135 35136 35137 35138 35139 35140 35141 35142 35143 35144 35145 35146 35147 35148 35149 35150 35151 35152 35153 35154 35155 35156 35157 35158 35159 35160 35161 35162 35163 35164 35165 35166 35167 35168 35169 35170 35171 35172 35173 35174 35175 35176 35177 35178 35179 35180 35181 35182 35183 35184 35185 | - + - + + + + - + - + - + | dbConf = fsl_cx_db_config(f); if(dbConf){ int const dbRole = (f->dbMain==&f->config.db) ? FSL_DBROLE_MAIN : FSL_DBROLE_CONFIG; rc = fsl_db_exec(dbConf, "INSERT OR IGNORE INTO %s.global_config(name,value) " "VALUES('repo:%q',1)", |
︙ | |||
33433 33434 33435 33436 33437 33438 33439 | 35219 35220 35221 35222 35223 35224 35225 35226 35227 35228 35229 35230 35231 35232 35233 35234 35235 35236 35237 35238 35239 35240 35241 35242 | - + - - + + | if(db->error.code){ fsl_cx_uplift_db_error(f, db); } return rv; } } |
︙ | |||
33489 33490 33491 33492 33493 33494 33495 33496 33497 33498 33499 33500 33501 33502 | 35275 35276 35277 35278 35279 35280 35281 35282 35283 35284 35285 35286 35287 35288 35289 | + | }else if(!fid){ rc = fsl_cx_err_set(f, FSL_RC_NOT_FOUND, "Could not resolve RID for UUID: %s", fc->uuid); }else if(opt.extractContent){ fsl_buffer_reuse(content); rc = fsl_content_get(f, fid, content); //assert(FSL_RC_RANGE!=rc); } if(!rc){ /** Call the callback. */ xst.fCard = fc; assert(fid>0); xst.content = content; xst.fileRid = fid; |
︙ | |||
33556 33557 33558 33559 33560 33561 33562 | 35343 35344 35345 35346 35347 35348 35349 35350 35351 35352 35353 35354 35355 35356 35357 35358 | - - + + | rid, uuid ); assert(cursorKludge.mem == in->mem); return rc; } } |
︙ | |||
33680 33681 33682 33683 33684 33685 33686 | 35467 35468 35469 35470 35471 35472 35473 35474 35475 35476 35477 35478 35479 35480 35481 | - + | } end: fsl__cx_scratchpad_yield(f, sql); fsl_stmt_finalize(&q); return rc; } |
︙ | |||
33820 33821 33822 33823 33824 33825 33826 | 35607 35608 35609 35610 35611 35612 35613 35614 35615 35616 35617 35618 35619 35620 35621 | - + | /** Update the repository schema for Fossil version 2.0. (2017-02-28) (1) Change the CHECK constraint on BLOB.UUID so that the length is greater than or equal to 40, not exactly equal to 40. */ zBlobSchema = fsl_db_g_text(frs->db, NULL, "SELECT sql FROM %!Q.sqlite_schema" |
︙ | |||
33843 33844 33845 33846 33847 33848 33849 | 35630 35631 35632 35633 35634 35635 35636 35637 35638 35639 35640 35641 35642 35643 35644 35645 35646 35647 35648 35649 35650 35651 35652 35653 35654 35655 35656 | - + - + | int rc2 = 0; zBlobSchema[i] = '>'; sqlite3_db_config(frs->db->dbh, SQLITE_DBCONFIG_DEFENSIVE, 0, &rc2); rc = fsl_cx_exec_multi(frs->f, "PRAGMA writable_schema=ON;" "UPDATE %!Q.sqlite_schema SET sql=%Q WHERE name LIKE 'blob';" "PRAGMA writable_schema=OFF;", |
︙ | |||
34024 34025 34026 34027 34028 34029 34030 | 35811 35812 35813 35814 35815 35816 35817 35818 35819 35820 35821 35822 35823 35824 35825 35826 35827 35828 35829 35830 35831 | - + - - - - - - - - + - + | fsl_stmt_bind_id(&frs->qChild, 1, cid); if( FSL_RC_STEP_ROW==fsl_stmt_step(&frs->qChild) && (sz = fsl_stmt_g_int64(&frs->qChild, 1))>=0 ){ fsl_buffer next = fsl_buffer_empty; fsl_buffer delta = fsl_buffer_empty; void const * blob = 0; fsl_size_t deltaBlobSize = 0; |
︙ | |||
34133 34134 34135 34136 34137 34138 34139 | 35913 35914 35915 35916 35917 35918 35919 35920 35921 35922 35923 35924 35925 35926 35927 35928 35929 35930 35931 35932 35933 35934 35935 35936 35937 35938 35939 35940 35941 35942 35943 35944 35945 35946 35947 35948 35949 35950 35951 35952 35953 35954 35955 35956 35957 35958 35959 35960 35961 35962 35963 35964 35965 35966 35967 35968 35969 35970 | - - - - + - + + + - - - + - + - - + + - - | } fsl__cx_scratchpad_yield(frs->f, b); return rc; } |
︙ | |||
34211 34212 34213 34214 34215 34216 34217 34218 34219 34220 34221 34222 34223 34224 | 35986 35987 35988 35989 35990 35991 35992 35993 35994 35995 35996 35997 35998 35999 36000 | + | } //totalSize += incrSize*2; rc = fsl_cx_prepare(f, &s, "SELECT rid, size FROM blob /*scan*/" " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" " AND NOT EXISTS(SELECT 1 FROM delta WHERE rid=blob.rid)" "%s", opt->randomize ? " ORDER BY RANDOM()" : "" ); if(rc) goto end; rc = fsl__crosslink_begin(f) /* Maintenace reminder: if this call succeeds, BE SURE that we do not skip past the fsl__crosslink_end() call via (goto end). Doing so would get the transaction stack out of sync. */; |
︙ | |||
34237 34238 34239 34240 34241 34242 34243 34244 34245 34246 34247 34248 34249 34250 34251 34252 34253 34254 34255 34256 34257 34258 34259 34260 34261 34262 34263 34264 34265 34266 34267 34268 34269 34270 34271 34272 34273 | 36013 36014 36015 36016 36017 36018 36019 36020 36021 36022 36023 36024 36025 36026 36027 36028 36029 36030 36031 36032 36033 36034 36035 36036 36037 36038 36039 36040 36041 36042 36043 36044 36045 36046 36047 36048 36049 36050 36051 36052 36053 36054 36055 36056 36057 36058 36059 36060 36061 36062 36063 36064 36065 36066 36067 36068 36069 36070 36071 36072 36073 36074 36075 36076 36077 36078 36079 36080 36081 36082 36083 36084 36085 36086 36087 36088 36089 36090 36091 36092 36093 36094 36095 36096 | + + + + + + + + + + + + + + + + + + + + + + + + - + + - | } } fsl_stmt_finalize(&s); if(rc) goto crosslink_end; rc = fsl_cx_prepare(f, &s, "SELECT rid, size FROM blob" " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" "%s", opt->randomize ? " ORDER BY RANDOM()" : "" ); while( 0==rc && FSL_RC_STEP_ROW==fsl_stmt_step(&s) ){ fsl_id_t const rid = fsl_stmt_g_id(&s, 0); int64_t const size = fsl_stmt_g_int64(&s, 1); if( size>=0 ){ if( !fsl_id_bag_contains(&frs.idsDone, rid) ){ fsl_buffer content = fsl_buffer_empty; rc = fsl_content_get(f, rid, &content); if(0==rc){ rc = fsl__rebuild_step(&frs, rid, size, &content); assert(!content.mem); } /* 2021-12-17: hmmm... while debugging the problem reported here: https://fossil-scm.org/forum/forumpost/f4cc31863179f843 It was discovered that fossil will simply skip any content it cannot read in this step, even if it's skipped over because of a broken blob-to-delta mapping (whereas fossil's test-integrity command will catch that case). If such a case happens to us, fsl_content_get() fails with FSL_RC_PHANTOM. That seems to me to be the right thing to do, as such a case is indicative of db corruption. However, if we skip over these then we cannot rebuild a repo which has such (invalid) state. Feature or bug? For now let's keep it strict and fail if we can't fetch the content. We can reevaluate that decision later if needed. We can add a fsl_rebuild_opt::ignorePhantomFailure (better name pending!) flag which tells us how the user would prefer to deal with this. */ fsl_buffer_clear(&content); } }else{ rc = fsl_cx_exec_multi(f, "INSERT OR IGNORE INTO phantom " "VALUES(%" FSL_ID_T_PFMT ")", rid); if(0==rc){ frs.step.blobSize = -1; frs.step.artifactType = FSL_SATYPE_INVALID; rc = fsl__rebuild_step_done(&frs, rid); } } } fsl_stmt_finalize(&s); crosslink_end: rc = fsl__crosslink_end(f, rc); if(rc) goto end; rc = fsl__rebuild_tag_trunk(&frs); if(rc) goto end; |
︙ | |||
34305 34306 34307 34308 34309 34310 34311 | 36105 36106 36107 36108 36109 36110 36111 36112 36113 36114 36115 36116 36117 36118 36119 36120 36121 36122 36123 36124 36125 36126 36127 36128 36129 36130 36131 36132 36133 36134 36135 36136 36137 36138 36139 36140 36141 36142 36143 36144 36145 36146 36147 36148 36149 36150 36151 36152 36153 36154 36155 36156 36157 36158 36159 36160 36161 36162 36163 36164 36165 36166 36167 36168 36169 36170 36171 36172 36173 36174 36175 36176 36177 36178 36179 36180 36181 36182 36183 36184 36185 36186 36187 36188 36189 36190 36191 36192 36193 36194 36195 36196 36197 36198 36199 36200 36201 36202 36203 36204 36205 36206 36207 36208 36209 36210 36211 36212 36213 36214 36215 36216 36217 36218 36219 36220 36221 36222 | - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + | int const rc2 = fsl_cx_transaction_end(f, opt->dryRun || rc!=0); if(0==rc && 0!=rc2) rc = rc2; } fsl_cx_interrupt(f, 0, NULL); return rc; } |
︙ | |||
34364 34365 34366 34367 34368 34369 34370 | 36264 36265 36266 36267 36268 36269 36270 36271 36272 36273 36274 36275 36276 36277 36278 36279 | - - + + | return fsl_schema_ticket_cstr; } char const * fsl_schema_forum(){ extern char const * fsl_schema_forum_cstr; return fsl_schema_forum_cstr; } |
︙ | |||
34465 34466 34467 34468 34469 34470 34471 | 36365 36366 36367 36368 36369 36370 36371 36372 36373 36374 36375 36376 36377 36378 36379 36380 | - - + + | /* All forum posts are always indexed */ end: return rc; #endif } #undef MARKER |
︙ | |||
36369 36370 36371 36372 36373 36374 36375 | 38269 38270 38271 38272 38273 38274 38275 38276 38277 38278 38279 38280 38281 38282 38283 38284 | - - + + | fsl_sha1_init(&ctx); fsl_sha1_update(&ctx, zIn, (len<0) ? fsl_strlen(zIn) : (fsl_size_t)len); fsl_sha1_final_hex(&ctx, zHex); return zHex; } } |
︙ | |||
37004 37005 37006 37007 37008 37009 37010 37011 37012 37013 | 38904 38905 38906 38907 38908 38909 38910 38911 38912 38913 38914 38915 38916 38917 38918 38919 38920 38921 38922 38923 38924 38925 38926 38927 38928 38929 38930 38931 38932 38933 38934 38935 38936 38937 38938 38939 38940 38941 38942 38943 38944 38945 38946 38947 38948 | + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + | fsl_sha3_end(&ctx); rc = fsl_buffer_append(pCksum, ctx.hex, fsl_strlen(ctx.hex)); return rc; #endif } } #undef A00 #undef A01 #undef A02 #undef A03 #undef A04 #undef A10 #undef A11 #undef A12 #undef A13 #undef A14 #undef A20 #undef A21 #undef A22 #undef A23 #undef A24 #undef A30 #undef A31 #undef A32 #undef A33 #undef A34 #undef A40 #undef A41 #undef A42 #undef A43 #undef A44 #undef ROL64 #undef SHA3_BYTEORDER #undef MARKER |
︙ | |||
37619 37620 37621 37622 37623 37624 37625 | 39545 39546 39547 39548 39549 39550 39551 39552 39553 39554 39555 39556 39557 39558 39559 39560 | - - + + | */ fsl_size_t fsl_strftime_unix(char * dest, fsl_size_t destLen, char const * format, fsl_time_t epochTime, bool convertToLocal){ time_t orig = (time_t)epochTime; struct tm * tim = convertToLocal ? localtime(&orig) : gmtime(&orig); return fsl_strftime( dest, destLen, format, tim ); } |
︙ | |||
38258 38259 38260 38261 38262 38263 38264 | 40184 40185 40186 40187 40188 40189 40190 40191 40192 40193 40194 40195 40196 40197 40198 40199 | - - + + | fsl_deck_finalize(&parent); fsl_deck_finalize(&deck); return rc; } #undef MARKER |
︙ | |||
38287 38288 38289 38290 38291 38292 38293 | 40213 40214 40215 40216 40217 40218 40219 40220 40221 40222 40223 40224 40225 40226 40227 40228 40229 40230 40231 40232 40233 40234 40235 40236 40237 40238 40239 40240 40241 40242 40243 40244 40245 40246 40247 40248 40249 40250 40251 40252 40253 40254 40255 40256 40257 40258 40259 40260 40261 40262 40263 40264 40265 40266 40267 40268 40269 40270 40271 40272 40273 40274 40275 40276 40277 40278 40279 40280 40281 40282 40283 40284 40285 40286 40287 40288 40289 40290 40291 40292 40293 40294 40295 40296 40297 40298 40299 40300 | - + - + - - - + - - - + - - + + + + - + + + + + + + - + + + + + + + - + | int rc; if(!db) return FSL_RC_NOT_A_REPO; rc = fsl_cx_exec_multi(f, "DROP TABLE IF EXISTS ticket;" "DROP TABLE IF EXISTS ticketchng;" ); if(!rc){ |
︙ | |||
38374 38375 38376 38377 38378 38379 38380 | 40310 40311 40312 40313 40314 40315 40316 40317 40318 40319 40320 40321 40322 40323 40324 40325 40326 40327 40328 40329 40330 40331 40332 40333 40334 40335 40336 40337 40338 40339 40340 40341 40342 40343 40344 40345 40346 40347 40348 40349 40350 40351 40352 40353 40354 40355 40356 40357 40358 40359 40360 40361 40362 40363 40364 40365 40366 40367 40368 40369 40370 40371 40372 40373 40374 40375 40376 40377 40378 40379 40380 40381 40382 40383 40384 40385 40386 40387 40388 40389 40390 40391 40392 40393 40394 40395 40396 40397 40398 40399 40400 40401 40402 40403 40404 40405 40406 40407 40408 40409 40410 40411 40412 40413 40414 40415 40416 40417 40418 40419 40420 40421 40422 40423 40424 40425 40426 40427 40428 40429 40430 40431 40432 40433 40434 40435 40436 40437 40438 40439 40440 40441 40442 40443 40444 40445 40446 40447 40448 40449 40450 40451 40452 40453 40454 40455 40456 40457 40458 40459 40460 40461 40462 40463 40464 40465 40466 40467 40468 40469 40470 40471 40472 40473 40474 40475 40476 40477 40478 40479 40480 40481 40482 40483 40484 40485 40486 40487 40488 40489 40490 40491 40492 40493 40494 40495 40496 40497 40498 40499 40500 40501 40502 40503 40504 40505 40506 40507 40508 40509 40510 40511 40512 40513 40514 40515 40516 40517 40518 40519 40520 40521 40522 40523 40524 40525 40526 40527 40528 40529 40530 40531 40532 40533 40534 40535 40536 40537 40538 40539 40540 40541 40542 40543 40544 40545 40546 40547 40548 40549 40550 40551 40552 40553 40554 40555 40556 40557 40558 40559 40560 40561 40562 40563 40564 40565 40566 40567 40568 40569 40570 40571 40572 40573 40574 40575 40576 40577 40578 40579 40580 40581 40582 40583 40584 40585 40586 40587 40588 40589 40590 40591 40592 40593 40594 40595 40596 40597 40598 40599 40600 40601 40602 40603 40604 40605 40606 40607 40608 40609 40610 40611 40612 40613 40614 40615 40616 40617 40618 40619 40620 40621 40622 40623 40624 40625 40626 40627 40628 40629 40630 40631 40632 40633 40634 40635 40636 40637 40638 40639 40640 40641 40642 40643 40644 40645 40646 40647 40648 40649 40650 40651 40652 40653 40654 40655 40656 40657 40658 40659 40660 40661 40662 40663 40664 40665 40666 40667 40668 40669 40670 40671 40672 40673 40674 40675 40676 40677 40678 40679 40680 40681 40682 40683 40684 40685 40686 40687 40688 40689 40690 40691 40692 40693 40694 40695 40696 40697 40698 40699 40700 40701 40702 40703 40704 40705 40706 40707 40708 40709 40710 40711 40712 40713 40714 40715 40716 40717 40718 40719 40720 40721 40722 40723 40724 40725 40726 40727 40728 40729 40730 40731 40732 40733 40734 40735 40736 40737 40738 40739 40740 40741 40742 40743 40744 40745 40746 40747 40748 40749 40750 40751 40752 40753 40754 40755 40756 40757 40758 40759 40760 40761 40762 40763 40764 40765 40766 40767 40768 40769 40770 40771 40772 40773 40774 40775 40776 40777 40778 40779 40780 40781 40782 40783 40784 40785 40786 40787 40788 40789 40790 40791 40792 40793 40794 40795 40796 40797 40798 40799 40800 40801 40802 40803 40804 40805 40806 40807 40808 40809 40810 40811 40812 40813 40814 40815 40816 40817 40818 40819 40820 40821 40822 40823 40824 40825 40826 40827 40828 40829 40830 40831 40832 40833 40834 40835 40836 40837 40838 40839 40840 40841 40842 40843 40844 40845 40846 40847 40848 40849 40850 40851 40852 40853 40854 40855 40856 40857 40858 40859 40860 40861 40862 40863 40864 40865 40866 40867 40868 40869 40870 40871 40872 40873 40874 40875 40876 40877 40878 40879 40880 40881 40882 40883 40884 40885 40886 40887 40888 40889 40890 40891 40892 40893 40894 40895 40896 40897 40898 40899 40900 40901 40902 40903 40904 40905 40906 40907 40908 40909 40910 40911 40912 40913 40914 40915 40916 40917 40918 40919 40920 40921 40922 40923 40924 40925 40926 40927 40928 40929 40930 40931 40932 40933 40934 40935 40936 40937 40938 40939 40940 40941 40942 40943 40944 40945 40946 40947 40948 40949 40950 40951 40952 40953 40954 40955 40956 40957 40958 40959 40960 40961 40962 40963 40964 40965 40966 40967 40968 40969 40970 40971 40972 40973 40974 40975 40976 40977 40978 40979 40980 40981 40982 40983 40984 40985 40986 40987 40988 40989 40990 40991 40992 40993 40994 40995 40996 40997 40998 40999 41000 41001 41002 41003 41004 41005 41006 41007 41008 41009 41010 41011 41012 41013 41014 41015 41016 41017 41018 41019 41020 41021 41022 41023 41024 41025 41026 41027 41028 41029 41030 41031 41032 41033 41034 41035 41036 41037 41038 41039 41040 41041 41042 41043 41044 41045 41046 41047 41048 41049 41050 41051 41052 41053 41054 41055 41056 41057 41058 41059 41060 41061 41062 41063 41064 41065 41066 41067 41068 41069 41070 41071 41072 41073 41074 41075 41076 41077 41078 41079 41080 41081 41082 41083 41084 41085 41086 41087 41088 41089 41090 41091 41092 41093 41094 41095 41096 41097 41098 41099 41100 41101 41102 41103 41104 41105 41106 41107 41108 41109 41110 41111 41112 41113 41114 41115 41116 41117 41118 41119 41120 41121 41122 41123 41124 41125 41126 41127 41128 41129 41130 41131 41132 41133 41134 41135 41136 41137 41138 41139 41140 41141 41142 41143 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + | fsl_stmt_finalize(&q); end: if(!rc){ fsl_list_sort(li, fsl__qsort_cmp_J_cards); } return rc; } static int fsl__ticket_insert(fsl_deck * const d, fsl_id_t tktId, fsl_id_t * const tgtId){ /* Derived from fossil(1) tkt.c:ticket_insert() */; fsl_cx * const f = d->f; fsl_id_t const rid = d->rid; int rc = 0; fsl_buffer * const sql1 = fsl__cx_scratchpad(f); fsl_buffer * const sql2 = fsl__cx_scratchpad(f); fsl_buffer * const sql3 = fsl__cx_scratchpad(f); fsl_db * const db = fsl_cx_db_repo(f); fsl_list const * const cf = &f->ticket.customFields; fsl_size_t i; //char const * zMimetype = NULL; fsl_stmt q = fsl_stmt_empty; char aUsed[cf->used]; assert(rid>0 && f!=NULL && db); if(0==tktId){ rc = fsl_cx_exec_multi(f, "INSERT INTO ticket(tkt_uuid, tkt_mtime) " "VALUES(%Q, 0)", d->K); if(rc) goto end; tktId = fsl_db_last_insert_id(db); } rc = fsl_buffer_append(sql1, "UPDATE OR REPLACE ticket SET tkt_mtime=?1", -1); if(0==rc && f->ticket.hasCTime){ rc = fsl_buffer_append(sql1, ", tkt_ctime=coalesce(tkt_ctime,?1)", -1); } if(rc) goto end; memset(aUsed, 0, cf->used); for(i = 0; 0==rc && i < d->J.used; ++i){ fsl_card_J const * const dJC = (fsl_card_J*)d->J.list[i]; int const j = fsl__tkt_field_id(cf, dJC->field); if(j<0){ /* Ticket has a field which this repo does not have. Skip it. */ continue; } aUsed[j] = FSL_CARD_J_TICKET; fsl_card_J const * const rJC = (fsl_card_J*)cf->list[j]; if(rJC->flags & FSL_CARD_J_TICKET){ if(dJC->append){ rc = fsl_buffer_appendf(sql1, ", %!Q=coalesce(%!Q,'') || %Q", dJC->field, dJC->field, dJC->value); }else{ rc = fsl_buffer_appendf(sql1, ", %!Q=%Q", dJC->field, dJC->value); } if(rc) break; } if(rJC->flags & FSL_CARD_J_CHNG){ rc = fsl_buffer_appendf(sql2, ",%!Q", dJC->field); if(0==rc) rc = fsl_buffer_appendf(sql3, ",%Q", dJC->value); if(rc) break; } #if 0 if(0==fsl_strcmp(dJC->field, "mimetype")){ zMimetype = dJC->value; } #endif } if(rc) goto end; /* MISSING: a block from fossil(1) tkt.c which extracts backlinks: if( rid>0 ){ for(i=0; i<p->nField; i++){ const char *zName = p->aField[i].zName; const char *zBaseName = zName[0]=='+' ? zName+1 : zName; j = fieldId(zBaseName); if( j<0 ) continue; backlink_extract(p->aField[i].zValue, zMimetype, rid, BKLNK_TICKET, p->rDate, i==0); } } That's not critical for core ticket functionality. */ rc = fsl_buffer_appendf(sql1, " WHERE tkt_id=%" FSL_ID_T_PFMT, tktId); if(rc) goto end; rc = fsl_cx_prepare(f, &q, "%b", sql1); if(rc) goto end; rc = fsl_stmt_bind_step(&q, "f", d->D); fsl_stmt_finalize(&q); if(rc) goto end; fsl_buffer_reuse(sql1); if(f->ticket.hasChngRid || sql2->used){ bool fromTkt = false; if(f->ticket.hasChngRid){ rc = fsl_buffer_append(sql2, ",tkt_rid", -1); if(0==rc) rc = fsl_buffer_appendf(sql3, ",%" FSL_ID_T_PFMT, d->rid); if(rc) goto end; } for(i = 0; 0==rc && i < cf->used; ++i){ fsl_card_J const * const rJC = (fsl_card_J*)cf->list[i]; if(0==aUsed[i] && (rJC->flags & FSL_CARD_J_BOTH)==FSL_CARD_J_BOTH){ fromTkt = true; rc = fsl_buffer_appendf(sql2, ",%!Q", rJC->field); if(0==rc) rc = fsl_buffer_appendf(sql3, ",%!Q", rJC->field); } } if(rc) goto end; if(fromTkt){ rc = fsl_cx_prepare(f, &q, "INSERT INTO ticketchng(tkt_id,tkt_mtime%b)" "SELECT %"FSL_ID_T_PFMT",?1%b " "FROM ticket WHERE tkt_id=%"FSL_ID_T_PFMT, sql2, tktId, sql3, tktId); }else{ rc = fsl_cx_prepare(f, &q, "INSERT INTO ticketchng(tkt_id,tkt_mtime%b)" "VALUES(%"FSL_ID_T_PFMT",?1%b)", sql2, tktId, sql3); } if(0==rc) rc = fsl_stmt_bind_step(&q, "f", d->D); } end: fsl_stmt_finalize(&q); fsl__cx_scratchpad_yield(f, sql1); fsl__cx_scratchpad_yield(f, sql2); fsl__cx_scratchpad_yield(f, sql3); *tgtId = tktId; return rc; } static int fsl__ticket_timeline_entry(fsl_deck * const d, bool isNew, fsl_id_t tagId){ /* Derived from fossil(1) manifest.c:mainfest_ticket_event() */; int rc; fsl_buffer * const comment = fsl__cx_scratchpad(d->f); fsl_buffer * const brief = fsl__cx_scratchpad(d->f); char * zTitle = 0; char * zNewStatus = 0; fsl_db * const db = fsl_cx_db_repo(d->f); fsl_cx * const f = d->f; if(!f->ticket.titleColumn){ assert(!f->ticket.statusColumn); rc = fsl_db_get_text(db, &f->ticket.titleColumn, NULL, "SELECT coalesce(" "(SELECT value FROM config WHERE name='ticket-title-expr')," "'title')"); if(0==rc){ rc = fsl_db_get_text(db, &f->ticket.statusColumn, NULL, "SELECT coalesce(" "(SELECT value FROM config WHERE name='ticket-status-column')," "'status')"); } if(rc) return fsl_cx_uplift_db_error( f, db ); } rc = fsl_db_get_text(db, &zTitle, NULL, "SELECT coalesce(%!Q,'unknown') " "FROM ticket WHERE tkt_uuid=%Q", f->ticket.titleColumn, d->K); if(rc){ fsl_cx_uplift_db_error(d->f, db); goto end; } if(isNew){ rc = fsl_buffer_appendf(comment, "New ticket [%!S|%S] <i>%h</i>.", d->K, d->K, zTitle); if(0==rc){ rc = fsl_buffer_appendf(brief, "New ticket [%!S|%S].", d->K, d->K); } if(rc) goto end; }else{ // Update an existing ticket... char * zNewStatus = 0; for(fsl_size_t i = 0; i < d->J.used; ++i){ fsl_card_J const * const jc = (fsl_card_J*)d->J.list[i]; if(0==fsl_strcmp(jc->field, f->ticket.statusColumn)){ zNewStatus = jc->value; break; } } if(zNewStatus){ rc = fsl_buffer_appendf(comment, "%h ticket [%!S|%S]: <i>%h</i>", zNewStatus, d->K, d->K, zTitle); if(!rc && d->J.used>1){ rc = fsl_buffer_appendf(comment, " plus %d other change%s", (int)d->J.used-1, d->J.used==2 ? "" : "s"); } if(0==rc) rc = fsl_buffer_appendf(brief, "%h ticket [%!S|%S].", zNewStatus, d->K, d->K); if(rc) goto end; }else{ rc = fsl_db_get_text(db, &zNewStatus, NULL, "SELECT coalesce(%!Q,'unknown') " "FROM ticket WHERE tkt_uuid=%Q", f->ticket.statusColumn, d->K); if(rc){ rc = fsl_cx_uplift_db_error2(f, db, rc); goto end; } rc = fsl_buffer_appendf(comment, "Ticket [%!S|%S] <i>%h</i> " "status still %h with %d other change%s", d->K, d->K, zTitle, zNewStatus, (int)d->J.used, 1==d->J.used ? "" : "s"); fsl_free(zNewStatus); if(rc) goto end; rc = fsl_buffer_appendf(brief, "Ticket [%!S|%S]: %d change%s", d->K, d->K, (int)d->J.used, 1==d->J.used ? "" : "s"); if(rc) goto end; } } assert(0==rc); // MISSING: manifest_create_event_triggers() rc = fsl_cx_exec(d->f, "REPLACE INTO event" "(type, tagid, mtime, objid, user, comment, brief) " "VALUES('t', %"FSL_ID_T_PFMT", %"FSL_JULIAN_T_PFMT", " "%"FSL_ID_T_PFMT",%Q,%B,%B)", tagId, d->D, d->rid, d->U, comment, brief); end: fsl_free(zTitle); fsl_free(zNewStatus); fsl__cx_scratchpad_yield(d->f, comment); fsl__cx_scratchpad_yield(d->f, brief); return rc; } int fsl__ticket_rebuild(fsl_cx * const f, char const * zTktKCard){ int rc; fsl_id_t tktId; fsl_id_t tagId; fsl_db * const db = fsl_needs_repo(f); fsl_stmt q = fsl_stmt_empty; if(!db) return FSL_RC_NOT_A_REPO; assert(!f->cache.isCrosslinking); rc = fsl__cx_ticket_load_fields(f, false); if(rc) goto end; else if(!f->ticket.hasTicket) return 0; char * const zTag = fsl_mprintf("tkt-%s", zTktKCard); if(!zTag){ rc = FSL_RC_OOM; goto end; } tagId = fsl_tag_id(f, zTag, true); fsl_free(zTag); if(tagId<0){ rc = f->error.code; assert(0!=rc); goto end; } tktId = fsl_db_g_id(db, 0, "SELECT tkt_id FROM ticket " "WHERE tkt_uuid=%Q", zTktKCard); if(tktId>0){ if(f->ticket.hasChng){ rc = fsl_cx_exec(f, "DELETE FROM ticketchng " "WHERE tkt_id=%" FSL_ID_T_PFMT, tktId); } if(!rc) rc = fsl_cx_exec(f, "DELETE FROM ticket " "WHERE tkt_id=%" FSL_ID_T_PFMT, tktId); if(rc) goto end; } tktId = 0; rc = fsl_cx_prepare(f, &q, "SELECT rid FROM tagxref " "WHERE tagid=%" FSL_ID_T_PFMT " ORDER BY mtime", tagId); int counter = 0; /* Potential TODO (fossil does not do this): DELETE FROM EVENT WHERE tagid=${tagId} */ while(0==rc && FSL_RC_STEP_ROW==fsl_stmt_step(&q)){ fsl_deck deck = fsl_deck_empty; fsl_id_t const rid = fsl_stmt_g_id(&q, 0); rc = fsl_deck_load_rid(f, &deck, rid, FSL_SATYPE_TICKET); if(rc) goto outro; assert(deck.rid==rid); rc = fsl__ticket_insert(&deck, tktId, &tktId); if(0==rc){ rc = fsl__ticket_timeline_entry(&deck, 0==counter++, tagId); if(0==rc) rc = fsl__call_xlink_listeners(&deck); } outro: fsl_deck_finalize(&deck); } end: fsl_stmt_finalize(&q); return rc; } /* end of file ./src/ticket.c */ /* start of file ./src/udf.c */ /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=2 et sw=2 tw=80: */ /* Copyright 2013-2021 The Libfossil Authors, see LICENSES/BSD-2-Clause.txt SPDX-License-Identifier: BSD-2-Clause-FreeBSD SPDX-FileCopyrightText: 2021 The Libfossil Authors SPDX-ArtifactOfProjectName: Libfossil SPDX-FileType: Code Heavily indebted to the Fossil SCM project (https://fossil-scm.org). */ /************************************************************************* This file houses fsl_cx-related sqlite3 User Defined Functions (UDFs). */ #if !defined(FSL_ENABLE_SQLITE_REGEXP) # define FSL_ENABLE_SQLITE_REGEXP 0 #endif #if FSL_ENABLE_SQLITE_REGEXP #endif #include <assert.h> /* Only for debugging */ #include <stdio.h> #define MARKER(pfexp) \ do{ printf("MARKER: %s:%d:%s():\t",__FILE__,__LINE__,__func__); \ printf pfexp; \ } while(0) /** SQL function for debugging. The print() function writes its arguments to fsl_output() if the bound fsl_cx->cxConfig.sqlPrint flag is true. */ static void fsl_db_sql_print( sqlite3_context *context, int argc, sqlite3_value **argv ){ fsl_cx * f = (fsl_cx*)sqlite3_user_data(context); assert(f); if( f->cxConfig.sqlPrint ){ int i; for(i=0; i<argc; i++){ char c = i==argc-1 ? '\n' : ' '; fsl_outputf(f, "%s%c", sqlite3_value_text(argv[i]), c); } } } /** SQL function to return the number of seconds since 1970. This is the same as strftime('%s','now') but is more compact. */ static void fsl_db_now_udf( sqlite3_context *context, int argc, sqlite3_value **argv ){ sqlite3_result_int64(context, (sqlite3_int64)time(0)); } /** SQL function to convert a Julian Day to a Unix timestamp. */ static void fsl_db_j2u_udf( sqlite3_context *context, int argc, sqlite3_value **argv ){ double const jd = (double)sqlite3_value_double(argv[0]); sqlite3_result_int64(context, (sqlite3_int64)fsl_julian_to_unix(jd)); } /** SQL function FSL_CKOUT_DIR([bool includeTrailingSlash=1]) returns the top-level checkout directory, optionally (by default) with a trailing slash. Returns NULL if the fsl_cx instance bound to sqlite3_user_data() has no checkout. */ static void fsl_db_cx_chkout_dir_udf( sqlite3_context *context, int argc, sqlite3_value **argv ){ fsl_cx * f = (fsl_cx*)sqlite3_user_data(context); int const includeSlash = argc ? sqlite3_value_int(argv[0]) : 1; if(f && f->ckout.dir && f->ckout.dirLen){ sqlite3_result_text(context, f->ckout.dir, (int)f->ckout.dirLen - (includeSlash ? 0 : 1), SQLITE_TRANSIENT); }else{ sqlite3_result_null(context); } } /** SQL Function to return the check-in time for a file. Requires (vid,fid) RID arguments, as described for fsl_mtime_of_manifest_file(). */ static void fsl_db_checkin_mtime_udf( sqlite3_context *context, int argc, sqlite3_value **argv ){ fsl_cx * f = (fsl_cx*)sqlite3_user_data(context); fsl_time_t mtime = 0; int rc; fsl_id_t vid, fid; assert(f); vid = (fsl_id_t)sqlite3_value_int(argv[0]); fid = (fsl_id_t)sqlite3_value_int(argv[1]); rc = fsl_mtime_of_manifest_file(f, vid, fid, &mtime); if( rc==0 ){ sqlite3_result_int64(context, mtime); }else{ sqlite3_result_error(context, "fsl_mtime_of_manifest_file() failed", -1); } } /** SQL UDF binding for fsl_content_get(). FSL_CONTENT(RID INTEGER | SYMBOLIC_NAME) returns the undeltified/uncompressed content of the [blob] record identified by the given RID or symbolic name. */ static void fsl_db_content_udf( sqlite3_context *context, int argc, sqlite3_value **argv ){ fsl_cx * const f = (fsl_cx*)sqlite3_user_data(context); fsl_id_t rid = 0; char const * arg; int rc; fsl_buffer b = fsl_buffer_empty; assert(f); if(1 != argc){ sqlite3_result_error(context, "Expecting one argument", -1); return; } if(SQLITE_INTEGER==sqlite3_value_type(argv[0])){ rid = (fsl_id_t)sqlite3_value_int64(argv[0]); arg = NULL; }else{ arg = (const char*)sqlite3_value_text(argv[0]); if(!arg){ sqlite3_result_error(context, "Invalid argument", -1); return; } rc = fsl_sym_to_rid(f, arg, FSL_SATYPE_ANY, &rid); if(rc) goto cx_err; else if(!rid){ sqlite3_result_error(context, "No blob found", -1); return; } } rc = fsl_content_get(f, rid, &b); if(rc) goto cx_err; /* Curiously, i'm seeing no difference in allocation counts here whether we copy the blob here or pass off ownership... */ sqlite3_result_blob(context, b.mem, (int)b.used, fsl_free); b = fsl_buffer_empty; return; cx_err: fsl_buffer_clear(&b); assert(f->error.msg.used); if(FSL_RC_OOM==rc){ sqlite3_result_error_nomem(context); }else{ assert(f->error.msg.used); sqlite3_result_error(context, (char const *)f->error.msg.mem, (int)f->error.msg.used); } } /** SQL UDF FSL_SYM2RID(SYMBOLIC_NAME) resolves the name to a [blob].[rid] value or triggers an error if it cannot be resolved. */ static void fsl_db_sym2rid_udf( sqlite3_context *context, int argc, sqlite3_value **argv ){ fsl_cx * const f = (fsl_cx*)sqlite3_user_data(context); char const * arg; assert(f); if(1 != argc){ sqlite3_result_error(context, "Expecting one argument", -1); return; } arg = (const char*)sqlite3_value_text(argv[0]); if(!arg){ sqlite3_result_error(context, "Expecting a STRING argument", -1); }else{ fsl_id_t rid = 0; int const rc = fsl_sym_to_rid(f, arg, FSL_SATYPE_ANY, &rid); if(rc){ if(FSL_RC_OOM==rc){ sqlite3_result_error_nomem(context); }else{ assert(f->error.msg.used); sqlite3_result_error(context, (char const *)f->error.msg.mem, (int)f->error.msg.used); } fsl_cx_err_reset(f) /* This is arguable but keeps this error from poluting down-stream code (seen it happen in unit tests). The irony is, it's very possible/likely that the error will propagate back up into f->error at some point. */; }else{ assert(rid>0); sqlite3_result_int64(context, rid); } } } static void fsl_db_dirpart_udf( sqlite3_context *context, int argc, sqlite3_value **argv ){ char const * arg; int rc; fsl_buffer b = fsl_buffer_empty; int fSlash = 0; if(argc<1 || argc>2){ sqlite3_result_error(context, "Expecting (string) or (string,bool) arguments", -1); return; } arg = (const char*)sqlite3_value_text(argv[0]); if(!arg){ sqlite3_result_error(context, "Invalid argument", -1); return; } if(argc>1){ fSlash = sqlite3_value_int(argv[1]); } rc = fsl_file_dirpart(arg, -1, &b, fSlash ? 1 : 0); if(!rc){ if(b.used && *b.mem){ #if 0 sqlite3_result_text(context, (char const *)b.mem, (int)b.used, SQLITE_TRANSIENT); #else sqlite3_result_text(context, (char const *)b.mem, (int)b.used, fsl_free); b = fsl_buffer_empty /* we passed ^^^^^ on ownership of b.mem */; #endif }else{ sqlite3_result_null(context); } }else{ if(FSL_RC_OOM==rc){ sqlite3_result_error_nomem(context); }else{ sqlite3_result_error(context, "fsl_dirpart() failed!", -1); } } fsl_buffer_clear(&b); } /* Implement the user() SQL function. user() takes no arguments and returns the user ID of the current user. */ static void fsl_db_user_udf( sqlite3_context *context, int argc, sqlite3_value **argv ){ fsl_cx * f = (fsl_cx*)sqlite3_user_data(context); assert(f); if(f->repo.user){ sqlite3_result_text(context, f->repo.user, -1, SQLITE_STATIC); }else{ sqlite3_result_null(context); } } /** SQL function: fsl_is_enqueued(vfile.id) fsl_if_enqueued(vfile.id, X, Y) On the commit command, when filenames are specified (in order to do a partial commit) the vfile.id values for the named files are loaded into the fsl_cx state. This function looks at that state to see if a file is named in that list. In the first form (1 argument) return TRUE if either no files are named (meaning that all changes are to be committed) or if id is found in the list. In the second form (3 arguments) return argument X if true and Y if false unless Y is NULL, in which case always return X. */ static void fsl_db_selected_for_checkin_udf( sqlite3_context *context, int argc, sqlite3_value **argv ){ int rc = 0; fsl_cx * f = (fsl_cx*)sqlite3_user_data(context); fsl_id_bag * bag = &f->ckin.selectedIds; assert(argc==1 || argc==3); if( bag->entryCount ){ fsl_id_t const iId = (fsl_id_t)sqlite3_value_int64(argv[0]); rc = iId ? (fsl_id_bag_contains(bag, iId) ? 1 : 0) : 0; }else{ rc = 1; } if(1==argc){ sqlite3_result_int(context, rc); }else{ assert(3 == argc); assert( rc==0 || rc==1 ); if( sqlite3_value_type(argv[2-rc])==SQLITE_NULL ) rc = 1-rc; sqlite3_result_value(context, argv[2-rc]); } } /** fsl_match_vfile_or_dir(p1,p2) A helper for resolving expressions like: WHERE pathname='X' C OR (pathname>'X/' C AND pathname<'X0' C) i.e. is 'X' a match for the LHS or is it a directory prefix of LHS? C = empty or COLLATE NOCASE, depending on the case-sensitivity setting of the fsl_cx instance associated with sqlite3_user_data(context). p1 is typically vfile.pathname or vfile.origname, and p2 is the string being compared against that. Resolves to NULL if either argument is NULL, 0 if the comparison shown above is false, 1 if the comparison is an exact match, or 2 if p2 is a directory prefix part of p1. */ static void fsl_db_match_vfile_or_dir( sqlite3_context *context, int argc, sqlite3_value **argv ){ fsl_cx * f = (fsl_cx*)sqlite3_user_data(context); char const * p1; char const * p2; fsl_buffer * b = 0; int rc = 0; assert(f); if(2 != argc){ sqlite3_result_error(context, "Expecting two arguments", -1); return; } p1 = (const char*)sqlite3_value_text(argv[0]); p2 = (const char*)sqlite3_value_text(argv[1]); if(!p1 || !p2){ sqlite3_result_null(context); return; } int (*cmp)(char const *, char const *) = f->cache.caseInsensitive ? fsl_stricmp : fsl_strcmp; if(0==cmp(p1, p2)){ sqlite3_result_int(context, 1); return; } b = fsl__cx_scratchpad(f); rc = fsl_buffer_appendf(b, "%s/", p2); if(rc) goto oom; else if(cmp(p1, fsl_buffer_cstr(b))>0){ b->mem[b->used-1] = '0'; if(cmp(p1, fsl_buffer_cstr(b))<0) rc = 2; } assert(0==rc || 2==rc); sqlite3_result_int(context, rc); end: fsl__cx_scratchpad_yield(f, b); return; oom: sqlite3_result_error_nomem(context); goto end; } /** F(glob-list-name, filename) Returns 1 if the 2nd argument matches any glob in the fossil glob list named by the first argument. The first argument must be a name resolvable via fsl_glob_name_to_category() or an error is triggered. The second value is intended to be a string, but NULL is accepted (but never matches anything). If no match is found, 0 is returned. An empty glob list never matches anything. */ static void fsl_db_cx_glob_udf( sqlite3_context *context, int argc, sqlite3_value **argv ){ fsl_cx * const f = (fsl_cx*)sqlite3_user_data(context); fsl_list * li = NULL; fsl_glob_category_e globType; char const * p1; char const * p2; p2 = (const char*)sqlite3_value_text(argv[1])/*value to check*/; if(NULL==p2 || 0==p2[0]){ sqlite3_result_int(context, 0); return; } p1 = (const char*)sqlite3_value_text(argv[0])/*glob set name*/; globType = fsl_glob_name_to_category(p1); if(FSL_GLOBS_INVALID==globType){ char buf[100] = {0}; buf[sizeof(buf)-1] = 0; fsl_snprintf(buf, (fsl_size_t)sizeof(buf)-1, "Unknown glob pattern name: %#.*s", 50, p1 ? p1 : "NULL"); sqlite3_result_error(context, buf, -1); return; } fsl_cx_glob_list(f, globType, &li, false); assert(li); sqlite3_result_int(context, fsl_glob_list_matches(li, p2) ? 1 : 0); } /** Plug in fsl_cx-specific db functionality into the given db handle. This must only be passed the MAIN db handle for the context. */ int fsl__cx_init_db(fsl_cx * const f, fsl_db * const db){ int rc; assert(!f->dbMain); if(f->cxConfig.traceSql){ fsl_db_sqltrace_enable(db, stdout); } f->dbMain = db; db->role = FSL_DBROLE_MAIN; /* This all comes from db.c:db_open()... */ /* FIXME: check result codes here. */ sqlite3 * const dbh = db->dbh; sqlite3_busy_timeout(dbh, 5000 /* historical value */); sqlite3_wal_autocheckpoint(dbh, 1); /* Set to checkpoint frequently */ rc = fsl_cx_exec_multi(f, "PRAGMA foreign_keys=OFF;" // ^^^ vmerge table relies on this for its magical // vmerge.id values. //"PRAGMA main.temp_store=FILE;" //"PRAGMA main.journal_mode=TRUNCATE;" // ^^^ note that WAL is not possible on a TEMP db // and OFF leads to undefined behaviour if // ROLLBACK is used! ); if(rc) goto end; sqlite3_create_function(dbh, "now", 0, SQLITE_ANY, 0, fsl_db_now_udf, 0, 0); sqlite3_create_function(dbh, "fsl_ci_mtime", 2, SQLITE_ANY | SQLITE_DETERMINISTIC, f, fsl_db_checkin_mtime_udf, 0, 0); sqlite3_create_function(dbh, "fsl_user", 0, SQLITE_ANY | SQLITE_DETERMINISTIC, f, fsl_db_user_udf, 0, 0); sqlite3_create_function(dbh, "fsl_print", -1, SQLITE_UTF8 /* not strictly SQLITE_DETERMINISTIC because it produces output */, f, fsl_db_sql_print,0,0); sqlite3_create_function(dbh, "fsl_content", 1, SQLITE_ANY | SQLITE_DETERMINISTIC, f, fsl_db_content_udf, 0, 0); sqlite3_create_function(dbh, "fsl_sym2rid", 1, SQLITE_ANY | SQLITE_DETERMINISTIC, f, fsl_db_sym2rid_udf, 0, 0); sqlite3_create_function(dbh, "fsl_dirpart", 1, SQLITE_UTF8 | SQLITE_DETERMINISTIC, NULL, fsl_db_dirpart_udf, 0, 0); sqlite3_create_function(dbh, "fsl_dirpart", 2, SQLITE_UTF8 | SQLITE_DETERMINISTIC, NULL, fsl_db_dirpart_udf, 0, 0); sqlite3_create_function(dbh, "fsl_j2u", 1, SQLITE_ANY | SQLITE_DETERMINISTIC, NULL, fsl_db_j2u_udf, 0, 0); /* fsl_i[sf]_selected() both require access to the f's list of files being considered for commit. */ sqlite3_create_function(dbh, "fsl_is_enqueued", 1, SQLITE_UTF8, f, fsl_db_selected_for_checkin_udf,0,0 ); sqlite3_create_function(dbh, "fsl_if_enqueued", 3, SQLITE_UTF8, f, fsl_db_selected_for_checkin_udf,0,0 ); sqlite3_create_function(dbh, "fsl_ckout_dir", -1, SQLITE_UTF8 | SQLITE_DETERMINISTIC, f, fsl_db_cx_chkout_dir_udf,0,0 ); sqlite3_create_function(dbh, "fsl_match_vfile_or_dir", 2, SQLITE_UTF8 | SQLITE_DETERMINISTIC, f, fsl_db_match_vfile_or_dir,0,0 ); sqlite3_create_function(dbh, "fsl_glob", 2, SQLITE_UTF8 | SQLITE_DETERMINISTIC, /* noting that ^^^^^ it's only deterministic for a given statement execution IF no SQL triggers an effect which forces the globs to reload. That "shouldn't ever happen." */ f, fsl_db_cx_glob_udf, 0, 0 ); #if 0 /* functions registered in v1 by db.c:db_open(). */ /* porting cgi() requires access to the HTTP/CGI layer. i.e. this belongs downstream. */ sqlite3_create_function(dbh, "cgi", 1, SQLITE_ANY, 0, db_sql_cgi, 0, 0); sqlite3_create_function(dbh, "cgi", 2, SQLITE_ANY, 0, db_sql_cgi, 0, 0); re_add_sql_func(db) /* Requires the regex bits. */; #endif end: return rc; } #undef MARKER |
︙ | |||
38642 38643 38644 38645 38646 38647 38648 | 41396 41397 41398 41399 41400 41401 41402 41403 41404 41405 41406 41407 41408 41409 41410 41411 | - + - + | p[-1] = '/'; } } } return zPath; #elif defined(__APPLE__) && !defined(WITHOUT_ICONV) return fsl_strdup(zUtf8) |
︙ | |||
38692 38693 38694 38695 38696 38697 38698 | 41446 41447 41448 41449 41450 41451 41452 41453 41454 41455 41456 41457 41458 41459 41460 41461 | - - + + | default: break; } } return rc; } } |
︙ | |||
38890 38891 38892 38893 38894 38895 38896 | 41644 41645 41646 41647 41648 41649 41650 41651 41652 41653 41654 41655 41656 41657 41658 41659 41660 41661 41662 41663 41664 41665 41666 41667 41668 41669 41670 41671 41672 41673 41674 41675 41676 41677 41678 41679 41680 41681 41682 41683 41684 41685 41686 41687 41688 41689 41690 41691 | - - + - + - + | } int fsl_vfile_changes_scan(fsl_cx * const f, fsl_id_t vid, unsigned cksigFlags){ fsl_stmt * stUpdate = NULL; fsl_stmt q = fsl_stmt_empty; int rc = 0; |
︙ | |||
39085 39086 39087 39088 39089 39090 39091 | 41838 41839 41840 41841 41842 41843 41844 41845 41846 41847 41848 41849 41850 41851 41852 41853 41854 41855 41856 41857 41858 41859 41860 41861 41862 41863 41864 41865 41866 41867 41868 41869 41870 41871 41872 41873 41874 41875 41876 41877 41878 41879 41880 41881 41882 41883 41884 41885 41886 41887 41888 | - + - - - - - - - + + - + + + - - - + - + - - - | }else if( origPerm==FSL_FILE_PERM_LINK ){ changed = FSL_VFILE_CHANGE_NOT_SYMLINK; } } #endif if( currentMtime!=oldMtime || changed!=oldChanged ){ if(!stUpdate){ |
︙ | |||
39277 39278 39279 39280 39281 39282 39283 | 42022 42023 42024 42025 42026 42027 42028 42029 42030 42031 42032 42033 42034 42035 42036 42037 | - - + + | end: fsl_buffer_clear(&content); fsl_stmt_finalize(&q); return rc; } #undef MARKER |
︙ | |||
39483 39484 39485 39486 39487 39488 39489 | 42228 42229 42230 42231 42232 42233 42234 42235 42236 42237 42238 42239 42240 42241 42242 42243 42244 | - - + + + | fsl_stmt_finalize(&s); fsl_vpath_clear(path); return rc; } /** Creates, if needed, the [ancestor] table, else clears its |
︙ | |||
39721 39722 39723 39724 39725 39726 39727 | 42467 42468 42469 42470 42471 42472 42473 42474 42475 42476 42477 42478 42479 42480 42481 42482 | - - + + | dberr: assert(rc); rc = fsl_cx_uplift_db_error2(f, db, rc); goto end; } #undef MARKER |
︙ | |||
39748 39749 39750 39751 39752 39753 39754 | 42494 42495 42496 42497 42498 42499 42500 42501 42502 42503 42504 42505 42506 42507 42508 42509 42510 42511 42512 42513 42514 42515 42516 42517 42518 42519 42520 42521 42522 42523 42524 42525 42526 42527 42528 42529 42530 42531 42532 42533 42534 42535 42536 42537 42538 42539 42540 42541 42542 42543 42544 42545 42546 42547 42548 42549 42550 42551 42552 42553 42554 42555 42556 42557 42558 42559 42560 42561 42562 42563 42564 42565 42566 42567 42568 42569 42570 42571 42572 42573 42574 42575 42576 42577 42578 42579 42580 42581 42582 42583 42584 42585 42586 42587 42588 42589 42590 42591 42592 42593 42594 42595 42596 42597 42598 42599 42600 42601 42602 42603 42604 | - + - + + + - + - + - + - - - + + - - + + - + - - + + + + - - - + - - - - - - - - - - - - - + + + + + + + + + + + + + - + | #include <stdio.h> #define MARKER(pfexp) \ do{ printf("MARKER: %s:%d:%s():\t",__FILE__,__LINE__,__func__); \ printf pfexp; \ } while(0) |
︙ | |||
39919 39920 39921 39922 39923 39924 39925 | 42666 42667 42668 42669 42670 42671 42672 42673 42674 42675 42676 42677 42678 42679 42680 42681 | - - + + | end: fsl_deck_finalize(&d); return rc; } } #undef MARKER |
︙ | |||
40392 40393 40394 40395 40396 40397 40398 | 43139 43140 43141 43142 43143 43144 43145 43146 43147 43148 43149 43150 43151 43152 43153 | - + | } } } return rc; } |
︙ | |||
40441 40442 40443 40444 40445 40446 40447 | 43188 43189 43190 43191 43192 43193 43194 43195 43196 43197 43198 43199 43200 43201 43202 | - + | } /** Always write the manifest files to the zip, regardless of the repo-level settings. This decision is up for debate. */ if(rc) goto end; else { |
︙ | |||
40478 40479 40480 40481 40482 40483 40484 | 43225 43226 43227 43228 43229 43230 43231 43232 43233 43234 43235 43236 43237 43238 43239 43240 43241 43242 43243 43244 43245 43246 43247 43248 43249 43250 43251 43252 43253 43254 43255 43256 43257 43258 43259 43260 43261 43262 43263 43264 43265 43266 43267 43268 43269 43270 43271 43272 43273 43274 43275 43276 43277 43278 43279 43280 43281 43282 43283 43284 43285 43286 43287 43288 43289 43290 43291 43292 43293 43294 43295 43296 43297 43298 43299 43300 43301 43302 43303 43304 43305 43306 43307 43308 43309 43310 43311 43312 43313 43314 43315 43316 43317 43318 43319 43320 43321 43322 43323 43324 43325 43326 43327 43328 43329 43330 43331 43332 43333 43334 43335 43336 43337 43338 43339 43340 43341 43342 43343 43344 43345 43346 43347 43348 43349 43350 43351 43352 43353 43354 43355 43356 43357 43358 43359 43360 43361 43362 43363 43364 43365 43366 43367 43368 43369 43370 43371 43372 43373 43374 43375 43376 43377 43378 43379 43380 43381 43382 43383 43384 43385 43386 43387 43388 43389 43390 43391 43392 43393 43394 43395 43396 43397 43398 43399 43400 43401 43402 43403 43404 43405 43406 43407 43408 43409 43410 43411 43412 43413 43414 43415 43416 43417 43418 43419 43420 43421 43422 43423 43424 43425 43426 43427 43428 43429 43430 43431 43432 43433 43434 43435 43436 43437 43438 43439 43440 43441 43442 43443 43444 43445 43446 43447 43448 43449 43450 43451 43452 43453 43454 43455 43456 43457 43458 43459 43460 43461 43462 43463 43464 43465 43466 43467 43468 43469 43470 43471 43472 43473 43474 43475 43476 43477 43478 43479 43480 43481 43482 43483 43484 43485 43486 43487 43488 43489 43490 43491 43492 43493 43494 43495 43496 43497 43498 43499 43500 43501 43502 43503 43504 43505 43506 43507 43508 43509 43510 43511 43512 43513 43514 43515 43516 43517 43518 43519 43520 43521 43522 43523 43524 43525 43526 43527 43528 43529 43530 43531 43532 43533 43534 43535 43536 43537 43538 43539 43540 43541 43542 43543 43544 43545 43546 43547 43548 43549 43550 43551 43552 43553 43554 43555 43556 43557 43558 43559 43560 43561 43562 43563 43564 43565 43566 43567 43568 43569 43570 43571 43572 43573 43574 43575 43576 43577 43578 43579 43580 43581 43582 43583 43584 43585 43586 43587 43588 43589 43590 43591 43592 43593 43594 43595 43596 43597 43598 43599 43600 43601 43602 43603 43604 43605 43606 43607 43608 43609 43610 43611 43612 43613 43614 43615 43616 43617 43618 43619 43620 43621 43622 43623 43624 43625 43626 43627 43628 43629 43630 43631 43632 43633 43634 43635 43636 43637 43638 43639 43640 43641 43642 43643 43644 43645 43646 43647 43648 43649 43650 43651 43652 43653 43654 43655 43656 43657 43658 43659 43660 43661 43662 43663 43664 43665 43666 43667 43668 43669 43670 43671 43672 43673 43674 43675 43676 43677 43678 43679 43680 43681 43682 43683 43684 43685 43686 43687 43688 43689 43690 43691 43692 43693 43694 43695 43696 43697 43698 43699 43700 43701 43702 43703 43704 43705 43706 43707 43708 43709 43710 43711 43712 43713 43714 43715 43716 43717 43718 43719 43720 43721 43722 43723 43724 43725 43726 43727 43728 43729 43730 43731 43732 43733 43734 43735 43736 43737 43738 43739 43740 43741 43742 43743 43744 43745 43746 43747 43748 43749 43750 43751 43752 43753 43754 43755 43756 43757 43758 43759 43760 43761 43762 43763 43764 43765 43766 43767 43768 43769 43770 43771 43772 43773 43774 43775 43776 43777 43778 43779 43780 43781 43782 43783 43784 43785 43786 43787 43788 43789 43790 43791 43792 43793 43794 43795 43796 43797 43798 43799 43800 43801 43802 43803 43804 43805 43806 43807 43808 43809 43810 43811 43812 43813 43814 43815 43816 43817 43818 43819 43820 43821 43822 43823 43824 43825 43826 43827 43828 43829 43830 43831 43832 43833 43834 43835 43836 43837 43838 43839 43840 43841 43842 43843 43844 43845 43846 43847 43848 43849 43850 43851 43852 43853 43854 43855 43856 43857 43858 43859 43860 43861 43862 43863 43864 43865 43866 43867 43868 43869 43870 43871 43872 43873 43874 43875 43876 43877 43878 43879 43880 43881 43882 43883 43884 43885 43886 43887 43888 43889 43890 43891 43892 43893 43894 43895 43896 43897 43898 43899 43900 43901 43902 43903 43904 43905 43906 43907 43908 43909 43910 43911 43912 43913 43914 43915 43916 43917 43918 43919 43920 43921 43922 43923 43924 43925 43926 43927 43928 43929 43930 43931 43932 43933 43934 43935 43936 43937 43938 43939 43940 43941 43942 43943 43944 43945 43946 43947 43948 43949 43950 43951 43952 43953 43954 43955 | - - + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - | fsl_deck_clean(&mf); return rc; } #undef MARKER |
︙ | |||
40518 40519 40520 40521 40522 40523 40524 | 43964 43965 43966 43967 43968 43969 43970 43971 43972 43973 43974 43975 43976 43977 43978 43979 43980 43981 43982 43983 43984 | - - - + + + - - + - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 105, 108, 101, 32, 116, 121, 112, 101, 46, 10, 45, 45, 32, 84, 104, 101, 32, 105, 110, 116, 101, 103, 101, 114, 32, 105, 115, 32, 116, 104, 101, 32, 115, 97, 109, 101, 32, 97, 115, 32, 39, 70, 83, 76, 71, 39, 46, 10, 80, 82, 65, 71, 77, 65, 32, 99, 102, 103, 46, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 95, 105, 100, 61, 50, 53, 50, 48, 48, 54, 54, 55, 53, 59, 10, 0}; char const * fsl_schema_config_cstr = fsl_schema_config_cstr_a; |
︙ | |||
40949 40950 40951 40952 40953 40954 40955 | 44261 44262 44263 44264 44265 44266 44267 44268 44269 44270 44271 44272 44273 44274 44275 44276 44277 44278 44279 44280 44281 | - - - + + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 32, 99, 111, 109, 109, 97, 110, 100, 32, 116, 111, 32, 105, 100, 101, 110, 116, 105, 102, 121, 32, 116, 104, 101, 10, 45, 45, 32, 100, 97, 116, 97, 98, 97, 115, 101, 32, 97, 115, 32, 97, 32, 102, 111, 115, 115, 105, 108, 32, 114, 101, 112, 111, 115, 105, 116, 111, 114, 121, 46, 10, 80, 82, 65, 71, 77, 65, 32, 114, 101, 112, 111, 46, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 95, 105, 100, 61, 50, 53, 50, 48, 48, 54, 54, 55, 51, 59, 10, 0}; char const * fsl_schema_repo1_cstr = fsl_schema_repo1_cstr_a; |
︙ | |||
41660 41661 41662 41663 41664 41665 41666 | 44757 44758 44759 44760 44761 44762 44763 44764 44765 44766 44767 44768 44769 44770 44771 44772 44773 44774 44775 44776 44777 | - - - + + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 105, 108, 100, 105, 100, 41, 10, 41, 32, 87, 73, 84, 72, 79, 85, 84, 32, 82, 79, 87, 73, 68, 59, 10, 67, 82, 69, 65, 84, 69, 32, 73, 78, 68, 69, 88, 32, 114, 101, 112, 111, 46, 99, 104, 101, 114, 114, 121, 112, 105, 99, 107, 95, 99, 105, 100, 32, 79, 78, 32, 99, 104, 101, 114, 114, 121, 112, 105, 99, 107, 40, 99, 104, 105, 108, 100, 105, 100, 41, 59, 10, 0}; char const * fsl_schema_repo2_cstr = fsl_schema_repo2_cstr_a; |
︙ | |||
41931 41932 41933 41934 41935 41936 41937 | 44951 44952 44953 44954 44955 44956 44957 44958 44959 44960 44961 44962 44963 44964 44965 44966 44967 44968 44969 44970 44971 | - - - + + + - - - + + - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 115, 32, 102, 105, 108, 101, 32, 116, 121, 112, 101, 46, 10, 45, 45, 32, 84, 104, 101, 32, 105, 110, 116, 101, 103, 101, 114, 32, 105, 115, 32, 116, 104, 101, 32, 115, 97, 109, 101, 32, 97, 115, 32, 39, 70, 83, 76, 67, 39, 46, 10, 80, 82, 65, 71, 77, 65, 32, 99, 107, 111, 117, 116, 46, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 95, 105, 100, 61, 50, 53, 50, 48, 48, 54, 54, 55, 52, 59, 10, 0}; char const * fsl_schema_ckout_cstr = fsl_schema_ckout_cstr_a; |
︙ | |||
42015 42016 42017 42018 42019 42020 42021 | 45003 45004 45005 45006 45007 45008 45009 45010 45011 45012 45013 45014 45015 45016 45017 45018 45019 45020 45021 45022 45023 | - - - + + + - - - + + - - - - - - - - - - - - - - - - - - - - - - + + - | 109, 101, 110, 116, 32, 84, 69, 88, 84, 10, 41, 59, 10, 67, 82, 69, 65, 84, 69, 32, 73, 78, 68, 69, 88, 32, 114, 101, 112, 111, 46, 116, 105, 99, 107, 101, 116, 99, 104, 110, 103, 95, 105, 100, 120, 49, 32, 79, 78, 32, 116, 105, 99, 107, 101, 116, 99, 104, 110, 103, 40, 116, 107, 116, 95, 105, 100, 44, 32, 116, 107, 116, 95, 109, 116, 105, 109, 101, 41, 59, 10, 0}; char const * fsl_schema_ticket_cstr = fsl_schema_ticket_cstr_a; |
︙ | |||
42081 42082 42083 42084 42085 42086 42087 | 45047 45048 45049 45050 45051 45052 45053 45054 45055 45056 45057 45058 45059 45060 45061 45062 45063 45064 45065 45066 45067 | - - - + + + - - - - + + + + - - - - - - - - - | 100, 97, 116, 101, 116, 105, 109, 101, 40, 116, 107, 116, 95, 109, 116, 105, 109, 101, 41, 32, 65, 83, 32, 39, 39, 109, 116, 105, 109, 101, 39, 39, 44, 10, 32, 32, 116, 121, 112, 101, 44, 10, 32, 32, 115, 116, 97, 116, 117, 115, 44, 10, 32, 32, 115, 117, 98, 115, 121, 115, 116, 101, 109, 44, 10, 32, 32, 116, 105, 116, 108, 101, 10, 70, 82, 79, 77, 32, 116, 105, 99, 107, 101, 116, 39, 41, 59, 10, 0}; char const * fsl_schema_ticket_reports_cstr = fsl_schema_ticket_reports_cstr_a; |
︙ | |||
42122 42123 42124 42125 42126 42127 42128 | 45079 45080 45081 45082 45083 45084 45085 45086 45087 | - - + + | 104, 101, 110, 32, 112, 111, 115, 116, 101, 100, 46, 32, 32, 74, 117, 108, 105, 97, 110, 32, 100, 97, 121, 10, 41, 59, 10, 67, 82, 69, 65, 84, 69, 32, 73, 78, 68, 69, 88, 32, 114, 101, 112, 111, 46, 102, 111, 114, 117, 109, 116, 104, 114, 101, 97, 100, 32, 79, 78, 32, 102, 111, 114, 117, 109, 112, 111, 115, 116, 40, 102, 114, 111, 111, 116, 44, 102, 109, 116, 105, 109, 101, 41, 59, 10, 0}; char const * fsl_schema_forum_cstr = fsl_schema_forum_cstr_a; |
Changes to lib/libfossil.h.
1 2 3 4 5 6 7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | + - + - | #if !defined(FSL_AMALGAMATION_BUILD) #define FSL_AMALGAMATION_BUILD 1 #endif #if defined(HAVE_CONFIG_H) # include "config.h" #endif #include "libfossil-config.h" #include "sqlite3.h" |
︙ | |||
246 247 248 249 250 251 252 | 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 | - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + | otherwise they do not. */ #define FSL_CONFIG_ENABLE_TIMER 1 #endif /* ORG_FOSSIL_SCM_FSL_CONFIG_H_INCLUDED */ |
︙ | |||
862 863 864 865 866 867 868 | 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 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 | - - + + + + + - + - + - + + + - - - + + + - - + + + + + - - + - - + - - - - - - - - - - - - - + + + + - - - - - + + + + + + + + + + + + + + + + + + + + - + + + + + + | initialize them properly leads to undefined behaviour. - ALWAYS fsl_buffer_clear() buffers when done with them. Remember that failed routines which output to buffers might partially populate the buffer, so be sure to clean up on error cases. |
︙ | |||
1161 1162 1163 1164 1165 1166 1167 | 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 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 1300 1301 1302 1303 1304 1305 1306 | - + + + + + + + + + + + + + + - - - - + + + + + - + + + - - + + + + + + + + + + + + + + + + + + - + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + - - + + + + + + + + + + + + + + - + | z need not be NUL terminated - this function does not read past the first invalid byte. Thus is can be used on, e.g., full ISO8601-format strings. If z is NULL, 0 is returned. */ FSL_EXPORT int fsl_str_is_date2(const char *z); |
︙ | |||
1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 | 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 | + + + + + - - - - - + - - + + - - + | int clearWhich ); /** Appends the first n bytes of src, plus a NUL byte, to b, expanding b as necessary and incrementing b->used by n. If n is less than 0 then the equivalent of fsl_strlen((char const*)src) is used to calculate the length. If b is an external buffer, it is first transformed into a managed buffer. Results are undefined if b or src are NULL. If n is 0 (or negative and !*src), this function ensures that b->mem is not NULL and is NUL-terminated, so it may allocate to have space for that NUL byte. |
︙ | |||
1346 1347 1348 1349 1350 1351 1352 | 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 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 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 | - - + + + + - + + + - + + + - + + + - + + - + - - - - - - - + + + + + + + + + - + - + - - - + + - + + + + + + + + + + + - + + + + - + + + + + - + + + - + + + + - - + + - + | */ FSL_EXPORT int fsl_buffer_compress2(fsl_buffer const *pIn1, fsl_buffer const *pIn2, fsl_buffer *pOut); /** Uncompress buffer pIn and store the result in pOut. It is ok for |
︙ | |||
1485 1486 1487 1488 1489 1490 1491 | 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 | - + | where the timing/duration of fsl_buffer_compare() (or an equivalent memcmp()) might inadvertently leak security-relevant information. Specifically, it address the concern that attackers can use timing differences to check for password misses, to narrow down an attack to passwords of a specific length or content properties. */ |
︙ | |||
1510 1511 1512 1513 1514 1515 1516 | 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 | - - - + + + - - - - + + + + | Return 0 on success. @see fsl_buffer_delta_apply() @see fsl_delta_apply() @see fsl_delta_apply2() */ |
︙ | |||
1631 1632 1633 1634 1635 1636 1637 | 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 | - + | /** Writes the given buffer to the given filename. Returns 0 on success, FSL_RC_MISUSE if !b or !fname, FSL_RC_IO if opening or writing fails. Uses fsl_fopen() to open the file, so it supports the name '-' as an alias for stdout. */ |
︙ | |||
1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 | 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 | + + + + + + + | */ FSL_EXPORT int fsl_strncmp(const char *zA, const char *zB, fsl_size_t nByte); /** BSD strlcpy() variant which is less error prone than strncpy. Copy up to dstsz - 1 characters from src to dst and NUL-terminate the resulting string if dstsz is not 0. Returns the length of the string it writes to dst. If it returns a value equal to or greater than its 3rd argument then the output was truncated. */ FSL_EXPORT fsl_size_t fsl_strlcpy(char *dst, const char *src, fsl_size_t dstsz); /** BSD strlcat() variant which is less error prone than strncat. Append src to the end of dst. Append at most dstsz - strlen(dst - 1) characters, and NUL-terminate unless dstsize is 0 or the passed in dst string was longer than dstsz to begin with. Returns the initial string-length of dest plus the length src. If it returns a value equal to or greater than its 3rd argument then the output was truncated. */ FSL_EXPORT fsl_size_t fsl_strlcat(char *dst, const char *src, fsl_size_t dstsz); /** Equivalent to fsl_strncmp(lhs, rhs, X), where X is either FSL_STRLEN_SHA1 or FSL_STRLEN_K256: if both lhs and rhs are longer than FSL_STRLEN_SHA1 then they are assumed to be |
︙ | |||
2045 2046 2047 2048 2049 2050 2051 | 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 | - + - + - + | int const rc = fsl_list_reserve( myList, n ); if( rc ) { ... error ... } ``` @see fsl_list_clear() @see fsl_list_visit_free() */ |
︙ | |||
2129 2130 2131 2132 2133 2134 2135 | 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 | - + + - + - + + - + | the client has no way (unless the finalizer somehow accounts for it) to know which entries in the list were cleaned up. Thus it is highly recommended that finalizer functions follow the conventional wisdom of "destructors do not throw." @see fsl_list_visit_free() */ |
︙ | |||
2245 2246 2247 2248 2249 2250 2251 | 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 | + - + - + | } assert(0 == fsl_strcmp( "/a/b/foo.bar, fsl_buffer_cstr(&buf))); fsl_buffer_clear(&buf); ``` */ FSL_EXPORT int fsl_file_canonical_name2(const char *zRoot, const char *zOrigName, fsl_buffer * const pOut, |
︙ | |||
2281 2282 2283 2284 2285 2286 2287 | 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 | - + | separator and leaveSlash is false then only a NUL terminator is appended to pOut if it is not already NUL-terminated. This function does no filesystem-level validation of the the given path - only string evaluation. */ FSL_EXPORT int fsl_file_dirpart(char const * zFilename, fsl_int_t nLen, |
︙ | |||
2372 2373 2374 2375 2376 2377 2378 | 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 | - + + | for directories, devices, fifos, symlinks, etc. The name may be absolute or relative to the current working dir. */ FSL_EXPORT bool fsl_is_file(const char *zFilename); /** Returns true if the given file is a symlink, else false. The name |
︙ | |||
2399 2400 2401 2402 2403 2404 2405 | 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 | - - - - + + + + + + + + + + + | Simplify a filename by: * converting all \ into / on windows and cygwin * removing any trailing and duplicate / * removing /./ * removing /A/../ |
︙ | |||
2447 2448 2449 2450 2451 2452 2453 | 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 | - + - + | "*.c *.h, *.sh, '*.in'" ``` @see fsl_glob_list_append() @see fsl_glob_list_matches() @see fsl_glob_list_clear() */ |
︙ | |||
2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 | 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | the more widespread OSes often have to be converted to something portable and this requires allocation on such platforms, but not on Unix. For API transparency, that means all platforms get the copy(-like) behaviour. */ FSL_EXPORT char *fsl_getenv(const char *zName); /** Collects a list of directories intended to use as temp dirs in the current environment. The returned array ends with a NULL element to mark its end. The memory's ownership is a bit awkward and therefore it must be eventually freed by passing it to fsl_temp_dirs_free(). No entries in the returned list contain a trailing slash unless the entry is itself a reference to a Unix-style root directory (which would be highly unusual). The list of directories varies by platform: Windows: - `GetTempPath()`, `$TEMP`, `$TMP`, "." Non-Windows: - `$TMPDIR`, "/var/tmp", "/usr/tmp", "/tmp", "/temp", "." (`$X` refers to the value of environment variable `X`.) Noting that only directories in those lists which actually exist (at the time this is called) are added to the list (also noting that "." always exists unless CWD is deleted while the app is active). If no suitable directories are found, an empty array (with a leading `NULL` element) is returned, but this would indicate that, e.g., even CWD does not exist (so the app has bigger problems). `NULL` is only returned if allocation of the containing array fails. Failure to allocate memory for a given directory name (as those require conversion on some platforms) is ignored and such entries are simply skipped over. @see fsl_temp_dirs_free() @see fsl_file_tempname() */ FSL_EXPORT char ** fsl_temp_dirs_get(void); /** If aDirs is not NULL then it is expected to be an array created by fsl_temp_dirs_get() and it frees the list's entries and the list itself. After calling this, the argument's memory is invalidated and any use of it leads to undefined results. This is a harmless no-op if the argument is NULL. @see fsl_temp_dirs_get() @see fsl_file_tempname() */ FSL_EXPORT void fsl_temp_dirs_free(char **aDirs); /** Creates a semi-random temp filename and populates the given buffer with it. The second argument is an optional string to prefix each filename with. If it is NULL then a library-wide default is used. If it is empty then no prefix is used. The final argument is expected to be NULL or a list of directories in the format constructed by fsl_temp_dirs_get(). If it is not NULL, this function uses the first entry in dirs which refers to an existing directory. If it is NULL then the buffer is filled with the new name with no directory prefix. Returns... - 0 on success, in which case tgt is populated with the new name. - FSL_RC_NOT_FOUND if dirs is empty or refers only to non-existent directories. - FSL_RC_OOM if allocating memory for the target buffer fails. - FSL_RC_RANGE if, after some hard-coded number of attempts, it is unable to construct a unique filename due to name collisions in the target directory. That "shouldn't ever happen." Sidebars: - This function does no translation or validation of the 2nd argument other than to check if it is NULL. It "should" be either a file base name, with no path component, or a relative path component for which the caller has already created the directory. e.g. use the base name of the application, e.g. "my-app". - This function does not actually write to the filesystem, it just constructs a name. There is hypothetically a window of opportunity for another file with the same name to be created before the caller has a chance to create the file, but the chances of that actually happening are close enough to zero to rule them out for all practical purposes. - The RNG is officially unspecified. (That said: sqlite3_randomness().) @see fsl_temp_dirs_get() @see fsl_temp_dirs_free() */ FSL_EXPORT int fsl_file_tempname(fsl_buffer * const tgt, char const *zPrefix, char * const * const dirs); /** Returns a positive value if zFilename is a directory, 0 if zFilename does not exist, or a negative value if zFilename exists but is something other than a directory. Results are undefined if zFilename is NULL. This function expects zFilename to be a well-formed path - |
︙ | |||
2690 2691 2692 2693 2694 2695 2696 | 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 | - + + - + - - - - + + + | Results are undefined if zFilename is NULL. Potential TODO: if it refers to a dir, forward the call to fsl_rmdir(). */ FSL_EXPORT int fsl_file_unlink(const char *zFilename); |
︙ | |||
2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 | 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 | + + + + + + + + + + + + + + + + + + + + + | returning 0. If the target is a directory or a symlink, this is a no-op and returns 0. */ FSL_EXPORT int fsl_file_exec_set(const char *zFilename, bool isExec); /** Returns true if the argument is fsl_stat()'able and has the executable bit set, else false. */ FSL_EXPORT bool fsl_file_isexec(const char *zFilename); /** Makes a bitwise copy of the file zFrom to file zTo, creating any directories needed for the target file's if they do not already exist. If the source file is executable then the target file will also be made so, but any failure to do so (e.g. because the target filesystem does not support it) is silently ignored. Returns 0 on success. On error it may return any number of result codes if opening a file fails, if a mkdir fails (see fsl_mkdir_for_file()), or if any I/O fails. Results are undefined if the source and target refer to the same file. */ FSL_EXPORT int fsl_file_copy(char const *zFrom, char const *zTo); /** Create the directory with the given name if it does not already exist. If forceFlag is true, delete any prior non-directory object with the same name. Return 0 on success, non-0 on error. |
︙ | |||
2794 2795 2796 2797 2798 2799 2800 | 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 | - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + | "/foo/bar" creates (if needed) /foo, but assumes "bar" is a file component. "/foo/bar/" creates /foo/bar. However "foo" will not create a directory - because the string has no path component, it is assumed to be a filename. Both "/foo/bar/my.doc" and "/foo/bar/" result in the directories |
︙ | |||
2948 2949 2950 2951 2952 2953 2954 | 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 | - + | #define fsl_fstat_empty_m {FSL_FSTAT_TYPE_UNKNOWN,0,0,-1,0} /** Empty-initialized fsl_fstat instance, intended for non-const copy construction. */ FSL_EXPORT const fsl_fstat fsl_fstat_empty; /** |
︙ | |||
2971 2972 2973 2974 2975 2976 2977 | 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 | - + | to differentiate between symlinks and files. The fsl_fstat_type_e family of flags can be used to determine the type of the filesystem object being stat()'d (file, directory, or symlink). It does not apply any special logic for platform-specific oddities other than symlinks (e.g. character devices and such). */ |
︙ | |||
3066 3067 3068 3069 3070 3071 3072 | 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 3410 3411 3412 | - + - + - - - + + + - + + - - - + + + | number of times to emit delta output. Each time it is called it should append the new bytes to its output channel. The semantics of the return value and the first four arguments are identical to fsl_delta_create(), with these ammendments regarding the return value: |
︙ | |||
3218 3219 3220 3221 3222 3223 3224 | 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 | - + | */ FSL_EXPORT void fsl_bytes_defossilize( unsigned char * inp, fsl_size_t * resultLen ); /** Defossilizes the contents of b. Equivalent to: fsl_bytes_defossilize( b->mem, &b->used ); */ |
︙ | |||
3342 3343 3344 3345 3346 3347 3348 | 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + + + + + + + + + + + + + + + + | untransformed characters and the strlen of *xlate for others. Bytes returned via xlate are static and immutable. Results are undefined if xlate is NULL. */ FSL_EXPORT fsl_size_t fsl_htmlize_xlate(int c, char const ** xlate); |
︙ | |||
3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 | 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 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 3804 3805 | + + + + - + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + | FSL_RC_RANGE. */ FSL_DIFF2_NOTTOOBIG = 0x0800, /** Strip trailing CR before diffing. Applies to all diff builders. */ FSL_DIFF2_STRIP_EOLCR = 0x1000, /* ACHTUNG: do not use 0x2000 because it would semantically collide with FSL_DIFF_ANSI_COLOR. */ /** More precise but slower side-by-side diff algorithm, for diffs which use that. */ |
︙ | |||
3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 | 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 | + + + + + - - + | may be NULL. */ const char * hashRHS; /** Output destination. Any given builder might, depending on how it actually constructs the diff, buffer output and delay calling this until its finish() method is called. Note that not all diff builders use this. e.g. a diff builder which outputs to an ncurses widget cannot do so via this method and instead has to use the drawing methods of that API. Thus is is legal for this method to be NULL for some builders. */ fsl_output_f out; /** State for this->out(). Ownership is unspecified by this interface: it is for use by this->out() but what is supposed to happen to it after this object is done with it depends on higher-level code. */ void * outState; |
︙ | |||
3647 3648 3649 3650 3651 3652 3653 | 3885 3886 3887 3888 3889 3890 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 3916 3917 3918 3919 | - + - + - + - + - + - + | were the ANSI code to reset all color attributes. */ char const * reset; } ansiColor; }; /** Convenience typedef. */ |
︙ | |||
3715 3716 3717 3718 3719 3720 3721 | 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 | - + | */ #define fsl_dline_change_max_spans 8 /** This "mostly-internal" type describes zero or more (up to fsl_dline_change_max_spans) areas of difference between two lines of text. This type is only in the public API for use with concrete |
︙ | |||
3763 3764 3765 3766 3767 3768 3769 | 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 | - + | Given two lines of a diff, this routine computes a set of changes between those lines for display purposes and writes a description of those changes into the 3rd argument. After returning, p->n contains the number of elements in p->a which were populated by this routine. This function is only in the public API for use with |
︙ | |||
3819 3820 3821 3822 3823 3824 3825 | 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 | - + - + + - - - - - - - - - - - - + - + + + + + + + - - - - - - + + + + + + + + - + | - FSL_RC_OOM on allocation error. */ FSL_EXPORT int fsl_break_into_dlines(const char *z, fsl_int_t n, uint32_t *pnLine, fsl_dline **pOut, uint64_t diff2Flags); /** Convenience typedef. */ |
︙ | |||
3906 3907 3908 3909 3910 3911 3912 | 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 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 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 | - + - + - + - + - + - + - + + + + + + + - + + + + + + + + + + + + + + - - - - - + - - - + - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - + - - + + + - + - + - + - + + + + + - + - + | those two chunks together. That "readability optimization" is skipped when this method is set because this method may otherwise report that lines are being skipped which then subsequently get output by the driver. Must return 0 on success, non-0 on error. */ |
︙ | |||
4117 4118 4119 4120 4121 4122 4123 | 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 | - + - + - + - + - + - + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + | ``` The SUBARRAY is an array of 3*N+1 strings with N>=0. The triples represent common-text, left-text, and right-text. The last string in SUBARRAY is the common-suffix. Any string can be empty if it does not apply. */ |
︙ | |||
4197 4198 4199 4200 4201 4202 4203 | 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 | - + - + - + + + - + - | - FSL_RC_DIFF_BINARY if the to-diff content appears to be binary, noting that "appears to be" is heuristric-driven and subject to false positives. Specifically, files with extremely long lines will be recognized as binary (and are, in any case, generally less than useful for most graphical diff purposes). |
︙ | |||
5035 5036 5037 5038 5039 5040 5041 | 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 | - + - - - - + + + + + - + - | FSL_EXPORT fsl_size_t fsl_simplify_sql( char * sql, fsl_int_t len ); /** Convenience form of fsl_simplify_sql() which assumes b holds an SQL string. It gets processed by fsl_simplify_sql() and its 'used' length potentially gets adjusted to match the adjusted SQL string. */ |
︙ | |||
5198 5199 5200 5201 5202 5203 5204 | 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 | - + + + + + + + + + + + | If merge conflicts are encountered, it continues as best as it can and injects "indiscrete" markers in the output to denote the nature of each conflict. If conflictCount is not NULL then on success the number of merge conflicts is written to *conflictCount. Returns 0 on success, FSL_RC_OOM on OOM, FSL_RC_TYPE if any input |
︙ | |||
5520 5521 5522 5523 5524 5525 5526 | 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 | - - - + + + + + + + + + | typedef struct fsl_dircrawl_state fsl_dircrawl_state; /** Callback type for use with fsl_dircrawl(). It gets passed the absolute name of the target directory, the name of the directory entry (no path part), the type of the entry, and the client state pointer which is passed to that routine. It must return 0 on |
︙ | |||
5562 5563 5564 5565 5566 5567 5568 | 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 | - + - - + + + | but libfossil does not.) It silently skips any files for which stat() fails or is not of a "basic" file type (e.g. character devices and such). Returns 0 on success, FSL_RC_TYPE if the given name is not a directory, and FSL_RC_RANGE if it recurses "too deep," (some |
︙ | |||
5629 5630 5631 5632 5633 5634 5635 | 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 | - + | FSL_LOOKSLIKE_BINARY = FSL_LOOKSLIKE_NUL | FSL_LOOKSLIKE_LONG | FSL_LOOKSLIKE_SHORT, /* Line separators. */ FSL_LOOKSLIKE_EOL = (FSL_LOOKSLIKE_LONE_CR | FSL_LOOKSLIKE_LONE_LF | FSL_LOOKSLIKE_CRLF) }; /** Returns true if b appears to contain "binary" (non-UTF8/16) content, |
︙ | |||
5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 | 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 | + + + + + + + + | Returns true if b starts with a UTF8 BOM. If the 2nd argument is not NULL, *pBomSize is set to the number of bytes in the BOM (always 3), regardless of whether or not the function returns true or false. */ FSL_EXPORT bool fsl_starts_with_bom_utf8(fsl_buffer const * const b, unsigned int *pBomSize); /** Populates the first n bytes of tgt with random bytes. Note that n must be 31 bits or less (2GB). The exact source of randomness is not guaranteed by the API, but the implementation currently uses sqlite3_randomness(). */ FSL_EXPORT void fsl_randomness(unsigned int n, void *tgt); #if 0 /** The UTF16 counterpart of fsl_looks_like_utf8(), with the addition that the 2nd argument, if true, specifies that the 2nd argument is true then the contents of the buffer are byte-swapped for checking purposes. This is not validate that the blob is valid UTF16. It assumes that all |
︙ | |||
5732 5733 5734 5735 5736 5737 5738 | 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 | - - + + - + | /* ^^^^ UTF-16 interfaces */ #if defined(__cplusplus) } /*extern "C"*/ #endif #endif /* ORG_FOSSIL_SCM_FSL_UTIL_H_INCLUDED */ |
︙ | |||
5852 5853 5854 5855 5856 5857 5858 | 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 | - + - | fsl_cx_db_repo() and fsl_cx_db_ckout() will always return the same database handle, but they can tell whether a given role has been attached or not and will fail in their documented ways when the role's corresponding database has not yet been attached. e.g. `fsl_cx_db_repo()` will return `NULL` if a repo database is not attached. |
︙ | |||
5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 | 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 | + + + + | FSL_CX_F_CALC_R_CARD = 0x01, /** When encounting artifact types in the crosslinking phase which the library does not currently support crosslinking for, skip over them instead of generating an error. For day-to-day use this is, perhaps counter-intuitively, generally desirable. As of 2021-12-04, crosslinking of all core fossil artifact types is supported, so this flag is effectively a no-op until/unless a new artifact type is added to fossil. */ FSL_CX_F_SKIP_UNKNOWN_CROSSLINKS = 0x02, /** By default, fsl_reserved_fn_check() will fail if the given filename is reserved on Windows platforms because such filenames cannot be checked out on Windows. This flag removes that limitation. It |
︙ | |||
6263 6264 6265 6266 6267 6268 6269 | 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 | - + | Special case of FSL_RC_TYPE triggered in some diff APIs, indicating that the API cannot diff what appears to be binary data. */ FSL_RC_DIFF_BINARY, /** Triggered by some diff APIs to indicate that only whitespace changes we found and the diff was requested to ignore whitespace. |
︙ | |||
6318 6319 6320 6321 6322 6323 6324 | 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 | - - + + - - + + + + | /** Returns the value of FSL_LIBRARY_VERSION used to compile the library. If this value differs from the value the caller was compiled with, Chaos might ensue. The API does not yet have any mechanism for determining |
︙ | |||
6364 6365 6366 6367 6368 6369 6370 | 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 | - + + + | /** A part of the configuration used by fsl_cx_init() and friends. */ struct fsl_cx_config { /** If true, all SQL which goes through the fossil engine |
︙ | |||
6553 6554 6555 6556 6557 6558 6559 | 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 | - + - - | of the parameters and return value. */ FSL_EXPORT int fsl_cx_err_get( fsl_cx * const f, char const ** str, fsl_size_t * len ); /** Returns f's error state object. This pointer is guaranteed by the API to be stable until f is finalized, but its contents are |
︙ | |||
6676 6677 6678 6679 6680 6681 6682 | 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | FSL_EXPORT int fsl_outputf( fsl_cx * const f, char const * fmt, ... ); /** va_list counterpart to fsl_outputf(). */ FSL_EXPORT int fsl_outputfv( fsl_cx * const f, char const * fmt, va_list args ); |
︙ | |||
6779 6780 6781 6782 6783 6784 6785 | 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 | - - - - - + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + | be invalidated by any future calls to fsl_cx_user_set(). @see fsl_cx_user_guess() */ FSL_EXPORT char const * fsl_cx_user_get( fsl_cx const * const f ); /** |
︙ | |||
7106 7107 7108 7109 7110 7111 7112 | 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | Note that the role of FSL_DBROLE_TEMP is invalid here. */ FSL_EXPORT char const * fsl_cx_db_file_for_role(fsl_cx const * f, fsl_dbrole_e r, fsl_size_t * len); |
︙ | |||
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 | - - + + + + + + - - - - + + + + + | */ FSL_EXPORT char const * fsl_cx_ckout_dir_name(fsl_cx const * f, fsl_size_t * len); /** Returns a handle to f's main db (which may or may not have any relationship to the repo/checkout/config databases - that's |
︙ | |||
7241 7242 7243 7244 7245 7246 7247 | 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 | - + - - - - - - - - - - - - + + + + + + + + + - - - - + + + + + + + - - + + + + + | /** Opens the given database file as f's configuration database. If f already has a config database opened then: 1) If passed a NULL dbName or dbName is an empty string then this |
︙ | |||
7417 7418 7419 7420 7421 7422 7423 | 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 | - + - - - - + + + + + + + + - + - - + + + + + - + | Returns 0 on success. On stat() error, nameOut is not updated, but after stat()'ing, allocation of memory for nameOut's buffer may fail. If zName ends with a trailing slash, that slash is retained in nameOut. |
︙ | |||
7649 7650 7651 7652 7653 7654 7655 | 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 | - + | - "ignore-glob" = FSL_GLOBS_IGNORE - "binary-glob" = FSL_GLOBS_BINARY - "crnl-glob" = FSL_GLOBS_CRNL - Anything else = FSL_GLOBS_INVALID To simplify this function's use via an SQL-accessible UDF, the `*-glob` names may be passed in without their `-glob` suffix, |
︙ | |||
7736 7737 7738 7739 7740 7741 7742 | 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 | - + | const char * zFilename, fsl_buffer * pOut); /** Works like fsl_getcwd() but updates f's error state on error and appends the current directory's name to the given buffer. Returns 0 on success. */ |
︙ | |||
7885 7886 7887 7888 7889 7890 7891 | 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 | - + + + + + + + + + + + + + + + + + + + + | The va_list counterpart of fsl_cx_interrupt(). */ FSL_EXPORT int fsl_cx_interruptv(fsl_cx * const f, int code, char const * fmt, va_list args); /** If f's is-interrupted flag is set, this function returns its value. Note that there is inherently a race condition when calling |
︙ | |||
7929 7930 7931 7932 7933 7934 7935 | 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 | - - - - + + + | */ FSL_EXPORT time_t fsl_cx_time_adj(fsl_cx const * f, time_t clock); #endif #if defined(__cplusplus) } /*extern "C"*/ #endif |
︙ | |||
7958 7959 7960 7961 7962 7963 7964 | 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 | - | */ /* We don't _really_ want to include sqlite3.h at this point, but if we do not then we have to typedef the sqlite3 struct here and that breaks when client code includes both this file and sqlite3.h. */ |
︙ | |||
7983 7984 7985 7986 7987 7988 7989 | 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 | - + | #define fsl_commit_hook_empty_m {NULL,0,NULL} typedef struct fsl_commit_hook fsl_commit_hook; /* extern const fsl_commit_hook fsl_commit_hook_empty; */ /** Potential TODO. */ |
︙ | |||
8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 | 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 | + + + + + + + + + + + + + - - + + + - + | in read-write mode, but should not create the db if it does not already exist. */ FSL_OPEN_F_RW = 0x02, /** Flag for fsl_db_open() specifying that the db should be opened in read-write mode, creating the db if it does not already exist. ACHTUNG: this flag propagates from an OPEN'd db handle to the ATTACH SQL command run via that handle, such that ATTACHing a non-existing db file will fail if the FSL_OPEN_F_CREATE flag is _not_ used. Historically (prior to 2022-01-01), fsl_db_open() would automatically apply this flag to DBs named ":memory:" or "" (unnamed temp dbs), but that ended up causing a full day of confusion, hair-pulling, and bug-hunting when lib-level code was migrated from an anonymous temp db to a "real" db and ATTACH suddenly failed. As of 2022-01-01, fsl_db_open() always takes the open-mode flags as provided by the client, regardless of the DB name, and never automatically rewrites them to include FSL_OPEN_F_CREATE. */ FSL_OPEN_F_CREATE = 0x04, /** Shorthand for RW+CREATE flags. */ FSL_OPEN_F_RWC = FSL_OPEN_F_RW | FSL_OPEN_F_CREATE, /** |
︙ | |||
8437 8438 8439 8440 8441 8442 8443 | 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 | - - + + - | Returns NULL on allocation error. */ FSL_EXPORT fsl_stmt * fsl_stmt_malloc(); /** |
︙ | |||
8653 8654 8655 8656 8657 8658 8659 | 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 | - - - - + + + + + + + - - + + + + + | copying fsl_stmt_empty so that this function knows whether or not to fsl_free() them). Returns FSL_RC_MISUSE if !stmt or it has already been finalized (but was not freed). */ FSL_EXPORT int fsl_stmt_finalize( fsl_stmt * const stmt ); /** |
︙ | |||
8739 8740 8741 8742 8743 8744 8745 | 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 | - + - - - - - + + + + + | /** Equivalent to fsl_stmt_reset2(stmt, 0). */ FSL_EXPORT int fsl_stmt_reset( fsl_stmt * const stmt ); /** Returns the db handle which prepared the given statement, or |
︙ | |||
8775 8776 8777 8778 8779 8780 8781 | 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 | - - - + + + + | */ FSL_EXPORT char const * fsl_stmt_col_name(fsl_stmt * const stmt, int index); /** Returns the result column count for the given statement, or -1 if !stmt or it has not been prepared. Note that this value is cached when the statement is created. Note that non-fetching queries |
︙ | |||
8976 8977 8978 8979 8980 8981 8982 | 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 | - - + + + + - - + + + + - - - + + + + + + | Gets a string value from the given 0-based result set column, assigns *out (if out is not NULL) to that value, assigns *outLen (if outLen is not NULL) to *out's length in bytes, and returns 0 on success. Ownership of the string memory is unchanged - it is owned by the statement and the caller should immediately copy it if it will be needed for much longer. |
︙ | |||
9066 9067 9068 9069 9070 9071 9072 | 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 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 | - - - - - - - + + + + + + + + + + + - - - + + + - + - - - - + + + + + + + + + + + + + + + + + | /** Equivalent to fsl_db_transaction_end(db, 1). */ FSL_EXPORT int fsl_db_transaction_rollback(fsl_db * const db); /** |
︙ | |||
9164 9165 9166 9167 9168 9169 9170 | 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 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 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 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 | - + - + - + - + - + - + - + - + - - + + + - + - + - + - + - + - + - + - + - + - + - - - + + + - - - + + + - + - + - + | int32_t defaultValue, char const * sql, ... ); /** The int64 counterpart of fsl_db_get_int32(). See that function for the semantics. */ |
︙ | |||
9392 9393 9394 9395 9396 9397 9398 | 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 | - + - + | bool localTime ); /** Returns the current time in Julian Date format. Returns a negative value if !db or db is not opened. */ |
︙ | |||
9461 9462 9463 9464 9465 9466 9467 | 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 | - - + - - - + - - + - + | - If FSL_OPEN_F_SCHEMA_VALIDATE is set in openFlags then the db is validated to see if it has a fossil schema. If that validation fails, FSL_RC_REPO_NEEDS_REBUILD or FSL_RC_NOT_A_REPO will be returned and db's error state will be updated. db->f does not need to be set for that check to work. |
︙ | |||
9504 9505 9506 9507 9508 9509 9510 | 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 | - + + + + + + + + + + | given code block is getting run. As a special case, if db->f is not NULL _before_ it is is fsl_db_open()ed, then this function automatically gets installed if the SQL tracing option is enabled for that fsl_cx instance before the db is opened. |
︙ | |||
9536 9537 9538 9539 9540 9541 9542 | 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 | - - + + - + - | */ FSL_EXPORT char const * fsl_db_name(fsl_db const * const db); /** Returns a db name string for the given fsl_db_role value. The string is static, guaranteed to live as long as the app. It |
︙ | |||
9588 9589 9590 9591 9592 9593 9594 | 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 | - + | FSL_EXPORT int fsl_db_detach(fsl_db * const db, const char *zLabel); /** Expects fmt to be a SELECT-style query. For each row in the query, the first column is fetched as a string and appended to the tgt list. |
︙ | |||
9624 9625 9626 9627 9628 9629 9630 | 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 | - + - + - + - + - - - + + + - - + - | fsl_list_visit_free(&li, 1); ``` Of course fsl_list_visit() may be used to traverse the list as well, as long as the visitor expects (char [const]*) list elements. */ |
︙ | |||
9785 9786 9787 9788 9789 9790 9791 | 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 | - - + + | FSL_EXPORT int fsl_stmt_bind_step( fsl_stmt * st, char const * fmt, ... ); #if defined(__cplusplus) } /*extern "C"*/ #endif #endif /* ORG_FOSSIL_SCM_FSL_DB_H_INCLUDED */ |
︙ | |||
10327 10328 10329 10330 10331 10332 10333 | 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 | - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | FSL_EXPORT const char * fsl_hash_type_name(fsl_hash_types_e h, const char *zUnknown); #if defined(__cplusplus) } /*extern "C"*/ #endif #endif /* ORG_FOSSIL_SCM_FSL_HASH_H_INCLUDED */ |
︙ | |||
10497 10498 10499 10500 10501 10502 10503 | 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 | - + | These lists, and F-cards in generally, are typically maintained internally in the library. There's probably "no good reason" for clients to manipulate them. */ struct fsl_card_F_list { /** The list of F-cards. The first this->used elements are in-use. |
︙ | |||
11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 | 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 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 | + + + + + + + + + + - - + + - + - - + - + - + + + + - - - + + + + - + + + + + + + - + | Returns 0 on success, else an error code propagated by fsl_deck_F_set(), fsl_repo_blob_lookup(), or some other lower-level routine. This routine requires that a transaction is active and returns FSL_RC_MISUSE if none is active. For any non-trivial error's, d->f's error state will be updated with a description of the problem. Returns FSL_RC_MISUSE if `d->rid>0` (which indicates that the deck has already been saved in the repository). fsl_deck_derive() can be used to "extend" a saved deck into a new version before using this API. Returns FSL_RC_RANGE if zName is not a valid filename for use as a repository entry, as per fsl_is_simple_pathname(). On error, d->f's error state will be updated with a description of the problem. TODO: add a fsl_cx-level or fsl_deck-level API for marking content saved this way as private. This type of content is intended for use cases which do not have a checkout, and thus cannot be processed with fsl_checkin_commit() (which includes a flag to mark its content as private). @see fsl_deck_F_set() @see fsl_deck_F_add() @see fsl_deck_derive() */ |
︙ | |||
11160 11161 11162 11163 11164 11165 11166 | 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 | - - + + + | The F-cards will be visited in the order they are declared in d. For loaded-from-a-repo manifests this is always lexical order (for delta manifests, consistent across the delta and baseline). For hand-created decks which have not yet been fsl_deck_unshuffle()'d, the order is unspecified. */ |
︙ | |||
11278 11279 11280 11281 11282 11283 11284 | 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 | - + | On any error but FSL_RC_MISUSE (basic argument validation) f's error state is updated to describe the error. @see fsl_content_get() */ FSL_EXPORT int fsl_card_F_content( fsl_cx * f, fsl_card_F const * fc, |
︙ | |||
11312 11313 11314 11315 11316 11317 11318 | 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 | - + - - - + + + + + | particular if their isAppend values differ. Returns 0 on success, FSL_RC_MISUSE if !mf or !key, FSL_RC_RANGE if !*field, FSL_RC_TYPE if mf is of a type for which J cards are not legal (see fsl_card_is_legal()), FSL_RC_OOM on allocation error. */ |
︙ | |||
11413 11414 11415 11416 11417 11418 11419 | 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 | - - - + + + - + | If uuid is not NULL and fsl_is_uuid(uuid) returns false then this function returns FSL_RC_RANGE. If uuid is NULL then it is assumed to be the UUID of the currently-being-constructed artifact in which the tag is contained (which appears as the '*' character in generated artifacts). |
︙ | |||
11444 11445 11446 11447 11448 11449 11450 11451 | 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 11606 11607 11608 11609 11610 11611 11612 11613 | + + + + + + - + | tags to the given deck: "branch" with a value of branchName and "sym-branchName" with no value. Returns 0 on success. Returns FSL_RC_OOM on allocation error and FSL_RC_RANGE if branchName is empty or contains any characters with ASCII values <=32d. It natively assumes that any characters >=128 are part of multibyte UTF8 characters. ACHTUNG: this does not arrange for canceling the previous branch because it doesn't know that branch at this point. To cancel the previous branch a cancelation T-card needs to be added to the deck named "sym-BRANCHNAME". Historically such tags have had the value "Cancelled by branch", but that's not a requirement. */ |
︙ | |||
11470 11471 11472 11473 11474 11475 11476 | 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 11637 11638 | - + | allows the client to decide on whether to use them (for more (admittedly redundant!) integrity checking) or not (much faster but "not strictly historically correct"), but defaults to having them enabled for symmetry with fossil(1). @see fsl_deck_R_calc2() */ |
︙ | |||
11611 11612 11613 11614 11615 11616 11617 | 11765 11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 11784 11785 11786 11787 | - + + + + | F-cards were used, but it was eventually made optional because (A) the memory cost and (B) it's part of a 3rd or 4th level of integrity-related checks, and is somewhat superfluous. @see fsl_deck_output() @see fsl_deck_save() */ |
︙ | |||
11638 11639 11640 11641 11642 11643 11644 | 11795 11796 11797 11798 11799 11800 11801 11802 11803 11804 11805 11806 11807 11808 11809 11810 11811 11812 11813 11814 11815 | - + - + | Returns FSL_RC_SYNTAX if fsl_deck_has_required_cards() returns false. On errors more serious than argument validation, the deck's context's (d->f) error state is updated. The exact structure of the ouput depends on the value of |
︙ | |||
11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 | 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 | + + + + + + + - - - + + + + + + + + + - + + + + + + + + + + | the destination deck when this function returns. d might be partially populated on error, so regardless of success or failure, the client must eventually pass d to fsl_deck_finalize() to free its memory. Error result codes include: - FSL_RC_SYNTAX on syntax errors. Note that fossil's approach to determine "is this an artifact?" is "can it pass through fsl_deck_parse()?" This result code simply means that the input is, strictly speaking, not a fossil artifact. In some contexts this condition must be caught and treated as not-an-error (but not an artifact). - FSL_RC_MISUSE if any pointer argument is NULL or d->f is NULL. |
︙ | |||
11811 11812 11813 11814 11815 11816 11817 | 11990 11991 11992 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 | - - + + | FSL_EXPORT int fsl_deck_parse2(fsl_deck * const d, fsl_buffer * const src, fsl_id_t rid); /** Quickly determines whether the content held by the given buffer "might" be a structural artifact. It performs a fast sanity check for prominent features which can be checked either in O(1) or very short O(N) time (with a fixed N). If it returns false then the |
︙ | |||
11939 11940 11941 11942 11943 11944 11945 | 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 | - + - + - - + + + + + + | const, but certain operations on a deck are necessarily non-const operations. That includes, but may not be limited to: - Iterating over F-cards, which requires calling fsl_deck_F_rewind() before doing so. - Loading a checkin's baseline (required for F-card iteration and |
︙ | |||
12041 12042 12043 12044 12045 12046 12047 | 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 12249 12250 | - + + + + + + + + | names they register. The library reserves the prefix "fsl/" for its own use, and will happily overwrite client-registered entries with the same names. The name string need not be stable across application sessions and maybe be a randomly-generated string. Caveat: some obscure artifact crosslinking steps do not happen unless crosslinking takes place in the context of a |
︙ | |||
12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 | 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 12275 12276 12277 12278 12279 12280 12281 12282 12283 12284 12285 | + + + + + + + + + + | - Technote artifacts: "fsl/technote/timeline" - Wiki artifacts: "fsl/wiki/timeline" A context registers listeners under those names when it initializes, and clients may override them at any point after that. Sidebar: due to how tickets are crosslinked (_after_ the general crosslinking phase is actually finished and requiring state which other crosslinkers do not), it is not currently possible to override the ticket crosslink handler. Thus the core ticket crosslinker will always run, and update the [event] table, but a custom crosslinker may overwrite the resulting [event] table entries (in particular, the comment). Determining whether/how ticket crosslinking can be restructured to be consistent with the other types is on the TODO list. Caveat: updating the timeline requires a bit of knowledge about the Fossil DB schema and/or conventions. Updates for certain types, e.g. attachment/control/forum post, is somewhat more involved and updating the timeline for wiki comments requires observing a "quirk of conventions" for labeling such comments, such that they will appear properly when the main fossil app renders them. That said, |
︙ | |||
12116 12117 12118 12119 12120 12121 12122 | 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 | - + | negative value on error (dig around the sources to decode them - this is not expected to fail unless the system is undergoing a catastrophe). @see fsl_content_blob() @see fsl_content_get() */ |
︙ | |||
12228 12229 12230 12231 12232 12233 12234 | 12428 12429 12430 12431 12432 12433 12434 12435 12436 12437 12438 12439 12440 12441 12442 12443 12444 12445 12446 12447 12448 12449 12450 12451 12452 12453 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 12483 12484 12485 12486 12487 | - + - + - + - + | must not hold a pointer to it or its contents. @see fsl_wiki_load_latest() @see fsl_wiki_latest_rid() @see fsl_wiki_names_get() @see fsl_wiki_page_exists() */ |
︙ | |||
12436 12437 12438 12439 12440 12441 12442 | 12636 12637 12638 12639 12640 12641 12642 12643 12644 12645 12646 12647 12648 12649 12650 12651 12652 12653 12654 12655 12656 12657 12658 12659 12660 12661 12662 12663 12664 12665 | - + - + | Represents a J card in a Ticket Control Artifact. */ struct fsl_card_J { /** If true, the new value should be appended to any existing one with the same key, else it will replace any old one. */ |
︙ | |||
12630 12631 12632 12633 12634 12635 12636 | 12830 12831 12832 12833 12834 12835 12836 12837 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 12848 12849 12850 12851 12852 12853 12854 12855 12856 12857 12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 12869 12870 12871 12872 12873 12874 12875 12876 12877 12878 12879 12880 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 | - - - + + + + - - + + - - - - - + + + + + - - + - - - - + + + + - - - - - + + + + + | it is impossible to distinguish between the results "invalid rid" and "empty directory list" (which is a legal result). On success it returns 0 and tgt will have a number of (char *) entries appended to it equal to the number of subdirectories in the repo (possibly 0). |
︙ | |||
12839 12840 12841 12842 12843 12844 12845 | 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 | - + - - - - - - - - + + + + - - + + | /** Initialized-with-defaults fsl_repo_extract_opt instance, intended for intializing new non-const instances. */ FSL_EXPORT const fsl_repo_extract_opt fsl_repo_extract_opt_empty; /** |
︙ | |||
12985 12986 12987 12988 12989 12990 12991 12992 12993 | 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 13193 13194 13195 13196 13197 13198 13199 | + + - + | /** Looks for the delta table record where rid==deltaRid, and returns that record's srcid via *rv. Returns 0 on success, non-0 on error. If no record is found, *rv is set to 0 and 0 is returned (as opposed to FSL_RC_NOT_FOUND) because that generally simplifies the error checking. Results are undefined if any pointer argument is NULL. */ FSL_EXPORT int fsl_delta_src_id( fsl_cx * const f, fsl_id_t deltaRid, |
︙ | |||
13022 13023 13024 13025 13026 13027 13028 | 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 13245 | - + + - + + | This routine is much more efficient if used to answer several queries in a row for the same manifest (the vid parameter). It is least efficient when it is passed intermixed manifest IDs, e.g. (1, 3, 1, 4, 1,...). This is a side-effect of the caching used in the computation of ancestors for a given vid. */ |
︙ | |||
13085 13086 13087 13088 13089 13090 13091 | 13285 13286 13287 13288 13289 13290 13291 13292 13293 13294 13295 13296 13297 13298 13299 | - + | The julian time of the branch. If 0 or less, default is the current time. */ double mtime; /** If true, the branch will be marked as private. */ |
︙ | |||
13420 13421 13422 13423 13424 13425 13426 | 13620 13621 13622 13623 13624 13625 13626 13627 13628 13629 13630 13631 13632 13633 13634 13635 | - + + | problems, another (more serious) result code is returned, e.g. FSL_RC_OOM or FSL_RC_DB. If FSL_RC_NOT_FOUND is returned and hashOut is not NULL, *hashOut is set to the value of f's preferred hash. *ridOut is only modified if 0 is returned, in which case *ridOut will have a positive value. */ |
︙ | |||
13468 13469 13470 13471 13472 13473 13474 | 13669 13670 13671 13672 13673 13674 13675 13676 13677 13678 13679 13680 13681 13682 13683 13684 13685 13686 13687 13688 13689 13690 13691 13692 13693 13694 13695 13696 13697 13698 13699 13700 13701 13702 13703 13704 13705 | - - - - - + + + + + + - - + - + - - + + - + | This routine does not require that f have an opened repo, but if it does then this routine compares the canonicalized forms of both the repository db and the given path and fails if zPath refers to the repository db. Be aware that the relativeToCwd flag may influence that test. |
︙ | |||
13536 13537 13538 13539 13540 13541 13542 | 13737 13738 13739 13740 13741 13742 13743 13744 13745 13746 13747 13748 13749 13750 13751 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 13786 13787 13788 13789 13790 13791 13792 13793 13794 13795 13796 13797 13798 13799 13800 13801 13802 13803 13804 13805 13806 13807 13808 13809 13810 13811 13812 13813 13814 13815 13816 13817 13818 13819 13820 13821 13822 13823 | - + - + - + - + - + - + - + | fsl_repo_leaves_rebuild()). @see fsl_leaves_computed_has() @see fsl_leaves_computed_count() @see fsl_leaves_computed_latest() @see fsl_leaves_computed_cleanup() */ |
︙ | |||
13778 13779 13780 13781 13782 13783 13784 | 13979 13980 13981 13982 13983 13984 13985 13986 13987 13988 13989 13990 13991 13992 | - - - - | TODO: figure out and explain the difference between versionRid and originRid. */ fsl_id_t originRid; /** The maximum number of versions to search through. |
︙ | |||
13965 13966 13967 13968 13969 13970 13971 | 14162 14163 14164 14165 14166 14167 14168 14169 14170 14171 14172 14173 14174 14175 14176 14177 14178 14179 14180 14181 14182 14183 14184 14185 | - - + + - - + | /** Options for the rebuild process. */ struct fsl_rebuild_opt { /** Scan artifacts in a random order (generally only of use in testing |
︙ | |||
13997 13998 13999 14000 14001 14002 14003 | 14193 14194 14195 14196 14197 14198 14199 14200 14201 14202 14203 14204 14205 14206 14207 14208 14209 14210 14211 | - + - | Optional state for the callback function. */ void * callbackState; }; /** Initialized-with-defaults fsl_rebuild_opt structure, intended for const-copy initialization. */ |
︙ | |||
14052 14053 14054 14055 14056 14057 14058 14059 14060 14061 14062 14063 | 14247 14248 14249 14250 14251 14252 14253 14254 14255 14256 14257 14258 14259 14260 14261 14262 14263 14264 14265 14266 14267 14268 14269 14270 14271 14272 14273 14274 14275 14276 14277 14278 14279 14280 14281 14282 14283 14284 14285 14286 14287 14288 14289 14290 14291 14292 14293 14294 14295 14296 14297 14298 14299 14300 14301 14302 14303 14304 14305 14306 14307 14308 14309 14310 14311 14312 14313 14314 14315 14316 14317 14318 14319 14320 14321 14322 14323 14324 14325 14326 14327 14328 14329 14330 14331 14332 14333 14334 14335 14336 14337 14338 14339 14340 14341 14342 14343 14344 14345 14346 14347 14348 14349 14350 14351 14352 14353 14354 14355 14356 14357 14358 14359 14360 14361 14362 14363 14364 14365 14366 14367 14368 14369 14370 14371 14372 14373 14374 14375 14376 14377 14378 14379 14380 14381 14382 14383 14384 14385 14386 14387 14388 14389 14390 14391 14392 14393 14394 14395 14396 14397 14398 14399 14400 14401 14402 14403 14404 14405 14406 14407 14408 14409 14410 14411 14412 14413 14414 14415 14416 14417 14418 14419 14420 14421 14422 14423 14424 14425 14426 14427 14428 14429 14430 14431 14432 14433 14434 14435 14436 14437 14438 14439 14440 14441 14442 14443 14444 14445 14446 14447 14448 14449 14450 14451 14452 14453 14454 14455 14456 14457 14458 14459 14460 14461 14462 14463 14464 14465 14466 14467 14468 14469 14470 14471 14472 14473 14474 14475 14476 14477 14478 14479 14480 14481 14482 14483 14484 14485 14486 14487 14488 14489 14490 14491 14492 14493 14494 14495 14496 14497 14498 14499 14500 14501 14502 14503 14504 14505 14506 14507 14508 14509 14510 14511 14512 14513 14514 14515 14516 14517 14518 14519 14520 14521 14522 14523 14524 14525 14526 14527 14528 14529 14530 14531 14532 14533 14534 14535 14536 14537 14538 14539 14540 14541 14542 14543 14544 14545 14546 14547 14548 14549 14550 14551 14552 14553 14554 14555 14556 14557 14558 14559 14560 14561 14562 14563 14564 14565 14566 14567 14568 14569 14570 14571 14572 14573 14574 14575 14576 14577 14578 14579 14580 14581 14582 14583 14584 14585 14586 14587 14588 14589 14590 14591 14592 14593 14594 14595 14596 14597 14598 14599 14600 14601 14602 14603 14604 14605 14606 14607 14608 14609 14610 14611 14612 14613 14614 14615 14616 14617 14618 14619 14620 14621 14622 14623 14624 14625 14626 14627 14628 14629 14630 14631 14632 14633 14634 14635 14636 14637 14638 14639 14640 14641 14642 14643 14644 14645 14646 14647 14648 14649 14650 14651 14652 14653 14654 14655 14656 14657 14658 14659 14660 14661 14662 14663 14664 14665 14666 14667 14668 14669 14670 14671 14672 14673 14674 14675 14676 14677 14678 14679 14680 14681 14682 14683 14684 14685 14686 14687 14688 14689 14690 14691 14692 14693 14694 14695 14696 14697 14698 14699 14700 14701 14702 14703 14704 14705 14706 14707 14708 14709 14710 14711 14712 14713 14714 14715 14716 14717 14718 14719 14720 14721 14722 14723 14724 14725 14726 14727 14728 14729 14730 14731 14732 14733 14734 14735 14736 14737 14738 14739 14740 14741 14742 14743 14744 14745 14746 14747 14748 14749 14750 14751 14752 14753 14754 14755 14756 14757 14758 14759 14760 14761 14762 14763 14764 14765 14766 14767 14768 14769 14770 14771 14772 14773 14774 14775 14776 14777 14778 14779 14780 14781 14782 14783 14784 14785 14786 14787 14788 14789 14790 14791 14792 14793 14794 14795 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | artifacts, so this routine does _not_ drop and rebuild the ticket-related tables. If the FSL_CX_F_SKIP_UNKNOWN_CROSSLINKS flag is _not_ set on f, this routine _will fail_ if it encounters any ticket artifacts. */ FSL_EXPORT int fsl_repo_rebuild(fsl_cx * const f, fsl_rebuild_opt const * const opt); /** Tries to determine the branch name of the given rid, which is assumed to refer to a checkin artifact. If it cannot find one and doFallback is true then it looks for the `main-branch` repository-level config setting and uses that (falling back to "trunk" is that setting is not set). On success it returns 0 and sets `*zOut` to the branch name, transfering ownership of those bytes to the caller. If doFallback is false and no direct branch name is found then it sets `*zOut` to NULL. If doFallback is true then, on success, `*zOut` will always be set to some non-NULL value. On error `*zOut` is not modified. On error it may return FSL_RC_NOT_A_REPO, FSL_RC_OOM, or any number of db-side error codes. */ FSL_EXPORT int fsl_branch_of_rid(fsl_cx * const f, fsl_int_t rid, bool doFallback, char ** zOut ); /** Convenience typedef and obligatory forward declaration. */ typedef struct fsl_cidiff_state fsl_cidiff_state; /** Callback type for use with fsl_cidiff(). It must return 0 on success or a value from the fsl_rc_e enum on error. On error it "should" update the error state in the corresponding fsl_cx object by passing state->f to fsl_cx_err_set() (or equivalent). */ typedef int (*fsl_cidiff_f)(fsl_cidiff_state const *state); /** Options for use with fsl_cidiff() */ struct fsl_cidiff_opt { /** Checkin version (RID) for "version 1". */ fsl_id_t v1; /** Checkin version (RID) for "version 2". This checkin need not have any relationship with version 1, in terms of SCM-side lineage. */ fsl_id_t v2; /** Callback to call on each iteration step. */ fsl_cidiff_f callback; /** Opaque state for the callback. It can be accessed from the callback via arg->opt->callbackState. */ void * callbackState; }; /** Convenience typedef. */ typedef struct fsl_cidiff_opt fsl_cidiff_opt; /** Initialized-with-defaults fsl_cidiff_opt structure, intended for const-copy initialization. */ #define fsl_cidiff_opt_empty_m {0,0} /** Initialized-with-defaults fsl_cidiff_opt structure, intended for non-const copy initialization. */ FSL_EXPORT const fsl_cidiff_opt fsl_cidiff_opt_empty; /** Descriptors for the type of information being reported for each step of fsl_cidiff() iteration, as reported via the fsl_cidiff_state::changes attribute. */ enum fsl_cidiff_e { /** Indicates that the v1 and v2 files are the same. Specifically, this means: - Same current names, compared case-sensitively. fsl_card_F::priorName values are ignored for this - Same permissions. - Same hash. */ FSL_CIDIFF_NONE = 0, /** Indicates that the hashes of the v1 and v2 files differ. */ FSL_CIDIFF_FILE_MODIFIED = 0x0001, /** Indicates that the v2 file was renamed. Caveats: - If v1 and v2 are not immediate relatives in the SCM DAG sense. e.g. when comparing a version X and unrelated version Y, or version X and X+30, it is possible that a rename goes unreported via fsl_cidiff or that it gets misdiagnosed. e.g. if version X renames file A to B and version X+100 renames file C to A, it will be reported as a rename. Detecting the true reality of such cases is remarkably challenging, requiring going through the entire history which links v1 and v2. - Pedantically speaking, if v1 and v2 are unrelated in the SCM DAG, "renames" are not possible but will be reported as such if their names happen to match up. */ FSL_CIDIFF_FILE_RENAMED = 0x0002, /** Indicates that the permissions of the current file differ between v1 and v2. This is only set if both versions have a given file (by name, as opposed to hash). */ FSL_CIDIFF_FILE_PERMS = 0x0004, /** Indicates that the file is in v2 but not v1. If v1 and v2 are unrelated versions or are not immediate DAG neighbors, this might also indicate that a file from v1 was renamed in v2. */ FSL_CIDIFF_FILE_ADDED = 0x0010, /** Indicates that the file is in v1 but not v2. If v1 and v2 are unrelated versions or are not immediate DAG neighbors, this might also indicate that a file from v1 was renamed in v2. */ FSL_CIDIFF_FILE_REMOVED = 0x0020 }; /** Convenience typedef. */ typedef enum fsl_cidiff_e fsl_cidiff_e; /** Holds the state for a single iteration step of fsl_cidiff. */ struct fsl_cidiff_state { /** The associated fsl_cx instance. */ fsl_cx * f; /** The options object passed to fsl_cidiff(). */ fsl_cidiff_opt const *opt; /** Denotes the type of this step in the iteration. Before fsl_cidiff() starts its loop over F-card changes, it calls the callback once with this value set to 0. The intent is to give the caller an opporuntity to do any required setup, e.g. outputing a report header. The fc1 and fc2 members will both be NULL, but the d1 and d2 members will be set. For each step of the F-card iteration, stepType will be set to FSL_RC_STEP_ROW. After successful difference iteration, fsl_cidiff() calls its callback with stepType set to FSL_RC_STEP_DONE. The intent is to give the caller an opporuntity to do any required cleanup, e.g. outputing a report footer. The fc1 and fc2 members will both be NULL, but the d1 and d2 members will be set. */ int stepType; /** Describes the change(s) being reported by the current iteration step, as a bitmask of fsl_cidiff_e values. */ int changes; /** The file, if any, corresponding to this->v1. This will be NULL this->changeType is FSL_CIDIFF_FILE_ADDED. */ fsl_card_F const * fc1; /** The file, if any, corresponding to this->v2. This will be NULL this->changeType is FSL_CIDIFF_FILE_REMOVED. */ fsl_card_F const * fc2; /** The deck corresponding to this->opt->v1. It is strictly forbidden for this->callback to manipulate this object. Specifically, any traversal of its F-card list will invalidate the iteration being done by fsl_cidiff(). Read-only operations on other state of the deck are legal. */ fsl_deck const * d1; /** The deck corresponding to this->opt->v2. See the docs for this->d1 for important details. */ fsl_deck const * d2; }; /** Initialized-with-defaults fsl_cidiff_state structure, intended for const-copy initialization. */ #define fsl_cidiff_state_empty_m {\ NULL/*f*/,NULL/*opt*/, \ 0/*stepType*/,FSL_CIDIFF_NONE/*changes*/, \ NULL/*fc1*/,NULL/*fc2*/, \ NULL/*d1*/,NULL/*d2*/ \ } /** Initialized-with-defaults fsl_cidiff_state structure, intended for non-const copy initialization. */ FSL_EXPORT const fsl_cidiff_state fsl_cidiff_state_empty; /** A utility for reporting the differences between the manifests of two checkins. This loads the fsl_deck instances for each version opt->v1 and opt->v2, then calls opt->callback for each step of the difference-checking process. It only inspects and reports the difference between _exactly_ v1 and _exactly_ v2, not the difference between the chain of SCM DAG relatives (if any) between the two. It is not required that v1 and v2 be related in the SCM DAG but its report of differences may be misleading if v1 and v2 are either unrelated or separated by more than 1 step in the DAG. See the docs for fsl_cidiff_e for cases known to be potentially confusing. Returns 0 on success. If the callback returns non-0, that result is propagated back to the caller. It may otherwise return any number of othe result codes including, but not limited to: - FSL_RC_OOM on allocation error - FSL_RC_NOT_A_REPO if f has no opened repository. - FSL_RC_TYPE if either of the given versions is not a checkin. - FSL_RC_NOT_FOUND if either of given versions is not found in the repository. Potential TODO: add fsl_deck_diff() which takes two decks, instead of RIDs, to compare. This function would just be a proxy for that one, loading the given RIDs and passing on the decks. That would require a significantly larger set of possible change-type values and would require much type-specific handling (e.g. maybe reporting J-card differences for a pair of ticket decks). */ FSL_EXPORT int fsl_cidiff(fsl_cx * const f, fsl_cidiff_opt const * const opt); /** Configuration parameters for fsl_repo_create(). Always copy-construct these from fsl_repo_create_opt_empty resp. fsl_repo_create_opt_empty_m in order to ensure proper behaviour vis-a-vis default values. TODOs: - Add project name/description, and possibly other configuration bits. - Allow client to set password for default user (currently set randomly, as fossil(1) does). */ struct fsl_repo_create_opt { /** The file name for the new repository. */ char const * filename; /** Fossil user name for the admin user in the new repo. If NULL, defaults to the Fossil context's user (see fsl_cx_user_get()). If that is NULL, it defaults to "root" for historical reasons. */ char const * username; /** The comment text used for the initial commit. If NULL or empty (starts with a NUL byte) then no initial check is created. fossil(1) is largely untested with that scenario (but it seems to work), so for compatibility it is not recommended that this be set to NULL. The default value (when copy-initialized) is "egg". There's a story behind the use of "egg" as the initial checkin comment, and it all started with a typo: "initial chicken" */ char const * commitMessage; /** Mime type for the commit message (manifest N-card). Manifests support this but fossil(1) has never (as of 2021-02) made use of it. It is provided for completeness but should, for compatibility's sake, probably not be set, as the fossil UI may not honor it. The implied default is text/x-fossil-wiki. Other ostensibly legal values include text/plain and text/x-markdown. This API will accept any value, but results are technically undefined with any values other than those listed above. */ char const * commitMessageMimetype; /** If not NULL and not empty, fsl_repo_create() will use this repository database to copy the configuration, copying over the following settings: - The reportfmt table, overwriting any existing entries. - The user table fields (cap, info, mtime, photo) are copied for the "system users". The system users are: anonymous, nobody, developer, reader. - The vast majority of the config table is copied, arguably more than it should (e.g. the 'manifest' setting). */ char const * configRepo; /** If false, fsl_repo_create() will fail if this->filename already exists. */ bool allowOverwrite; }; typedef struct fsl_repo_create_opt fsl_repo_create_opt; /** Initialized-with-defaults fsl_repo_create_opt struct, intended for in-struct initialization. */ #define fsl_repo_create_opt_empty_m { \ NULL/*filename*/, \ NULL/*username*/, \ "egg"/*commitMessage*/, \ NULL/*commitMessageMimetype*/, \ NULL/*configRepo*/, \ false/*allowOverwrite*/ \ } /** Initialized-with-defaults fsl_repo_create_opt struct, intended for copy-initialization. */ FSL_EXPORT const fsl_repo_create_opt fsl_repo_create_opt_empty; /** Creates a new repository database using the options provided in the second argument. If f is not NULL, it must be a valid context instance, though it need not have an opened checkout/repository. If f has an opened repo or checkout, this routine closes them but that closing _will fail_ if a transaction is currently active! If f is NULL, a temporary context is used for creating the repository, in which case the caller will not have access to detailed error information (only the result code) if this operation fails. In that case, the resulting repository file will, on success, be found at the location referred to by opt.filename. The opt argument may not be NULL. If opt->allowOverwrite is false (0) and the file exists, it fails with FSL_RC_ALREADY_EXISTS, otherwise is creates/overwrites the file. This is a destructive operation if opt->allowOverwrite is true, so be careful: the existing database will be truncated and re-created. This operation installs the various "static" repository schemas into the db, sets up some default settings, and installs a default user. This operation always closes any repository/checkout opened by f because setting up the new db requires wiring it to f to set up some of the db-side infrastructure. The one exception is if argument validation fails, in which case f's repo/checkout-related state are not modified. Note that closing will fail if a transaction is currently active and that, in turn, will cause this operation to fail. See the fsl_repo_create_opt docs for more details regarding the creation options. On success, 0 is returned and f (if not NULL) is left with the new repository opened and ready for use. On error, f's error state is updated and any number of the FSL_RC_xxx codes may be returned - there are no less than 30 different _potential_ error conditions on the way to creating a new repository. If initialization of the repository fails, this routine will attempt to remove its partially-initialize corpse from the filesystem but will ignore any errors encountered while doing so. Example usage: ``` fsl_repo_create_opt opt = fsl_repo_create_opt_empty; int rc; opt.filename = "my.fossil"; // ... any other opt.xxx you want to set, e.g.: // opt.user = "fred"; // Assume fsl is a valid fsl_cx instance: rc = fsl_repo_create(fsl, &opt); if(rc) { ...error... } else { fsl_db * db = fsl_cx_db_repo(f); assert(db); // == the new repo db ... } ``` @see fsl_repo_open() @see fsl_repo_close() */ FSL_EXPORT int fsl_repo_create(fsl_cx * f, fsl_repo_create_opt const * opt ); /** UNTESTED. Returns true if f has an opened repository database which is opened in read-only mode, else returns false. */ FSL_EXPORT char fsl_repo_is_readonly(fsl_cx const * f); #if defined(__cplusplus) } /*extern "C"*/ #endif #endif /* ORG_FOSSIL_SCM_FSL_REPO_H_INCLUDED */ |
︙ | |||
14111 14112 14113 14114 14115 14116 14117 | 14806 14807 14808 14809 14810 14811 14812 14813 14814 14815 14816 14817 14818 14819 14820 14821 14822 14823 14824 | - - + + - - + + | as those always "seed" the database with an initial commit artifact containing no files. */ FSL_EXPORT void fsl_ckout_version_info(fsl_cx * const f, fsl_id_t * const rid, fsl_uuid_cstr * const uuid ); /** |
︙ | |||
14148 14149 14150 14151 14152 14153 14154 | 14843 14844 14845 14846 14847 14848 14849 14850 14851 14852 14853 14854 14855 14856 14857 14858 14859 14860 14861 14862 14863 14864 14865 14866 14867 14868 14869 14870 14871 14872 14873 14874 14875 14876 14877 14878 14879 14880 14881 14882 14883 14884 14885 14886 14887 14888 14889 14890 14891 14892 14893 14894 14895 14896 14897 14898 14899 14900 14901 14902 14903 14904 14905 14906 14907 14908 14909 14910 14911 14912 14913 14914 14915 14916 14917 14918 14919 14920 14921 14922 14923 14924 14925 | - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + + - - + + - | This function does not validate whether or not the file actually exists, only that its name is potentially valid as a filename for use in a checkout (though other, downstream rules might prohibit that, e.g. the filename "..../...." is not valid but is not seen as invalid by this function). (Reminder to self: we could run the end result through fsl_is_simple_pathname() to catch that?) */ |
︙ | |||
14256 14257 14258 14259 14260 14261 14262 | 14997 14998 14999 15000 15001 15002 15003 15004 15005 15006 15007 15008 15009 15010 | - | any of those globs. - The client-provided callback says not to include the file. */ uint32_t skipped; } counts; }; |
︙ | |||
14305 14306 14307 14308 14309 14310 14311 14312 14313 14314 14315 14316 14317 14318 14319 14320 14321 14322 14323 | 15045 15046 15047 15048 15049 15050 15051 15052 15053 15054 15055 15056 15057 15058 15059 15060 15061 15062 15063 15064 15065 15066 15067 15068 15069 15070 15071 15072 15073 15074 15075 15076 15077 15078 15079 15080 15081 15082 15083 15084 15085 15086 15087 15088 15089 15090 15091 15092 15093 15094 15095 15096 15097 15098 15099 15100 15101 15102 15103 15104 15105 15106 15107 15108 15109 15110 15111 15112 15113 15114 15115 15116 15117 15118 15119 15120 15121 15122 15123 15124 15125 15126 15127 15128 15129 15130 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + - - - + + + - - - - - + | ``` Returns 0 on success, non-0 on error. Files queued for addition this way can be unqueued before they are committed using fsl_ckout_unmanage(). To avoid Significant Grief, this routine automatically skips any directories under opt->filename which appear to be fossil checkout roots unless that directory is f's current checkout directory, into which it will recurse normally. @see fsl_ckout_unmanage() @see fsl_reserved_fn_check() */ FSL_EXPORT int fsl_ckout_manage( fsl_cx * const f, fsl_ckout_manage_opt * const opt ); /** Convenience typedef and required forward decl. */ typedef struct fsl_ckout_unmanage_opt fsl_ckout_unmanage_opt; /** State passed to fsl_ckout_unmanage_f() callback. */ struct fsl_ckout_unmanage_state { /** The fsl_cx instance for the correspnding fsl_ckout_unmanage() call. */ fsl_cx * f; /** The options object passed to the corresponding call to fsl_ckout_unmanage(). This is provided primarily for access to its callbackState member. The client must never modify any state in this opt object other than the callbackState or to use other APIs of this->f. */ fsl_ckout_unmanage_opt const * opt; /** The name of the file being unmanaged, relative to the root of the checkout. fsl_cx_stat2() can be used to transform it to an absolute path, if needed. Given a fsl_ckout_unmanage_state named `ums`, that call would look like: ``` fsl_buffer_reuse(&yourBuffer); // ^^^ noting that fsl_cx_stat2() APPENDS to the buffer. int rc = fsl_cx_stat2(ums->f, false, ums->filename, NULL, &yourBuffer, true); // ^^^ noting that the stat will legitimately and harmlessly // fail if the file does not exist, so this error can // normally be ignored. ``` */ char const * filename; }; /** Convenience typedef. */ typedef struct fsl_ckout_unmanage_state fsl_ckout_unmanage_state; /** Callback type for use with fsl_ckout_unmanage(). It is called by the removal process, immediately after a file is "removed" from SCM management (a.k.a. when the file becomes "unmanaged"). |
︙ | |||
14380 14381 14382 14383 14384 14385 14386 | 15167 15168 15169 15170 15171 15172 15173 15174 15175 15176 15177 15178 15179 15180 15181 | - - | The name it is passed is relative to the checkout root. */ fsl_ckout_unmanage_f callback; /** State to be passed to this->callback. */ void * callbackState; |
︙ | |||
14858 14859 14860 14861 14862 14863 14864 | 15643 15644 15645 15646 15647 15648 15649 15650 15651 15652 15653 15654 15655 15656 15657 15658 15659 15660 15661 15662 15663 15664 15665 15666 15667 15668 15669 15670 15671 15672 15673 15674 15675 15676 15677 15678 15679 15680 15681 15682 15683 15684 15685 15686 15687 15688 15689 15690 15691 15692 15693 15694 15695 15696 15697 15698 15699 15700 15701 15702 15703 15704 15705 15706 | - - + + - - - - - - + + + + + + + + - + + - + | opt->filename must refer to a path within the current checkout. @see fsl_checkin_enqueue() @see fsl_checkin_is_enqueued() @see fsl_checkin_discard() @see fsl_checkin_commit() */ |
︙ | |||
15392 15393 15394 15395 15396 15397 15398 | 16180 16181 16182 16183 16184 16185 16186 16187 16188 16189 16190 16191 16192 16193 16194 16195 16196 16197 | - - - - + + + | Empty-initialised fsl_repo_open_ckout_opt instance. Clients should copy this value (or fsl_repo_open_ckout_opt_empty_m) to initialise fsl_repo_open_ckout_opt instances for sane default values. */ FSL_EXPORT const fsl_repo_open_ckout_opt fsl_repo_open_ckout_opt_empty; /** |
︙ | |||
15418 15419 15420 15421 15422 15423 15424 | 16205 16206 16207 16208 16209 16210 16211 16212 16213 16214 16215 16216 16217 16218 16219 16220 | - + + | Pending: - If opening an existing checkout db for a different repo then delete the STASH and UNDO entries, as they're not valid for a different repo. */ |
︙ | |||
15479 15480 15481 15482 15483 15484 15485 | 16267 16268 16269 16270 16271 16272 16273 16274 16275 16276 16277 16278 16279 16280 16281 | - + | /** Merge was not performed because at least one of the inputs appears to be binary. The updated-to version overwrites the previous version in this case. */ FSL_CKUP_FCHANGE_UPDATED_BINARY, /** Updated with a merge by the update process. */ FSL_CKUP_FCHANGE_MERGED, |
︙ | |||
15503 15504 15505 15506 15507 15508 15509 | 16291 16292 16293 16294 16295 16296 16297 16298 16299 16300 16301 16302 16303 16304 16305 16306 16307 16308 16309 16310 16311 16312 16313 16314 16315 16316 16317 16318 16319 | - + + + + + + + + + + | TODO: use confirmer here to ask user whether to overwrite. */ FSL_CKUP_FCHANGE_CONFLICT_ADDED_UNMANAGED, /** Edited locally but removed from updated-to version. Local edits will be left in the checkout tree. */ FSL_CKUP_FCHANGE_CONFLICT_RM, /** Cannot merge if one or both of the update/updating verions of a |
︙ | |||
15788 15789 15790 15791 15792 15793 15794 | 16585 16586 16587 16588 16589 16590 16591 16592 16593 16594 16595 16596 16597 16598 16599 | - + | repo, FSL_RC_NOT_A_CKOUT if no checkout is opened. If cOpt->callback is not NULL and returns a non-0 result code, extraction ends and that result is returned. If it returns non-0 at any point after basic argument validation, it rolls back all changes or sets the current transaction stack into a rollback state. |
︙ | |||
15843 15844 15845 15846 15847 15848 15849 15850 15851 15852 15853 15854 15855 15856 15857 15858 | 16640 16641 16642 16643 16644 16645 16646 16647 16648 16649 16650 16651 16652 16653 16654 16655 16656 16657 16658 | + + + | FSL_EXPORT int fsl_ckout_calc_update_version(fsl_cx * f, fsl_id_t * outRid); /** Bitmask used by fsl_ckout_manifest_setting() and fsl_ckout_manifest_write(). */ enum fsl_cx_manifest_mask_e { /** Coresponds to the file "manifest". */ FSL_MANIFEST_MAIN = 0x001, /** Coresponds to the file "manifest.uuid". */ FSL_MANIFEST_UUID = 0x010, /** Coresponds to the file "manifest.tags". */ FSL_MANIFEST_TAGS = 0x100 }; typedef enum fsl_cx_manifest_mask_e fsl_cx_manifest_mask_e; /** Returns a bitmask representing which manifest files, if any, will be written when opening or updating a checkout directory, as |
︙ | |||
15930 15931 15932 15933 15934 15935 15936 | 16730 16731 16732 16733 16734 16735 16736 16737 16738 16739 16740 16741 16742 16743 16744 16745 16746 16747 16748 16749 16750 16751 16752 16753 16754 16755 16756 16757 16758 16759 16760 16761 16762 16763 16764 16765 16766 16767 16768 | - + - + - + - + | written by this routine and is also not part of the current checkout (i.e. not listed in the vfile table) will be removed from disk, but a failure while attempting to do so will be silently ignored. @see fsl_repo_manifest_write() */ |
︙ | |||
16178 16179 16180 16181 16182 16183 16184 | 16978 16979 16980 16981 16982 16983 16984 16985 16986 16987 16988 16989 16990 16991 16992 16993 16994 16995 16996 16997 16998 16999 17000 17001 17002 17003 17004 | + + + - + + + - - - + + + + | filenames in a more flexible form than that routine. This routine works exactly like that one except for the following differences: 1) The given filename and the relativeToCwd arguments are passed to by fsl_ckout_filename_check() to canonicalize the name and ensure that it points to someplace within f's current checkout. 2) Directory names passed to it may optionally end in an trailing slash. |
︙ | |||
16295 16296 16297 16298 16299 16300 16301 | 17101 17102 17103 17104 17105 17106 17107 17108 17109 17110 17111 17112 17113 17114 17115 | - + | it should be. TODO: currently the library offers no automated recovery mechanism from a mismatch, the only remedy being to close the checkout database, destroy it, and re-create it. fossil(1) is able, in some cases, to automatically recover from this situation. */ |
︙ | |||
16324 16325 16326 16327 16328 16329 16330 | 17130 17131 17132 17133 17134 17135 17136 17137 17138 17139 17140 17141 17142 17143 17144 | - + | char const * zName, fsl_buffer * const dest); /** Fetches the timestamp of the given F-card's name against the filesystem and/or the most recent checkin in which it was modified (as reported by fsl_mtime_of_manifest()). vid is the checkin |
︙ | |||
16348 16349 16350 16351 16352 16353 16354 16355 16356 | 17154 17155 17156 17157 17158 17159 17160 17161 17162 17163 17164 17165 17166 17167 17168 17169 17170 17171 17172 17173 17174 17175 17176 17177 17178 17179 17180 17181 17182 17183 17184 17185 17186 17187 17188 17189 17190 17191 17192 17193 17194 17195 17196 17197 17198 17199 17200 17201 17202 17203 17204 17205 17206 17207 17208 17209 17210 17211 17212 17213 17214 17215 17216 17217 17218 17219 17220 17221 17222 17223 17224 17225 17226 17227 17228 17229 17230 17231 17232 17233 17234 17235 17236 17237 17238 17239 17240 17241 17242 17243 17244 17245 17246 17247 17248 17249 17250 17251 17252 17253 17254 17255 17256 17257 17258 17259 17260 17261 17262 17263 17264 17265 17266 17267 17268 17269 17270 17271 17272 17273 17274 17275 17276 17277 17278 17279 17280 17281 17282 17283 17284 17285 17286 17287 17288 17289 17290 17291 17292 17293 17294 17295 17296 17297 17298 17299 17300 17301 17302 17303 17304 17305 17306 17307 17308 17309 17310 17311 17312 17313 17314 17315 17316 17317 17318 17319 17320 17321 17322 17323 17324 17325 17326 17327 17328 17329 17330 17331 17332 17333 17334 17335 17336 17337 17338 17339 17340 17341 17342 17343 17344 17345 17346 17347 17348 17349 17350 17351 17352 17353 17354 17355 17356 17357 17358 17359 17360 17361 17362 17363 17364 17365 17366 17367 17368 17369 17370 17371 17372 17373 17374 17375 17376 17377 17378 17379 17380 17381 17382 17383 17384 17385 17386 17387 17388 17389 17390 17391 17392 17393 17394 17395 17396 17397 17398 17399 17400 17401 17402 17403 17404 17405 17406 17407 17408 17409 17410 17411 17412 17413 17414 17415 17416 17417 17418 17419 17420 17421 17422 17423 17424 17425 17426 17427 17428 17429 17430 17431 17432 17433 17434 17435 17436 17437 17438 17439 17440 17441 17442 17443 17444 17445 17446 17447 17448 17449 17450 17451 17452 17453 17454 17455 17456 17457 17458 17459 17460 17461 17462 17463 17464 17465 17466 17467 17468 17469 17470 17471 17472 17473 17474 17475 17476 17477 17478 17479 17480 17481 17482 17483 17484 17485 17486 17487 17488 17489 17490 17491 17492 17493 17494 17495 17496 17497 17498 17499 17500 17501 17502 17503 17504 17505 17506 17507 17508 17509 17510 17511 17512 17513 17514 17515 17516 17517 17518 17519 17520 17521 17522 17523 17524 17525 17526 17527 17528 17529 17530 17531 17532 17533 17534 17535 17536 17537 17538 17539 17540 17541 17542 17543 17544 17545 17546 17547 17548 17549 17550 17551 17552 17553 17554 17555 17556 17557 17558 17559 17560 17561 17562 17563 17564 17565 17566 17567 17568 17569 17570 17571 17572 17573 17574 17575 17576 17577 17578 17579 17580 17581 17582 17583 17584 17585 17586 17587 17588 17589 17590 17591 17592 17593 17594 17595 17596 17597 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + + + + + + - + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + - + - - - - + + + + - + - - + + - + - + - + + - + - + - + + + + + - + + + - + + + + + + + + + + + + + + - + - - - - + + + - - + + - - - - - - - - - + + + + + + - + + - - - + - + - - + - + + + - - + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + | - FSL_RC_OOM. */ FSL_EXPORT int fsl_card_F_ckout_mtime(fsl_cx * const f, fsl_id_t vid, fsl_card_F const * const fc, fsl_time_t * repoMtime, fsl_time_t * localMtime); /** File change types for use with fsl_merge_state::fileChangeType. Terminology used in some of the descriptions: - (P) is the "pivot" - the common ancestor for the merge. - (M) is the version being merged in to... - (V) is current checkout version into which (M) is being merged. Maintenance reminder: this enum's values must start at 0 and increment sequentially, and FSL_MERGE_FCHANGE_count must be the final entry. This is to enable the creation of arrays, e.g. for keeping track (client-side) of how many times a given change type has been seen during a given merge run. */ enum fsl_merge_fchange_e { /** Not currently used. Merge does not (and cannot without some surgery) report state of files unaffected by a merge. This entry exists for the case that that changes. This is the only entry in the enum which is guaranteed to have a specific value: 0, so that it can be used as a boolean false. */ FSL_MERGE_FCHANGE_NONE = 0, /** File was added to (V) from (M). */ FSL_MERGE_FCHANGE_ADDED, /** File content was copied as-is from (M) to (V). */ FSL_MERGE_FCHANGE_COPIED, /** File was removed from (V) via (M). a.k.a. it became "unmanaged." */ FSL_MERGE_FCHANGE_RM, /** Content from (M) was merged into (V). */ FSL_MERGE_FCHANGE_MERGED, /** Special case of FSL_MERGE_FCHANGE_MERGED. Merge was performed from (M) to (V) and conflicts were detected. The newly-updated file will contain conflict markers. @see fsl_buffer_contains_merge_marker() */ FSL_MERGE_FCHANGE_CONFLICT_MERGED, #if 0 /** Added in the current checkout but also contained in the updated-to version. The local copy takes precedence. */ FSL_MERGE_FCHANGE_CONFLICT_ADDED, #endif /** Added to (V) by (M) but a local unmanaged copy exists. The local copy is overwritten, per historical fossil(1) convention (noting that fossil has undo support to allow one to avoid loss of such a file's contents). */ FSL_MERGE_FCHANGE_CONFLICT_ADDED_UNMANAGED, #if 0 /* Fossil deletes merged-over removed files, regardless of whether they're locally edited, so we'll do the same for now (noting that fossil has undo support which can hypothetically save that case from data loss). fsl_ckout_update() does not do so, but has extra infastructure to deal with this. */ /** Edited locally but removed from merged-in version. Local edits will be left in the checkout tree. */ FSL_MERGE_FCHANGE_CONFLICT_RM, #endif /** Cannot merge if one or both of the update/updating versions of a file is a symlink. This case needs re-thinking. fossil(1) simply skips such merges with a warning but no error. This library has no warning mechanism other than to pass this code on to the fsl_merge_f() callback, so that's what we do. For UPDATE ops, the updated-to version overwrites the previous version in this case. Why merge doesn't do that isn't clear, but it's probably because we can have any number of merge parents and choosing which one to use in the merge/replace case would be impossible. */ FSL_MERGE_FCHANGE_CONFLICT_SYMLINK, /** Indicates that a merge of binary content was requested. We cannot merge binaries, so this indicates that the file in question was skipped over for merge purposes. fossil(1) simply skips over, with a warning, binaries during a merge, so we do the same (for lack of a better option). */ FSL_MERGE_FCHANGE_CONFLICT_BINARY, /** Indicates that the given file cannot be merged because no common ancestor can be found for it. This condition is not strictly fatal but does indicate a problem with the input data. Merging will continue unless the fsl_merge_f() to which this is reported returns non-0 to cancel it. This particular status is reported very early in the fsl_ckout_merge() process, before any files have been written by the merge, thus the callback can effectively abort the merge without side-effects by returning non-0 if this status is reported to it. If the fsl_ckout_merge() call has no callback set, this case will go silently undiagnosed! Potential TODO: add a flag to fsl_merge_opt to tell it to treat any of these cases as merge-fatal. */ FSL_MERGE_FCHANGE_CONFLICT_ANCESTOR, /** File was renamed in the updated-to version. If a file is both modified and renamed, it will be reported twice: once for each type of change. The new name is reported via fsl_merge_state::filename and the previous name via fsl_merge_state::priorName. */ FSL_MERGE_FCHANGE_RENAMED, /** This is the number of entries in this enum, for purposes of creating, e.g. arrays of counters. This entry is never reported via a fsl_merge_state::fileChangeType. */ FSL_MERGE_FCHANGE_count }; typedef enum fsl_merge_fchange_e fsl_merge_fchange_e; /** Reqired forward decl. */ typedef struct fsl_merge_opt fsl_merge_opt; /** UNDER CONSTRUCTION! INCOMPLETE! A type for passing state to fsl_merge_f callbacks during fsl_ckout_merge() processing. For each step of a merge operation which affects a file, state reflecting that change is set in one of these objects and it is passed to the fsl_merge_f implementation supplied by the caller. Unlike fsl_ckout_update(), fsl_ckout_merge() reports only files which are affected by a merge, not unmodified files. Whether that's a bug or a feature is not yet clear, but the merge algorithm does not, as is, support reporting unaffected files. Due to the complexity and intricacy of the merge operation, it is possible that any given file will get passed to the fsl_merge_f() callback more than once with a different fsl_merge_state::fileChangeType value. Most notably, a file which has been modified and renamed may be passed on one with FSL_MERGE_FCHANGE_COPIED and once with FSL_MERGE_FCHANGE_RENAMED. Whether that's a bug or a feature is as-yet undecided, but (A) fossil(1) does it that way and (B) _not_ doing that would require some rearchitecting. |
︙ | |||
16576 16577 16578 16579 16580 16581 16582 16583 16584 16585 16586 16587 16588 16589 | 17610 17611 17612 17613 17614 17615 17616 17617 17618 17619 17620 17621 17622 17623 17624 17625 17626 17627 17628 17629 | + + + + + + | were */ enum fsl_confdb_e { /** Sentinel value. Not for use with public APIs. */ FSL_CONFDB_NONE = 0, /** Signfies the global-level (per system user) configuration area. Note that fsl_config_... APIs which use this do not currently open that database on demand due to the potential for downstream locking-related issues when the config db is left open, as well as locking-related issues here when a separate client or instance is holding that db open. That behaviour may change in the future. */ FSL_CONFDB_GLOBAL = 1, /** Signfies the repository-level configuration area. */ FSL_CONFDB_REPO = 2, /** |
︙ | |||
17013 17014 17015 17016 17017 17018 17019 | 18053 18054 18055 18056 18057 18058 18059 18060 18061 18062 18063 18064 18065 18066 18067 18068 | - - + + | fsl_size_t * len); #if defined(__cplusplus) } /*extern "C"*/ #endif #endif /* ORG_FOSSIL_SCM_FSL_CONFDB_H_INCLUDED */ |
︙ | |||
17252 17253 17254 17255 17256 17257 17258 | 18292 18293 18294 18295 18296 18297 18298 18299 18300 18301 18302 18303 18304 18305 18306 18307 | - - + + | #if defined(__cplusplus) } /*extern "C"*/ #endif #endif /* ORG_FOSSIL_SCM_FSL_VPATH_H_INCLUDED */ |
︙ | |||
17432 17433 17434 17435 17436 17437 17438 | 18472 18473 18474 18475 18476 18477 18478 18479 18480 18481 18482 18483 18484 18485 18486 18487 | - + + | */ fsl_uint_t nextAge; /** List of cached content, ordered by age. */ fsl__bccache_line * list; /** |
︙ | |||
17537 17538 17539 17540 17541 17542 17543 | 18578 18579 18580 18581 18582 18583 18584 18585 18586 18587 18588 18589 18590 18591 18592 18593 18594 18595 18596 18597 18598 18599 18600 18601 18602 18603 18604 18605 18606 18607 18608 18609 18610 18611 18612 18613 18614 18615 18616 18617 18618 18619 18620 18621 18622 18623 18624 18625 18626 18627 18628 18629 18630 18631 18632 18633 18634 18635 18636 18637 18638 18639 18640 18641 18642 18643 18644 18645 18646 18647 18648 18649 18650 18651 18652 18653 18654 18655 18656 18657 18658 18659 18660 18661 18662 18663 | - - + + - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - + + + + - - - + - - - + + + + - - - - - - - - - - - - - - - + - - + - + | /* The fsl_cx class is documented in main public header. */ struct fsl_cx { /** A pointer to the "main" db handle. Exactly which db IS the main db is, because we have three DBs, not generally knowble. |
︙ | |||
17634 17635 17636 17637 17638 17639 17640 | 18675 18676 18677 18678 18679 18680 18681 18682 18683 18684 18685 18686 18687 18688 18689 18690 18691 18692 18693 18694 18695 18696 18697 18698 18699 18700 18701 18702 18703 18704 18705 18706 18707 18708 18709 18710 18711 18712 18713 18714 18715 | - + - - - + + + + + - + | /** Holds info directly related to a repo database. */ struct { /** Holds the filename of the current repo db and possibly related |
︙ | |||
17686 17687 17688 17689 17690 17691 17692 17693 17694 17695 17696 17697 17698 17699 | 18729 18730 18731 18732 18733 18734 18735 18736 18737 18738 18739 18740 18741 18742 18743 18744 18745 18746 18747 18748 18749 | + + + + + + + | /** Output channel used by fsl_output() and friends. This was added primarily so that fossil client apps can share a single output channel which the user can swap out, e.g. to direct all output to a UI widget or a file. Though the library has adamantly avoided adding a "warning" output channel, features like: https://fossil-scm.org/home/info/52a389d3dbd4b6cc arguably argue for one. */ fsl_outputer output; /** Can be used to tie client-specific data to the context. Its finalizer is called when fsl_cx_finalize() cleans up. The library does not use this state. It is intended primarily for tying, |
︙ | |||
17710 17711 17712 17713 17714 17715 17716 | 18760 18761 18762 18763 18764 18765 18766 18767 18768 18769 18770 18771 18772 18773 18774 18775 18776 18777 18778 18779 18780 18781 18782 18783 18784 18785 18786 18787 18788 18789 18790 18791 18792 18793 18794 18795 18796 18797 18798 | - - - - - - - - - - - + - + | db-driver-provided error state. It is not used by "simple" routines for which an integer code always suffices. APIs which set this should denote it with a comment like "updates the context's error state on error." */ fsl_error error; |
︙ | |||
17776 17777 17778 17779 17780 17781 17782 | 18816 18817 18818 18819 18820 18821 18822 18823 18824 18825 18826 18827 18828 18829 18830 18831 18832 18833 18834 18835 18836 18837 18838 18839 18840 18841 18842 18843 18844 18845 18846 18847 18848 18849 18850 18851 18852 18853 18854 18855 18856 | - + + + - - - - - - - - + + | flags to the cache member along with the rest of them. */ int flags; /** Error flag which is intended to be set via signal handlers or a UI thread to tell this context to cancel any currently |
︙ | |||
17829 17830 17831 17832 17833 17834 17835 17836 17837 17838 17839 17840 17841 17842 | 18865 18866 18867 18868 18869 18870 18871 18872 18873 18874 18875 18876 18877 18878 18879 18880 18881 18882 18883 18884 18885 | + + + + + + + | /** Is used to tell the content-save internals that a "final verification" (a.k.a. verify-before-commit) is underway. */ bool inFinalVerify; /** Specifies whether SOME repository-level file-name comparisons/searches will work case-insensitively. <0 means not-yet-determined, 0 = no, >0 = yes. */ short caseInsensitive; /** Cached copy of the allow-symlinks config option, because it is (hypothetically) needed on many stat() call. Negative value=="not yet determined", 0==no, positive==yes. The negative value means we need to check the repo config resp. the global config to see if this is on. |
︙ | |||
17855 17856 17857 17858 17859 17860 17861 | 18898 18899 18900 18901 18902 18903 18904 18905 18906 18907 18908 18909 18910 18911 18912 18913 18914 18915 18916 18917 18918 18919 18920 18921 18922 18923 18924 18925 18926 18927 18928 18929 18930 18931 18932 18933 18934 18935 18936 18937 18938 18939 18940 18941 18942 18943 18944 18945 18946 18947 18948 18949 18950 18951 18952 18953 18954 18955 18956 18957 18958 18959 18960 18961 | - + - + + + + + + + + + + + + + + + + + + | /** Indicates whether or not this repo has ever seen a delta manifest. If none has ever been seen then the repository will prefer to use baseline (non-delta) manifests. Once a delta is seen in the repository, the checkin algorithm is free to choose deltas later on unless its otherwise prohibited, e.g. by the |
︙ | |||
17916 17917 17918 17919 17920 17921 17922 | 18976 18977 18978 18979 18980 18981 18982 18983 18984 18985 18986 18987 18988 18989 18990 18991 18992 18993 18994 18995 18996 18997 18998 18999 | - + - - + + | /** Infrastructure for fsl_mtime_of_manifest_file(). It remembers the previous RID so that it knows when it has to invalidate/rebuild its ancestry cache. */ fsl_id_t mtimeManifest; /** |
︙ | |||
17959 17960 17961 17962 17963 17964 17965 17966 17967 17968 17969 17970 17971 17972 | 19019 19020 19021 19022 19023 19024 19025 19026 19027 19028 19029 19030 19031 19032 19033 19034 19035 19036 19037 19038 19039 19040 19041 19042 19043 19044 19045 19046 19047 19048 19049 19050 19051 19052 19053 19054 19055 19056 19057 19058 19059 19060 19061 19062 19063 19064 19065 19066 19067 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | */ fsl_list binary; /** Holds the "crnl-glob" globs. */ fsl_list crnl; } globs; /** Very-frequently-used SQL statements. This are not stored as pointers into the fsl_db_prepare_cached() list because that cache can be invalidated via a db-close. These particular statements are potentially prepared so often that we manage them separate from fsl_db_prepare_cached() as a further optimization. This optimization was single-handedly responsible for cutting f-rebuild's time in less than half. The rest of that time was spent building the SQL strings (indirectly via fsl_appendf()) to figure out if they corresponded to a cached query or not. */ struct { /** Query fetching [delta].[srcid] for a given [delta].[rid]. */ fsl_stmt deltaSrcId; /** Query fetching a [blob].[rid] for an exact-match [blob].[uuid]. */ fsl_stmt uuidToRid; /** Query fetching [blob].[rid] for a [blob].[uuid] prefix. */ fsl_stmt uuidToRidGlob; /** Query fetching [blob].[size] for a [blob].[rid] */ fsl_stmt contentSize; /** Query fetching [blob].[content,size] for a [blob].[rid] */ fsl_stmt contentBlob; /** Placeholder. */ fsl_stmt nextEntry; } stmt; /** Holds a list of temp-dir names. Must be allocated using fsl_temp_dirs_get() and freed using fsl_temp_dirs_free(). */ char **tempDirs; } cache; /** Ticket-related information. */ struct { /** |
︙ | |||
18003 18004 18005 18006 18007 18008 18009 18010 18011 18012 18013 18014 18015 18016 18017 18018 18019 18020 18021 18022 18023 18024 18025 18026 | 19098 19099 19100 19101 19102 19103 19104 19105 19106 19107 19108 19109 19110 19111 19112 19113 19114 19115 19116 19117 19118 19119 19120 19121 19122 19123 19124 19125 19126 19127 19128 19129 19130 19131 19132 19133 19134 19135 19136 19137 19138 19139 19140 19141 19142 19143 19144 19145 19146 19147 19148 19149 19150 19151 19152 19153 19154 19155 19156 19157 19158 19159 19160 19161 19162 19163 19164 19165 19166 19167 19168 19169 19170 19171 19172 19173 19174 19175 19176 19177 19178 19179 19180 19181 19182 19183 19184 19185 19186 19187 19188 19189 19190 19191 19192 19193 19194 19195 19196 19197 19198 19199 19200 19201 19202 19203 19204 19205 19206 19207 19208 19209 19210 19211 19212 | + + + + + + + + + + + - - - + + + + + + + + + + + - - + + + - + + + | */ bool hasChng; /** Gets set to true (at some point) if the client has the ticketchng.rid db field. */ bool hasChngRid; /** The name of the ticket-table field which refers to a ticket's title. Default = "title". The bytes are owned by this object. */ char * titleColumn; /** The name of the ticket-table field which refers to a ticket's status. Default = "status". The bytes are owned by this object. */ char * statusColumn; } ticket; /* Note: no state related to server/user/etc. That is higher-level stuff. We might need to allow the user to set a default user name to avoid that he has to explicitly set it on all of the various Control Artifact-generation bits which need it. */ }; /** @internal Initialized-with-defaults fsl_cx struct. */ #define fsl_cx_empty_m { \ NULL /*dbMain*/, \ NULL/*allocStamp*/, \ |
︙ | |||
18287 18288 18289 18290 18291 18292 18293 | 19404 19405 19406 19407 19408 19409 19410 19411 19412 19413 19414 19415 19416 19417 19418 19419 19420 19421 19422 19423 19424 19425 19426 19427 19428 19429 19430 19431 19432 19433 19434 19435 19436 | - + - - + + | left untouched. Returns 0 if a delta is successfully made or none needs to be made, non-0 on error. @see fsl__content_undeltify() */ |
︙ | |||
18820 18821 18822 18823 18824 18825 18826 | 19937 19938 19939 19940 19941 19942 19943 19944 19945 19946 19947 19948 19949 19950 19951 19952 19953 19954 19955 19956 19957 19958 19959 19960 19961 19962 19963 19964 19965 | + + + + + + + + + + + + + - - + + | operation. It degrades to O(N) if out-of-lexical-order searches are performed. */ fsl_card_F * fsl__deck_F_seek(fsl_deck * const d, const char *zName); /** @internal Ensures that f's single file content buffer is available for use and returns it to the caller. If it appears to already be in use, this function fails fatally via fsl__fatal(), indicating a serious misuse of the internal API. Calling this obligates the caller to call fsl__cx_content_buffer_yield() as soon as they are done with the buffer. */ fsl_buffer * fsl__cx_content_buffer(fsl_cx * const f); /** @internal |
︙ | |||
18848 18849 18850 18851 18852 18853 18854 | 19978 19979 19980 19981 19982 19983 19984 19985 19986 19987 19988 19989 19990 19991 19992 19993 19994 19995 19996 19997 19998 19999 20000 20001 20002 20003 20004 20005 20006 20007 20008 20009 20010 20011 20012 20013 20014 20015 20016 20017 20018 20019 20020 20021 20022 20023 20024 20025 | - - - - - - - - - - - - - - - - - - - - + + - - - + + + + + + + - + - - + | to the db. */ int fsl__search_doc_touch(fsl_cx * const f, fsl_satype_e saType, fsl_id_t rid, const char * docName); /** @internal |
︙ | |||
18918 18919 18920 18921 18922 18923 18924 | 20033 20034 20035 20036 20037 20038 20039 20040 20041 20042 20043 20044 20045 20046 20047 20048 20049 20050 20051 20052 20053 20054 20055 20056 20057 20058 20059 20060 20061 20062 20063 20064 20065 20066 20067 | - + + - + - + | Results are undefined if tgtDir is not an absolute path rooted in f's current checkout. There are any number of valid reasons removal of a directory might fail, and this routine stops at the first one which does. */ |
︙ | |||
19076 19077 19078 19079 19080 19081 19082 | 20192 20193 20194 20195 20196 20197 20198 20199 20200 20201 20202 20203 20204 20205 20206 | - + | 'allow-symlinks' repo-level config setting is true. That said: the addition of symlinks support into fossil was, IMHO, a poor decision for $REASONS. That might (might) be reflected long-term in this API by only supporting them in the way fossil does for platforms which do not support symlinks. */ int fsl__ckout_symlink_create(fsl_cx * const f, char const *zTgtFile, |
︙ | |||
19178 19179 19180 19181 19182 19183 19184 | 20294 20295 20296 20297 20298 20299 20300 20301 20302 20303 20304 20305 20306 20307 20308 | - + | beyond the file size change, is performed. - FSL__LOCALMOD_NOFOUND = file was not found in the local checkout. Noting that: - Combined values of (FSL__LOCALMOD_PERM | FSL__LOCALMOD_CONTENT) are |
︙ | |||
19313 19314 19315 19316 19317 19318 19319 | 20429 20430 20431 20432 20433 20434 20435 20436 20437 20438 20439 20440 20441 20442 20443 20444 20445 20446 20447 20448 20449 20450 20451 20452 20453 20454 20455 20456 20457 20458 20459 20460 20461 20462 20463 20464 20465 20466 20467 20468 20469 20470 20471 20472 20473 20474 20475 20476 20477 20478 20479 20480 20481 20482 20483 20484 20485 20486 | - - - - + + + + + + + + - - - - + + + + - - - - - - - - - + + + + + + + + + + + + + + + - - | @see fsl_ckout_fingerprint_check() */ int fsl__repo_fingerprint_search(fsl_cx * const f, fsl_id_t rcvid, char ** zOut); /** |
︙ | |||
19370 19371 19372 19373 19374 19375 19376 | 20494 20495 20496 20497 20498 20499 20500 20501 20502 20503 20504 20505 20506 20507 20508 20509 20510 20511 20512 20513 20514 20515 20516 20517 20518 20519 20520 20521 20522 20523 20524 20525 20526 20527 20528 20529 | - + - - + - - + - + + + - | Any common text at the beginning and end of the two files is removed before starting the divide-and-conquer algorithm. Returns 0 on succes, FSL_RC_OOM on an allocation error. */ int fsl__diff_all(fsl__diff_cx * const p); |
︙ | |||
19414 19415 19416 19417 19418 19419 19420 19421 19422 19423 19424 19425 19426 19427 19428 | 20537 20538 20539 20540 20541 20542 20543 20544 20545 20546 20547 20548 20549 20550 20551 20552 20553 20554 20555 20556 20557 20558 20559 20560 20561 20562 20563 20564 20565 20566 20567 20568 20569 20570 20571 20572 20573 20574 20575 20576 20577 20578 20579 20580 20581 20582 20583 20584 20585 20586 20587 20588 20589 20590 20591 20592 20593 20594 20595 20596 20597 20598 20599 20600 20601 20602 20603 20604 20605 20606 20607 20608 20609 20610 20611 20612 20613 20614 20615 20616 20617 20618 20619 20620 20621 20622 20623 20624 20625 20626 20627 20628 20629 20630 20631 20632 20633 20634 20635 20636 20637 20638 20639 20640 20641 20642 20643 20644 20645 20646 20647 20648 20649 20650 20651 20652 20653 20654 20655 20656 20657 20658 20659 20660 20661 20662 20663 20664 20665 20666 20667 20668 20669 20670 20671 20672 20673 20674 20675 20676 20677 20678 20679 20680 20681 20682 20683 20684 20685 20686 20687 20688 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + | As a special case, if role==0 then ALL cached statements are closed, with the caveat that the process will still fail if any statement is currently flagged as active. */ int fsl__db_cached_clear_role(fsl_db * const db, int role); /** @internal Part of the crosslinking bits: rebuilds the entry for the ticket with the given K-card value. */ int fsl__ticket_rebuild(fsl_cx * const f, char const * zTktId); /** @internal Calls all registered crosslink link listeners, passing each the given deck. Returns 0 if there are no listeners or if all return 0, else it propagates an error from a failed listener. This must only be called while crosslinking is underway. @see fsl_xlink_listener() */ int fsl__call_xlink_listeners(fsl_deck * const d); /** @internal Copies symlink zFrom to a new symlink or pseudo-symlink named zTo. If realLink is true and this is a non-Windows platform, symlink zFrom is copied to zTo. If realLink is false or this is a Windows platform them... - On Windows this has currently undesired, or at least, highly arguable, behavior (historical, inherited from fossil(1)), in that an empty file named zTo will be created. In fossil(1) this function's counterpart is (apparently) never called on Windows, so that behavior seems to be moot. It is, however, important that this library never call it on Windows. - On non-Windows, a pseudo-symlink will be created: the string zFrom will be written to a regular file named zTo. That is, the file zTo will hold, as its contents, what it would point to if it were a symlink. */ int fsl__symlink_copy(char const *zFrom, char const *zTo, bool realLink); /** @internal Clears the contents of f->cache.mcache. */ void fsl__cx_mcache_clear(fsl_cx * const f); /** @internal Translates sqliteCode (or, if it's 0, sqlite3_errcode()) to an approximate FSL_RC_xxx match but treats SQLITE_ROW and SQLITE_DONE as non-errors (result code 0). If non-0 is returned db's error state is updated with the current sqlite3_errmsg() string. */ int fsl__db_errcode(fsl_db * const db, int sqliteCode); /** @internal Clears various internal caches and resets various internally-cached values related to a repository db, but the data cleared here are not associated directly with a db handle. This is intended primarily to be used when a db transaction is rolled back which might have introduced state into those caches which would be stale after a rollback. */ void fsl__cx_clear_repo_caches(fsl_cx * const f); /** @internal Plug in fsl_cx-specific db functionality into the given db handle. This must only be passed the MAIN db handle for the context, immediately after opening that handle, before f->dbMain is assigned. This function has very limited applicability and various preconditions which are assert()ed. */ int fsl__cx_init_db(fsl_cx * const f, fsl_db * const db); /** @internal Attaches the given db file to f with the given role. This function "should" be static but we need it in repo.c when creating a new repository. This function has tightly-controlled preconditions which will assert if not met. r must be one of FSL_DBROLE_CKOUT or FSL_DBROLE_REPO. If createIfNotExists is true and zDbName does not exist in the filesystem, it is created before/as part of the OPEN or ATTACH. This is almost never desired, but is required for operations which create a repo (e.g. the aptly-named fsl_repo_create()) or a checkout db (e.g. fsl_repo_open_ckout()). */ int fsl__cx_attach_role(fsl_cx * const f, const char *zDbName, fsl_dbrole_e r, bool createIfNotExists); /** @internal Returns one of f->{repo,ckout}.db or NULL. ACHTUNG and REMINDER TO SELF: the current (2021-03) design means that none of these handles except for FSL_DBROLE_MAIN actually has an sqlite3 db handle assigned to it. This returns a handle to the "level of abstraction" we need to keep track of each db's name and db-specific other state. e.g. passing a role of FSL_DBROLE_CKOUT this does NOT return the same thing as fsl_cx_db_ckout(). */ fsl_db * fsl__cx_db_for_role(fsl_cx * const f, fsl_dbrole_e r); /** @internal Frees/clears the non-db state of f->ckout. */ void fsl__cx_ckout_clear(fsl_cx * const f); /** @internal Maximum length of a line in a text file, in bytes. (2**15 = 32k) */ #define FSL__LINE_LENGTH_MASK_SZ 15 /** @internal Bitmask which, when AND-ed with a number, will result in the bottom FSL__LINE_LENGTH_MASK_SZ bits of that number. |
︙ | |||
19479 19480 19481 19482 19483 19484 19485 | 20722 20723 20724 20725 20726 20727 20728 20729 20730 20731 20732 20733 20734 20735 20736 20737 20738 20739 20740 20741 20742 20743 20744 20745 20746 20747 20748 20749 20750 20751 20752 20753 20754 20755 20756 20757 20758 20759 20760 20761 20762 20763 20764 20765 20766 20767 20768 20769 20770 20771 20772 20773 20774 20775 20776 20777 20778 20779 20780 20781 20782 20783 20784 20785 20786 20787 20788 20789 20790 20791 20792 20793 20794 20795 20796 20797 20798 20799 20800 20801 20802 | - + - + - + - + - + - - + + | returns a copy of zPw) if the project code is not set, under the assumption that this is "the first xfer request of a clone." Whether or not that will apply at this level to libfossil remains to be seen. TODO? Does fossil still use SHA1 for this? */ |
︙ | |||
19585 19586 19587 19588 19589 19590 19591 | 20828 20829 20830 20831 20832 20833 20834 20835 20836 20837 20838 20839 20840 20841 20842 20843 | - - + + | #if defined(__cplusplus) } /*extern "C"*/ #endif #endif /* ORG_FOSSIL_SCM_FSL_FORUM_H_INCLUDED */ |
︙ | |||
20092 20093 20094 20095 20096 20097 20098 | 21335 21336 21337 21338 21339 21340 21341 21342 21343 21344 21345 21346 21347 21348 21349 | - + | ``` */ /** @page page_code_conventions Code Conventions Project and Code Conventions... |
︙ | |||
20133 20134 20135 20136 20137 20138 20139 20140 20141 20142 20143 20144 20145 20146 20147 | 21376 21377 21378 21379 21380 21381 21382 21383 21384 21385 21386 21387 21388 21389 21390 21391 21392 21393 21394 21395 21396 21397 21398 21399 21400 21401 21402 21403 21404 21405 21406 21407 21408 21409 21410 21411 21412 21413 21414 21415 21416 21417 21418 21419 21420 21421 21422 21423 21424 21425 21426 21427 21428 21429 21430 21431 21432 21433 21434 21435 21436 21437 21438 21439 21440 21441 21442 21443 21444 21445 21446 21447 21448 21449 21450 21451 21452 21453 21454 21455 21456 21457 21458 21459 21460 21461 21462 21463 21464 | + + + + + + + + - + + - + - - + + - - + + - + + - - + + - - - - - - + + + + + | for fun). - Public API members have a fsl_ or FSL_ prefix (fossil_ seems too long). For private/static members, anything goes. Optional or "add-on" APIs (e.g. ::fcli) may use other prefixes, but are encouraged use an "f-word" (as it were), simply out of deference to long-standing software naming conventions. - Internal APIs, especially non-static ones, start with `fsl__` or `FSL__`, with two underscores. Such APIs must never be used in client-side code. - Public-API structs and functions use lower_underscore_style(). Static/internal APIs may use different styles. It's not uncommon to see UpperCamelCase for file-scope structs. - Function parameters and function-scope vars have no set conventions - implementors are free to name those however they like. - Overall style, especially scope blocks and indentation, should follow Fossil's. We are _not at all_ picky about whether or not there is a space after/before parens in if( foo ), and similar |
︙ | |||
20325 20326 20327 20328 20329 20330 20331 | 21577 21578 21579 21580 21581 21582 21583 21584 21585 21586 21587 21588 21589 21590 21591 21592 21593 21594 21595 21596 21597 21598 21599 21600 21601 21602 21603 21604 21605 21606 21607 21608 21609 21610 21611 21612 21613 21614 | - - + + - - - - - - + | executable bit and only does anything useful on platforms which support symlinks. */ #endif /* ORG_FOSSIL_SCM_PAGES_H_INCLUDED */ |
︙ | |||
20776 20777 20778 20779 20780 20781 20782 | 22023 22024 22025 22026 22027 22028 22029 22030 22031 22032 22033 22034 22035 22036 22037 | - + | If not NULL then fcli_setup() will attempt to open the checkout for the given dir, including its associated repo db. By default this is "." (the current directory). Applications can set this to NULL _before_ calling fcli_setup() in order to disable the automatic attemp to open a checkout under the current directory. Doing so is |
︙ | |||
20799 20800 20801 20802 20803 20804 20805 | 22046 22047 22048 22049 22050 22051 22052 22053 22054 22055 22056 22057 22058 22059 22060 | - + | */ struct { /** repo db name string from -R/--repo CLI flag. */ const char * repoDbArg; /** |
︙ | |||
20855 20856 20857 20858 20859 20860 20861 | 22102 22103 22104 22105 22106 22107 22108 22109 22110 22111 22112 22113 22114 22115 22116 22117 22118 22119 22120 22121 22122 22123 22124 22125 22126 22127 22128 22129 22130 22131 22132 22133 22134 22135 22136 22137 22138 22139 22140 22141 22142 22143 22144 22145 22146 | - - - - - - - - - - - + - + + - - - - - + + + + + + + | fcli_cx() returns the API's fsl_cx instance. It will be non-NULL (but might not have an opened checkout/repository) if fsl_setup() succeeds. */ FSL_EXPORT fcli_t fcli; |
︙ | |||
21230 21231 21232 21233 21234 21235 21236 21237 | 22470 22471 22472 22473 22474 22475 22476 22477 22478 22479 22480 22481 22482 22483 22484 22485 22486 22487 22488 22489 22490 22491 | + + + + + + - + | complex values like multi-dimensional arrays. "fax" is short for "free at exit." Results are undefined if the same address or overlapping addresses are queued more than once. Once an entry is in this queue, there is no way to remove it. Returns its argument so that it can be used like: ``` char * x = fcli_fax( fsl_strdup("...") ); ``` */ |
︙ | |||
21377 21378 21379 21380 21381 21382 21383 | 22623 22624 22625 22626 22627 22628 22629 22630 22631 22632 22633 22634 22635 22636 22637 22638 22639 22640 22641 22642 22643 22644 | - - - + + + - + + | Returns 0 on success. If there are no more CLI arguments when it is called then it returns FSL_RC_MISUSE and updates the fcli error state with a description of the problem. It may return any number of non-0 codes from the underlying operations. Sidebar: fsl_filename_to_vfile_ids() requires that directory names |
︙ | |||
21426 21427 21428 21429 21430 21431 21432 | 22673 22674 22675 22676 22677 22678 22679 22680 22681 22682 22683 22684 22685 22686 22687 22688 22689 22690 | - + - + | */ FCLI_DIFF_COLORS_RG, FCLI_DIFF_COLORS_DEFAULT = FCLI_DIFF_COLORS_RG }; typedef enum fcli_diff_colors_e fcli_diff_colors_e; /** |
︙ | |||
21461 21462 21463 21464 21465 21466 21467 | 22708 22709 22710 22711 22712 22713 22714 22715 22716 22717 22718 22719 22720 22721 22722 22723 22724 22725 22726 22727 22728 22729 22730 22731 22732 22733 22734 22735 22736 22737 22738 22739 22740 22741 22742 22743 22744 22745 22746 22747 22748 22749 22750 22751 22752 22753 22754 22755 22756 22757 22758 22759 22760 22761 22762 22763 22764 22765 22766 22767 22768 22769 22770 22771 22772 22773 22774 22775 22776 22777 22778 22779 22780 22781 22782 22783 22784 22785 22786 22787 22788 22789 22790 22791 22792 22793 22794 22795 22796 22797 22798 22799 22800 22801 22802 22803 22804 22805 22806 22807 22808 22809 22810 22811 22812 22813 22814 22815 22816 22817 22818 22819 22820 22821 22822 22823 22824 22825 22826 22827 22828 22829 22830 22831 22832 22833 22834 22835 22836 22837 22838 22839 22840 22841 22842 22843 22844 22845 22846 22847 22848 22849 22850 22851 22852 22853 22854 22855 22856 22857 22858 22859 22860 22861 22862 22863 22864 22865 22866 22867 22868 22869 22870 22871 22872 22873 22874 22875 22876 22877 22878 22879 22880 22881 22882 22883 22884 22885 22886 22887 22888 22889 22890 22891 22892 22893 22894 22895 22896 22897 22898 22899 22900 22901 22902 22903 22904 22905 22906 22907 22908 22909 22910 22911 22912 22913 22914 22915 22916 22917 22918 22919 22920 22921 22922 22923 22924 22925 22926 22927 22928 22929 22930 22931 22932 22933 22934 22935 22936 22937 22938 22939 22940 22941 22942 22943 22944 22945 22946 22947 22948 22949 22950 22951 22952 22953 22954 22955 22956 22957 22958 22959 22960 22961 22962 22963 22964 22965 22966 22967 22968 | - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | #if defined(__cplusplus) } /*extern "C"*/ #endif #endif /* _ORG_FOSSIL_SCM_FCLI_H_INCLUDED_ */ |
Deleted signify/fnc-05-release.pub.
| - - |
|
Added signify/fnc-07-release.pub.
|
Changes to src/fnc.1.
1 | 1 2 3 4 5 6 7 8 9 | - + | .\" |
︙ | |||
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 | 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 69 70 71 72 73 74 75 76 77 78 79 80 81 | + + + + + + + + + + + - - - - - | .Nm .Op Ar command .Op Fl h | -help .Nm .Op Fl h | -help .Op Fl v | -version .Nm .Cm config .Op Fl hu .Op Fl -ls .Op Fl R Ar path .Op Ar setting Op Ar value .Nm .Cm timeline .Op Fl Cz .Op Fl b Ar branch .Op Fl c Ar commit .Op Fl f Ar glob .Op Fl n Ar number .Op Fl R Ar path .Op Fl T Ar tag .Op Fl t Ar type .Op Fl u Ar user .Op Ar path .Nm .Cm diff .Op Fl Ciw .Op Fl R Ar path .Op Fl x Ar number .Op Ar artifact1 Op Ar artifact2 .Op Ar path ... .Nm .Cm tree .Op Fl C .Op Fl c Ar commit .Op Fl R Ar path .Op Ar path .Nm .Cm blame .Op Fl C .Op Fl c Ar commit Op Fl r .Op Fl n Ar number .Op Fl R Ar path .Ar path .Nm .Cm branch .Op Fl Ccopr .Op Fl a Ar date | Fl b Ar date .Op Fl R Ar path .Op Fl s Ar order .Op Ar glob .Nm |
︙ | |||
98 99 100 101 102 103 104 | 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 | - + - + + + + + + + + | version that last modified the line. .It Branch view Display navigable list of all repository branches. .El .Pp .Nm provides both global and command-specific options and in-app key |
︙ | |||
134 135 136 137 138 139 140 | 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | - + - + - + + + + + + + + + + + + + + + + - + + + - - + + - + + + + + + | .El .Pp Commands available to .Nm are as follows: .Bl -tag -width 4v .Tg conf |
︙ | |||
223 224 225 226 227 228 229 | 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | - + - - - + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + | will open the timeline to the latest leaf on the repository tree. For a complete list of valid arguments this option accepts, see .Lk https://fossil-scm.org/home/doc/trunk/www/checkin_names.wiki \ "Fossil's Check-in Names". .It Fl f , -filter Ar glob Filter timeline by commits containing .Ar glob |
︙ | |||
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | 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 361 362 363 364 365 366 367 368 369 370 371 372 373 | + + + + - + - + + + + + | .Nm .Cm timeline .Cm -t e -t t Ns ). .It Fl u , -username Ar user Only display commits authored by .Ar user . The search is case-insensitive by default unless .Ar user contains at least one uppercase character, in which case the search will be case-sensitive. .It Fl z , -utc Use Coordinated Universal Time (UTC) rather than local time when displaying commit dates and timestamps. .El .Pp Key bindings for .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 C-f, Page-down |
︙ | |||
334 335 336 337 338 339 340 | 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 | - - + + | the timeline is consumed. .It Cm N Find the previous commit that matches the current search term. The search will continue until either a match is found or the latest commit on the timeline is consumed. .El .Tg di |
︙ | |||
366 367 368 369 370 371 372 | 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 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 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 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 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 | - + + + + + + + + + + + + + + + + + + + + + + + + + - + - + + + + + + + + + + + + + + + + + + + + + - + - + + + + + + + + + + + - + - - + + + + | .Ar artifact1 and .Ar artifact2 must be of the same type, which is expected to be either a symbolic check-in name, tag, (unique abbreviated prefix of) a commit or blob artifact UUID SHA1 or SHA3 hash, or an ISO 8601 formatted date. Both artifact arguments must be supplied when diffing blobs; any following non-option arguments are invalid |
︙ | |||
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 | 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 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 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 | + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + - - - + - - + + + + | to the latest commit on the given branch, or (a unique abbreviated prefix of) a valid commit UUID SHA1 or SHA3 hash. For a complete list of valid arguments this option accepts, see .Lk https://fossil-scm.org/home/doc/trunk/www/checkin_names.wiki \ "Fossil's Check-in Names". .It Fl h , -help Display tree command help and usage information then exit. .It Fl R , -repo Ar path Use the .Xr fossil 1 repository database at the specified .Ar path for the current .Cm fnc tree invocation. When this option is used, the checkout-related Fossil special tags .Qq current , .Qq prev , and .Qq next are invalid arguments to the .Sy --commit option. .El .Pp Key bindings for .Cm fnc tree are as follows: .Bl -tag -width Ds .It Cm Enter, Arrow-right, l Enter the currently selected directory, or open a .Cm blame view of the currently selected file. .It Cm Backspace, Arrow-left, h Move up a level to the parent directory. This is a no-op when in the root tree. .It Cm Arrow-down, j Move selection cursor one node down the tree. .It Cm Arrow-up, k Move selection cursor one node up the tree. .It Cm C-f, Page-down Scroll tree view one page downwards in the buffer. .It Cm C-b, Page-up Scroll tree view one page upwards in the buffer. |
︙ | |||
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 | 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 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 | + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - - - - + + + + - + - - - - - + + + + + + + - - - - + + | .Nm will traverse either as many commits as specified, or as possible in the specified time limit. By default, .Nm will traverse the entire historical record of the file, which can be expensive for large files that span many commits. Use this option for a faster, more targeted annotation. .It Fl R , -repo Ar path Use the .Xr fossil 1 repository database at the specified .Ar path for the current .Cm fnc blame invocation. When this option is used, the checkout-related Fossil special tags .Qq current , .Qq prev , and .Qq next are invalid arguments to the .Sy --commit option. When .Sy --commit is not specified, .Nm will default to blaming the version of the file found in the latest commit. .It Fl r , -reverse Reverse annotate the file starting from a historical commit and move forward in time. That is, rather than show the most recent change to each line, show the first time each line was modified by a subsequent commit after the specified .Ar commit . (Requires \fB\-c\fP|\fB\-\-commit\fP.) .El .Pp Key bindings for .Cm fnc blame are as follows: .Bl -tag -width Ds .It Cm Arrow-down, j Move selection cursor down one line. .It Cm Arrow-up, k Move selection cursor up one line. .It Cm Arrow-right, l Scroll the view two columns to the right in the buffer. File output moves left on the screen. .It Cm Arrow-left, h Scroll the view two columns to the left in the buffer. File output moves right on the screen. |
︙ | |||
692 693 694 695 696 697 698 | 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 | - + + + + + + + + + + - + + + + + + + + + + + + + + + + + + | .Pp Options for .Cm fnc branch are as follows: .Bl -tag -width Ds .It Fl a , -after Ar date Display only those branches with activity after the specified |
︙ | |||
737 738 739 740 741 742 743 | 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 | + + + + - + - - + + - + + + + + + + | .Cm fnc branch are as follows: .Bl -tag -width Ds .It Cm Arrow-down, j Move selection cursor down one branch. .It Cm Arrow-up, k Move selection cursor up one branch. .It Cm C-f, Page-down Scroll branch view one page downwards in the buffer. .It Cm C-b, Page-up Scroll branch view one page upwards in the buffer. |
︙ | |||
779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 | 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 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 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 1078 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - - + + | .It Cm n Find the next branch that matches the current search pattern. .It Cm N Find the previous branch that matches the current search pattern. .El .El .Sh ENVIRONMENT Depending on the available screen estate determined by the LINES and COLUMNS environment variables, .Nm will display child views in either a horizontal or vertical split. By default, if COLUMNS is \(>= 120, a child view will open in a vertical split at least 80 columns wide. Otherwise, the child view will open in a horizontal split that is approximately 60% of the terminal height. This behaviour can be customised by configuring the following options as either exported environment variables or with .Nm Cm config as documented above. .Bl -tag -width FNC_VIEW_SPLIT_HEIGHT .It Ev FNC_VIEW_SPLIT_MODE Open child views in a horizontal or vertical split. Value can be one of .Sy auto , .Sy horizontal , or .Sy vertical . Default: .Qq auto . .It Ev FNC_VIEW_SPLIT_HEIGHT Height of the child view when opening in a horizontal split. Valid numeric values are 1 \(<= .Sy n < LINES. Percentage values denoted with a postfixed .Sq % .Po e.g., .Sy 55% .Pc are also valid. Default: .Qq 60% . .It Ev FNC_VIEW_SPLIT_WIDTH Minimum width of the child view when opening in a vertical split. Currently a no-op. Default: .Qq 80 . .El .Pp .Nm displays coloured output by default in supported terminals. Each colour object identified below can be defined by either exporting environment variables .Po e.g., .Cm export FNC_COLOUR_COMMIT=red .Pc , or with .Nm Cm config as documented above. At startup, .Nm will search for user-defined colours in the following order: .Bl -column " environment variables " description -offset Ds .It 1. repository settings Ta Pa repo.fossil .It 3. environment variables Ta Sy shell .El .Pp If none are found, the default colour scheme will be displayed. This enables setting per-project colours to visually distinguish the current repository being viewed, and globally changing the colour scheme for all repositories with |
︙ | |||
834 835 836 837 838 839 840 | 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 | - + | .Qq magenta . .It Ev FNC_COLOUR_DIFF_PLUS Added lines displayed in the diff view. If not defined, the default value is .Qq cyan . .It Ev FNC_COLOUR_DIFF_CHUNK Chunk header lines .Po e.g., |
︙ | |||
871 872 873 874 875 876 877 878 879 880 881 882 883 884 | 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 | + + + + + + + + + + + + | .It Ev FNC_COLOUR_BRANCH_CURRENT The branch corresponding to the current checkout displayed in the branch view. If not defined, the default value is .Qq green . .It Ev FNC_COLOUR_BRANCH_PRIVATE Private branches displayed in the branch view. If not defined, the default value is .Qq yellow . .It Ev FNC_COLOUR_HL_LINE Selected line highlight in the diff view. Value can be one of .Sy auto or .Sy mono . The former will invert the foreground colour of the selected line, while the latter will use a monochromatic highlight. If not defined, the default value is .Qq auto . .It Ev FNC_COLOUR_HL_SEARCH Search term highlight in blame and diff view. If not defined, the default value is .Qq yellow . .El .Pp To clear environment variables, issue .Cm unset Ar ENVIRONMENT_VARIABLE in the shell. .Sh EXIT STATUS |
︙ |
Changes to src/fnc.c.
1 | 1 2 3 4 5 6 7 8 9 | - + | /* |
︙ | |||
31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | + + + | # endif # if !defined(_DEFAULT_SOURCE) # define _DEFAULT_SOURCE /* Needed for strsep() on glibc >= 2.19. */ # endif #endif #ifdef FCLI_USE_SIGACTION #define FCLI_USE_SIGACTION 0 /* We want C-c to exit. */ #endif #include <sys/queue.h> #include <sys/ioctl.h> #include <sys/stat.h> #ifdef _WIN32 #include <windows.h> |
︙ | |||
67 68 69 70 71 72 73 | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | - - + + + + - - + + + + + - - + + | #include "libfossil.h" #include "settings.h" #define FNC_VERSION VERSION /* cf. Makefile */ /* Utility macros. */ |
︙ | |||
172 173 174 175 176 177 178 | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | - + | /* Timeline options. */ struct artifact_types { const char **values; short nitems; } filter_types; /* Only load commits of <type>. */ union { const char *zlimit; |
︙ | |||
204 205 206 207 208 209 210 | 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | - - - - - - + + + + + + | 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. */ fcli_command cmd_args[7]; /* App commands. */ |
︙ | |||
276 277 278 279 280 281 282 283 284 285 286 | 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | + + - - - - + + + + + | {"config", "conf\0cfg\0settings\0set\0", "Configure or view currently available settings.", cmd_config, usage_config, fnc_init.cliflags_config}, {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, "Disable colourised timeline, which is enabled by default on\n " "supported terminals. Colour can also be toggled with the 'c' " "\n key binding in timeline view when this option is not used."), |
︙ | |||
335 336 337 338 339 340 341 342 343 344 345 346 347 348 | 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | + + + | 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("q", "quiet", &fnc_init.quiet, "Disable verbose diff output; that is, do not output complete" " content\n of newly added or deleted files. Verbosity can also" " be toggled with\n the 'v' key binding in diff view."), FCLI_FLAG_CSTR("R", "repo", "<path>", NULL, "Use the fossil(1) repository located at <path> for this diff\n " "invocation."), FCLI_FLAG_BOOL("w", "whitespace", &fnc_init.ws, "Ignore whitespace-only changes when displaying diff. This option " "can\n also be toggled with the 'w' key binding in diff view."), 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 |
︙ | |||
364 365 366 367 368 369 370 371 372 373 374 375 376 377 | 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | + + + | "\tISO8601 date\n" "\tISO8601 timestamp\n" "\t{tip,current,prev,next}\n " "For a complete list of symbols see Fossil's Check-in Names:\n " "https://fossil-scm.org/home/doc/trunk/www/checkin_names.wiki"), FCLI_FLAG_BOOL("h", "help", NULL, "Display tree command help and usage."), FCLI_FLAG_CSTR("R", "repo", "<path>", NULL, "Use the fossil(1) repository located at <path> for this tree\n " "invocation."), fcli_cliflag_empty_m }, /* End cliflags_tree. */ { /* cliflags_blame blame command related options. */ FCLI_FLAG_BOOL("C", "no-colour", &fnc_init.nocolour, "Disable coloured output, which is enabled by default on supported" "\n terminals. Colour can also be toggled with the 'c' key " |
︙ | |||
391 392 393 394 395 396 397 398 399 400 401 402 403 404 | 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | + + + | FCLI_FLAG_BOOL("h", "help", NULL, "Display blame command help and usage."), FCLI_FLAG("n", "limit", "<n>", &fnc_init.nrecords.zlimit, "Limit depth of blame history to <n> commits or seconds. Denote the" "\n latter by postfixing 's' (e.g., 30s). Useful for large files" " with\n extensive history. Persists for the duration of the " "session."), FCLI_FLAG_CSTR("R", "repo", "<path>", NULL, "Use the fossil(1) repository located at <path> for this blame\n" " invocation."), FCLI_FLAG_BOOL("r", "reverse", &fnc_init.reverse, "Reverse annotate the file starting from a historical commit. " "Rather\n than show the most recent change of each line, show " "the first time\n each line was modified after the specified " "commit. Requires -c|--commit."), fcli_cliflag_empty_m }, /* End cliflags_blame. */ |
︙ | |||
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | 443 444 445 446 447 448 449 450 451 452 453 454 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 480 481 482 483 484 485 486 487 | + + + + + + + | "Display branch command help and usage."), FCLI_FLAG_BOOL("o", "open", &fnc_init.open, "Show open branches only. Open and closed branches are listed by " "\n default."), FCLI_FLAG_BOOL("p", "no-private", &fnc_init.noprivate, "Do not show private branches, which are otherwise included in the" "\n list of displayed branches by default."), FCLI_FLAG_CSTR("R", "repo", "<path>", NULL, "Use the fossil(1) repository located at <path> for this branch\n" " invocation."), FCLI_FLAG_BOOL("r", "reverse", &fnc_init.reverse, "Reverse the order in which branches are displayed."), FCLI_FLAG("s", "sort", "<order>", &fnc_init.sort, "Sort branches by <order>. Available options are:\n" "\tmru - most recently used\n" "\tstate - open/closed state\n " "Branches are sorted in lexicographical order by default."), fcli_cliflag_empty_m }, /* End cliflags_blame. */ { /* cliflags_config config command related options. */ FCLI_FLAG_BOOL("h", "help", NULL, "Display config command help and usage."), FCLI_FLAG_BOOL(NULL, "ls", &fnc_init.lsconf, "Display a list of all currently defined settings."), FCLI_FLAG_CSTR("R", "repo", "<path>", NULL, "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. */ }; enum date_string { ISO8601_DATE_ONLY = 10, ISO8601_DATE_HHMM = 16, ISO8601_TIMESTAMP = 20 }; enum fnc_view_id { FNC_VIEW_TIMELINE, FNC_VIEW_DIFF, FNC_VIEW_TREE, |
︙ | |||
472 473 474 475 476 477 478 | 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 | - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + | SEARCH_WAITING, SEARCH_CONTINUE, SEARCH_COMPLETE, SEARCH_NO_MATCH, SEARCH_FOR_END }; |
︙ | |||
618 619 620 621 622 623 624 | 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 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 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 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 | - - + + + - + + + + + + + + + + + + + - + + + + + + | int ncommits_needed; /* * XXX Is there a more elegant solution to retrieving return codes from * thread functions while pinging between, but before we join, threads? */ int rc; bool endjmp; |
︙ | |||
751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 | + + + | fsl_uuid_str commit_id; char *path; int first_line_onscreen; int last_line_onscreen; int selected_line; int matched_line; int spin_idx; int gtl; uint32_t *maxx; bool done; bool blame_complete; bool eof; bool colour; bool showln; }; struct fnc_branch { char *name; char *date; fsl_uuid_str id; bool private; |
︙ | |||
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 | 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 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 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 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 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 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 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 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 | + + + + + + + + + + + + + + + + - - + + - - + + - - + + + - + + + + + + + + + + + + + + + + - + - - + - + - + - - + - - - - + + + + + + + - - - + + + - - - - + + + + + - - + + + + + + - + - + - + - + + + - + - + - - - - + - - + + + - - + + + + + - + + + + + + + + + + - + - - + - + + - - - + + + | int ndisplayed; int selected; int when; bool colour; bool show_date; bool show_id; }; struct line { char buf[BUFSIZ]; int sz; enum line_type type; bool selected; }; struct position { int col; int line; int offset; }; TAILQ_HEAD(view_tailhead, fnc_view); struct fnc_view { TAILQ_ENTRY(fnc_view) entries; WINDOW *window; PANEL *panel; struct fnc_view *parent; struct fnc_view *child; struct line line; struct position pos; union { struct fnc_diff_view_state diff; struct fnc_tl_view_state timeline; struct fnc_tree_view_state tree; struct fnc_blame_view_state blame; struct fnc_branch_view_state branch; } state; enum fnc_view_id vid; enum view_mode mode; enum fnc_search_state search_status; enum fnc_search_mvmnt searching; |
︙ | |||
1073 1074 1075 1076 1077 1078 1079 | 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 | - - + + - + + + + + + + + + + + + | if (!setlocale(LC_CTYPE, "")) fsl_fprintf(stderr, "[!] Warning: Can't set locale.\n"); fnc_init.cmdarg = argv[1]; /* Which cmd to show usage if needed. */ #if DEBUG fcli.clientFlags.verbose = 2; /* Verbose error reporting. */ #endif |
︙ | |||
1178 1179 1180 1181 1182 1183 1184 | 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 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 | - + - - + + + + + - - + + + + - + - - + + + + + + + + + + + + + + + + + | fnc_init.sym); } if (fnc_init.glob) glob = fsl_strdup(fnc_init.glob); if (fnc_init.path) path = fsl_strdup(fnc_init.path); |
︙ | |||
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 | 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 | + + + + + + + - + | { initscr(); cbreak(); noecho(); nonl(); intrflush(stdscr, FALSE); keypad(stdscr, TRUE); raw(); /* Don't signal control characters, specifically C-y */ curs_set(0); set_escdelay(0); /* ESC should return immediately. */ #ifndef __linux__ typeahead(-1); /* Don't disrupt screen update operations. */ #endif if (!fnc_init.nocolour && has_colors()) { start_color(); use_default_colors(); } return fnc_set_signals(); } 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), "%s", "sigaction(SIGPIPE)"); if (sigaction(SIGWINCH, &(struct sigaction){{sigwinch_handler}}, NULL) == -1) return RC(fsl_errno_to_rc(errno, FSL_RC_ERROR), "%s", "sigaction(SIGWINCH)"); if (sigaction(SIGCONT, &(struct sigaction){{sigcont_handler}}, NULL) == -1) return RC(fsl_errno_to_rc(errno, FSL_RC_ERROR), "%s", "sigaction(SIGCONT)"); |
︙ | |||
1511 1512 1513 1514 1515 1516 1517 1518 | 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 | + - + - - | const char *glob) { struct fnc_tl_view_state *s = &view->state.timeline; fsl_cx *const f = fcli_cx(); fsl_db *db = fsl_cx_db_repo(f); fsl_buffer sql = fsl_buffer_empty; char *startdate = NULL; char *op = NULL, *str = NULL; fsl_id_t idtag = 0; |
︙ | |||
1612 1613 1614 1615 1616 1617 1618 1619 | 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 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 | + + + + - + - - - + + + + + - - + + + + + + + - - + + - - - - + + + + + + - - + + - - - + + + + + + + - - - + + + + + - + + + - + - + - - - + + + - - + | for (idx = 0; idx < fnc_init.filter_types.nitems; ++idx) fsl_buffer_appendf(&sql, " eventtype=%Q%s", fnc_init.filter_types.values[idx], (idx + 1) < fnc_init.filter_types.nitems ? " OR " : ")"); } if (fnc_init.filter_branch) { rc = fnc_make_sql_glob(&op, &str, fnc_init.filter_branch, !fnc_str_has_upper(fnc_init.filter_branch)); if (rc) goto end; idtag = fsl_db_g_id(db, 0, |
︙ | |||
1710 1711 1712 1713 1714 1715 1716 | 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 | - - + + | if (fnc_init.nrecords.limit > 0) fsl_buffer_appendf(&sql, " LIMIT %d", fnc_init.nrecords.limit); view->show = show_timeline_view; view->input = tl_input_handler; view->close = close_timeline_view; |
︙ | |||
1738 1739 1740 1741 1742 1743 1744 | 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 | - + - + + + + - + + + | s->colour = !fnc_init.nocolour && has_colors(); s->thread_cx.rc = 0; s->thread_cx.db = db; s->thread_cx.spin_idx = 0; s->thread_cx.ncommits_needed = view->nlines - 1; s->thread_cx.commits = &s->commits; |
︙ | |||
1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 | 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 | + + + + + | prev = TAILQ_PREV(view, view_tailhead, entries); else if (view->parent) 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; rc = view_resize(view->parent, VIEW_SPLIT_NONE); if (rc) goto end; } else TAILQ_REMOVE(&views, view, entries); rc = view_close(view); if (rc) goto end; |
︙ | |||
1860 1861 1862 1863 1864 1865 1866 | 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 | - - - + - - + - - - - | goto end; } rc = view->show(view); if (rc) goto end; if (view->child) { rc = view->child->show(view->child); |
︙ | |||
1973 1974 1975 1976 1977 1978 1979 | 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 | - + - + | } if ((rc = pthread_mutex_unlock(&fnc_mutex))) rc = RC(fsl_errno_to_rc(rc, FSL_RC_ACCESS), "%s", "pthread_mutex_unlock"); } |
︙ | |||
2003 2004 2005 2006 2007 2008 2009 | 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 | - + - + - - - - - + + + + - + | return RC(fsl_errno_to_rc(errno, FSL_RC_MISUSE), "%s", "sigaddset"); if (pthread_sigmask(SIG_BLOCK, &set, NULL)) return RC(fsl_errno_to_rc(errno, FSL_RC_MISUSE), "%s", "pthread_sigmask"); |
︙ | |||
2210 2211 2212 2213 2214 2215 2216 | 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 | - + | static int signal_tl_thread(struct fnc_view *view, int wait) { struct fnc_tl_thread_cx *cx = &view->state.timeline.thread_cx; int rc = 0; while (cx->ncommits_needed > 0) { |
︙ | |||
2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 | 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 | + - + | struct commit_entry *entry = s->selected_commit; struct fnc_colour *c = NULL; const char *search_str = NULL; char *headln = NULL, *idxstr = NULL; char *branch = NULL, *type = NULL; char *uuid = NULL; wchar_t *wcstr; attr_t rx = A_BOLD; int ncommits = 0, rc = 0, wstrlen = 0; int ncols_needed, max_usrlen = -1; if (s->selected_commit && !(view->searching != SEARCH_DONE && view->search_status == SEARCH_WAITING)) { uuid = fsl_strdup(s->selected_commit->commit->uuid); branch = fsl_strdup(s->selected_commit->commit->branch); type = fsl_strdup(s->selected_commit->commit->type); } |
︙ | |||
2326 2327 2328 2329 2330 2331 2332 | 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 | - + - - + + - + + - - - - + - + + - + - + | == NULL) { rc = RC(FSL_RC_RANGE, "%s", "fsl_mprintf"); headln = NULL; goto end; } if (SPINNER[++tcx->spin_idx] == '\0') tcx->spin_idx = 0; |
︙ | |||
2419 2420 2421 2422 2423 2424 2425 | 2564 2565 2566 2567 2568 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 2595 2596 | - + + - - + + + + + + + + + + - + | usr[strcspn(usr, "@>")] = '\0'; *username = usr; } static int formatln(wchar_t **ptr, int *wstrlen, const char *mbstr, int column_limit, |
︙ | |||
2458 2459 2460 2461 2462 2463 2464 | 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 | - + | if (cols + width > column_limit) break; cols += width; i++; } else if (width == -1) { if (wline[i] == L'\t') { width = TABSIZE - |
︙ | |||
2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 | 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | end: if (rc) free(wline); else *ptr = wline; return rc; } /* * Copy the string src into the statically sized dst char array, and expand * any tab ('\t') characters found into the equivalent number of space (' ') * characters. Return number of bytes written to dst minus the terminating NUL. */ static size_t expand_tab(char *dst, size_t dstlen, const char *src, int srclen) { size_t sz = 0; int idx = 0; while (sz < dstlen - 1 && idx < srclen && src[idx]) { const char c = *(src + idx); if (c == '\t') { size_t spaces = TABSIZE - (sz % TABSIZE); if (spaces + sz >= dstlen - 1) spaces = dstlen - sz - 1; memcpy(dst + sz, " ", spaces); sz += spaces; } else { dst[sz++] = src[idx]; } ++idx; } dst[sz] = '\0'; return sz; } static int multibyte_to_wchar(const char *src, wchar_t **dst, size_t *dstlen) { int rc = 0; /* |
︙ | |||
2589 2590 2591 2592 2593 2594 2595 | 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 | - + | */ user = fsl_strdup(commit->user); if (user == NULL) goto end; if (strpbrk(user, "<@>") != NULL) parse_emailaddr_username(&user); rc = formatln(&usr_wcstr, &usrlen, user, view->ncols - col_pos, |
︙ | |||
2616 2617 2618 2619 2620 2621 2622 | 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 | - + + | return RC(FSL_RC_ERROR, "%s", "fsl_strdup"); while (*comment == '\n') ++comment; eol = strchr(comment, '\n'); if (eol) *eol = '\0'; ncols_avail = view->ncols - col_pos; |
︙ | |||
2657 2658 2659 2660 2661 2662 2663 | 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 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 | - + - + + - + + - + + - + - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - + - - - - + - - - - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | if ((rc = pthread_mutex_unlock(&fnc_mutex))) return RC(fsl_errno_to_rc(rc, FSL_RC_ACCESS), "%s", "pthread_mutex_unlock"); sched_yield(); if ((rc = pthread_mutex_lock(&fnc_mutex))) return RC(fsl_errno_to_rc(rc, FSL_RC_ACCESS), "%s", "pthread_mutex_lock"); |
︙ | |||
2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 | 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 | + + + + + + + + + + + + + + + + + + + - - + + + + | {" Enter,Space ", " ❬Enter❭❬Space❭ "}, {" b ", " ❬b❭ "}, {" F ", " ❬F❭ "}, {" t ", " ❬t❭ "}, {""}, {""}, /* Diff */ {" Space ", " ❬Space❭ "}, {" # ", " ❬#❭ "}, {" $ ", " ❬$❭ "}, {" 0 ", " ❬0❭ "}, {" C-e ", " ❬C-e❭ "}, {" C-y ", " ❬C-y❭ "}, {" C-n ", " ❬C-n❭ "}, {" C-p ", " ❬C-p❭ "}, {" l<Right> ", " ❬l❭❬→❭ "}, {" h<Left> ", " ❬h❭❬←❭ "}, {" b ", " ❬b❭ "}, {" F ", " ❬F❭ "}, {" i ", " ❬i❭ "}, {" L ", " ❬L❭ "}, {" v ", " ❬v❭ "}, {" w ", " ❬w❭ "}, {" -,_ ", " ❬-❭❬_❭ "}, {" +,= ", " ❬+❭❬=❭ "}, {" C-k,K,<,, ", " ❬C-k❭❬K❭❬<❭❬,❭ "}, {" C-j,J,>,. ", " ❬C-j❭❬J❭❬>❭❬.❭ "}, {""}, {""}, /* Tree */ {" l,Enter,<Right> ", " ❬→❭❬l❭❬Enter❭ "}, {" h,<BS>,<Left> ", " ❬←❭❬h❭❬⌫❭ "}, {" b ", " ❬b❭ "}, {" d ", " ❬d❭ "}, {" i ", " ❬i❭ "}, {" t ", " ❬t❭ "}, {""}, {""}, /* Blame */ {" Space ", " ❬Space❭ "}, {" Enter ", " ❬Enter❭ "}, {" # ", " ❬#❭ "}, {" $ ", " ❬$❭ "}, {" 0 ", " ❬0❭ "}, {" l<Right> ", " ❬l❭❬→❭ "}, {" h<Left> ", " ❬h❭❬←❭ "}, {" L ", " ❬L❭ "}, {" b ", " ❬b❭ "}, {" p ", " ❬p❭ "}, {" B ", " ❬B❭ "}, {" T ", " ❬T❭ "}, {""}, {""}, /* Branch */ {" Enter,Space ", " ❬Enter❭❬Space❭ "}, {" d ", " ❬d❭ "}, {" i ", " ❬i❭ "}, {" s ", " ❬s❭ "}, {" t ", " ❬t❭ "}, {" R,<C-l> ", " ❬R❭❬C-l❭ "}, {""}, {""}, {0} }; static const char *desc[] = { "", "Global", "Open in-app help", "Move selection cursor or page up one line", "Move selection cursor or page down one line", |
︙ | |||
2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 | 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 | + + + + + + + + + + + + + + + + + + + | "Open diff view of the selected commit", "Open and populate branch view with all repository branches", "Open prompt to enter term with which to filter new timeline view", "Display a tree reflecting the state of the selected commit", "", "Diff", "Scroll down one page of diff output", "Toggle display of diff view line numbers", "Scroll the view right to the end of the longest line", "Scroll the view left to the beginning of the line", "Scroll the view down in the buffer", "Scroll the view up in the buffer", "Navigate to next file in the diff", "Navigate to previous file in the diff", "Scroll the view right", "Scroll the view left", "Open and populate branch view with all repository branches", "Open prompt to enter file number and navigate to file", "Toggle inversion of diff output", "Open prompt to enter line number and navigate to line", "Toggle verbosity of diff output", "Toggle ignore whitespace-only changes in diff", "Decrease the number of context lines", "Increase the number of context lines", "Display diff of next (newer) commit in the timeline", "Display diff of previous (older) commit in the timeline", "", "Tree", "Move into the selected directory", "Return to the parent directory", "Open and populate branch view with all repository branches", "Toggle ISO8601 modified timestamp display for each tree entry", "Toggle display of file artifact SHA hash ID", "Display timeline of all commits modifying the selected entry", "", "Blame", "Scroll down one page", "Display the diff of the commit corresponding to the selected line", "Toggle display of file line numbers", "Scroll the view right to the end of the longest line", "Scroll the view left to the beginning of the line", "Scroll the view right", "Scroll the view left", "Open prompt to enter line number and navigate to line", "Blame the version of the file found in the selected line's commit", "Blame the version of the file found in the selected line's parent " "commit", "Reload the previous blamed version of the file", "Open and populate branch view with all repository branches", "", "Branch", "Display the timeline of the currently selected branch", "Toggle display of the date when the branch last received changes", "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." }; int cs, ln, width = 0, rc = 0; |
︙ | |||
2988 2989 2990 2991 2992 2993 2994 | 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 | - + - + | case 'j': if (cury < end) ++cury; break; case KEY_PPAGE: case CTRL('b'): if (cury > 0) { |
︙ | |||
3065 3066 3067 3068 3069 3070 3071 | 3337 3338 3339 3340 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 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 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 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 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 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 | - - - + + - - - - - - - - - + + + + + - - - - + - - - - - - - - - + + - - - - + + - - + - - - - - + - - - + - - - - - + - - - - - - - - - - - - - - - - - - - - - + - - - - + - - - - - - - - - - - - - - - - - - - - + - - - - - + - - - - - - + - - - - + + - - - - - + - - - - - + - - + - + - - - - - - - - - - - - - - - + - - + - - + - - - - - - - - - - - - - - - - - - + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - - + - + + + | refresh(); } static int tl_input_handler(struct fnc_view **new_view, struct fnc_view *view, int ch) { struct fnc_tl_view_state *s = &view->state.timeline; |
︙ | |||
3373 3374 3375 3376 3377 3378 3379 | 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 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 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 3883 3884 3885 3886 3887 3888 3889 3890 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 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 | - + - - - + + + + + + - + + + + + - + + - + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + - + - + - - - + - - - - - - + - - + + - - - - + - - + + - + - | ++ncommits; } } static int make_splitscreen(struct fnc_view *view) { |
︙ | |||
3534 3535 3536 3537 3538 3539 3540 | 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 | - + - - + + | entry = TAILQ_FIRST(&s->commits.head); else entry = TAILQ_LAST(&s->commits.head, commit_tailhead); } while (1) { if (entry == NULL) { |
︙ | |||
3610 3611 3612 3613 3614 3615 3616 | 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 | - + - + | return false; } static int view_close(struct fnc_view *view) { |
︙ | |||
3743 3744 3745 3746 3747 3748 3749 | 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 | - + - - + + - + - + + + + + + + + + + - + - - - + + + | fsl_free(ffa->fc); fsl_free(ffa); return 0; } static int |
︙ | |||
3809 3810 3811 3812 3813 3814 3815 | 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 | - - + + - - + - - - - + - + | free_colours(&s->colours); return rc; } view->show = show_diff; view->input = diff_input_handler; view->close = close_diff_view; |
︙ | |||
3859 3860 3861 3862 3863 3864 3865 | 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 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 | - - + + - - + + | /* * We'll diff artifacts of type "ci" (i.e., "checkin") separately, as * it's a different process to diff the others (wiki, technote, etc.). */ if (s->selected_commit->diff_type == FNC_DIFF_COMMIT) rc = create_changeset(s->selected_commit); else if (s->selected_commit->diff_type == FNC_DIFF_BLOB) |
︙ | |||
3903 3904 3905 3906 3907 3908 3909 | 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 | - + - - + - + - + + + + + + + - + - - - - - - - + | /* * Diff local changes on disk in the current checkout differently to * checked-in versions: the former compares on disk file content with * file artifacts; the latter compares file artifact blobs only. */ if (s->selected_commit->diff_type == FNC_DIFF_COMMIT) |
︙ | |||
4051 4052 4053 4054 4055 4056 4057 | 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 | - + + + + | if (st == NULL) { RC(FSL_RC_ERROR, "%s", "fsl_strdup"); goto end; } while ((line = fnc_strsep(&st, "\n")) != NULL) { linelen = fsl_strlen(line); if (linelen >= s->ncols) { |
︙ | |||
4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 | 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 | + + + + + + + | file_change->fc->name)) < 0) goto end; lnoff += n; if ((rc = add_line_offset(&s->line_offsets, &s->nlines, lnoff))) goto end; } /* Add blank line between end of changeset and diff. */ fputc('\n', s->f); ++lnoff; rc = add_line_offset(&s->line_offsets, &s->nlines, lnoff); s->index.offset = fsl_realloc(s->index.offset, (s->index.n + 1) * sizeof(size_t)); s->index.offset[s->index.n++] = lnoff; end: free(st0); free(line); if (rc) { free(*&s->line_offsets); s->line_offsets = NULL; s->nlines = 0; |
︙ | |||
4183 4184 4185 4186 4187 4188 4189 | 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 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 | - - + - + + - - + + + - + - + | * exists in both d1 and d2). In cases (1) and (2), we call diff_file_artifact() * to dump the complete content of the added/deleted file if FSL_DIFF_VERBOSE is * set, otherwise only diff metatadata will be output. In case (3), if the * hash (UUID) of each F card is the same, there are no changes; if different, * both artifacts will be passed to diff_file_artifact() to be diffed. */ static int |
︙ | |||
4257 4258 4259 4260 4261 4262 4263 | 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 | - + - - - - + + - - + - + | fsl_deck_F_next(&d2, &fc2); } else if (different < 0) { a = fc1; change = FSL_CKOUT_CHANGE_REMOVED; fsl_deck_F_next(&d1, &fc1); } if (diff) |
︙ | |||
4301 4302 4303 4304 4305 4306 4307 | 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 | - - + - + + | * buf output buffer in which diff content is appended * vid repository database record id of the version to diff against * diff_flags, context, and sbs are the same parameters as diff_file_artifact() * nb. This routine is only called with 'fnc diff [hash]'; that is, one or * zero args—not two—supplied to fnc's diff command line interface. */ static int |
︙ | |||
4437 4438 4439 4440 4441 4442 4443 | 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 | - - - - + + + + - + - + - - + + - - + - + | } if (!xminus) xminus = fsl_strdup(NULL_DEVICE); allow_symlinks = fsl_config_get_bool(f, FSL_CONFDB_REPO, false, "allow-symlinks"); if (!symlink != !(fsl_is_symlink(fsl_buffer_cstr(&abspath)) && allow_symlinks)) { |
︙ | |||
4542 4543 4544 4545 4546 4547 4548 | 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 | - + - - + + + - + - - + + - + - | /* FALL THROUGH */ default: minus = xminus; plus = xplus; break; } |
︙ | |||
4644 4645 4646 4647 4648 4649 4650 | 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 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 | + + + - - + + + + + + + - - + - - - + + + + + - - + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | default: RC(FSL_RC_SIZE_MISMATCH, "invalid artifact uuid [%s]", xminus); goto end; } if (rc) goto end; s->index.offset = fsl_realloc(s->index.offset, (s->index.n + 1) * sizeof(size_t)); s->index.offset[s->index.n++] = s->buf.used; |
︙ | |||
4751 4752 4753 4754 4755 4756 4757 | 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 | - + + - + + - - + + + + + + + + - - + + - + + - - + | else { fsl_buffer_copy(buf, &wiki); goto end; } } /* Diff the artifacts if a parent is found. */ |
︙ | |||
4842 4843 4844 4845 4846 4847 4848 | 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 | - + | } if (b) { rc = fsl_card_F_content(f, b, &fbuf2); if (rc) goto end; zplus = b->name; xplus = b->uuid; |
︙ | |||
4867 4868 4869 4870 4871 4872 4873 | 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 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 | + + + + + - - + + - - - - + + + + + + + + + + | } xplus0 = fsl_rid_to_uuid(f, vid2); xplus = xplus0; fsl_stmt_finalize(&stmt); fsl_content_get(f, vid2, &fbuf2); } if (s->buf.used) { s->index.offset = fsl_realloc(s->index.offset, (s->index.n + 1) * sizeof(size_t)); s->index.offset[s->index.n++] = s->buf.used + s->index.offset[0]; } |
︙ | |||
4931 4932 4933 4934 4935 4936 4937 | 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 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 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 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 | - - + + - + + + + + + + + + + + + - - + + - + - - + + + + - + - + - - - + + - + - - + + + + + + + + + + + + + + + - - - + + + + - + - + - + + + - - - - - + + + + + + + - - + + - + - + - - | regmatch_t *regmatch = &view->regmatch; struct fnc_colour *c = NULL; wchar_t *wcstr; char *line; size_t linesz = 0; ssize_t linelen; off_t line_offset; |
︙ | |||
5047 5048 5049 5050 5051 5052 5053 | 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 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 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 5684 5685 5686 5687 5688 5689 5690 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 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 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 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 | - + - + - + + + + + + + + + + + + + + - - + + - - + + + - + + + + - - + + + + - + - + - + + - + + + + + + + + - + - - + + - - - + + + - + + - - - - + + + + + + + + + + - + + - + + + + + + - + - + + + + + + - - - - + + + + + - - + + + + + + + + + + + - - - + + + - + - - + + + + + - - + + - + - - - - + + - - - - - - - + + + + + + - - - - - - - - - - + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | return false; } else if (!screen_is_split(view)) return false; return view->active; } |
︙ | |||
5245 5246 5247 5248 5249 5250 5251 | 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 | - + - + - + - - - - + - - + - - - - - - - + - + - | case 'c': case 'i': case 'v': case 'w': if (ch == 'c') s->colour = !s->colour; if (ch == 'i') |
︙ | |||
5302 5303 5304 5305 5306 5307 5308 | 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 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 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 | + + + + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + - - - - - + + + + + + + + + + + - + - + - + - + - + - - + + - + - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - + + + + + - - - + + + + + + - + - - + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + - + - + | if (previous_selection == tlstate->selected_commit) break; if ((rc = set_selected_commit(s, tlstate->selected_commit))) break; s->selected_line = 1; reset_diff_view(view, false); break; default: break; } |
︙ | |||
5468 5469 5470 5471 5472 5473 5474 | 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 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 | - + - - + + - + - + + + - + - | wclear(view->window); view->nlines = nlines; view->ncols = ncols; view->lines = LINES; view->cols = COLS; |
︙ | |||
5585 5586 5587 5588 5589 5590 5591 | 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 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 | - - - + + + - - + + - + + - - + + - + + - + - + + | exit(fcli_end_of_main(fnc_init.err)); } static void usage_timeline(void) { fsl_fprintf(fnc_init.err ? stderr : stdout, |
︙ | |||
5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 | 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 | + + + + + + - + | commit->type = fsl_strdup("blob"); commit->diff_type = diff_type; } rc = init_curses(); if (rc) goto end; #ifdef __OpenBSD__ rc = init_unveil(fsl_cx_db_file_repo(f, NULL), fsl_cx_ckout_dir_name(f, NULL), false); if (rc) goto end; #endif if (fnc_init.context) { if ((rc = strtonumcheck(&context, fnc_init.context, INT_MIN, INT_MAX))) goto end; |
︙ | |||
5830 5831 5832 5833 5834 5835 5836 | 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 | - + - + | TAILQ_FOREACH(pe, &paths, entry) free((char *)pe->path); fnc_pathlist_free(&paths); return rc; } static int |
︙ | |||
5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 | 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 | + + + + + + | fcli_progname()); goto end; } rc = init_curses(); if (rc) goto end; #ifdef __OpenBSD__ rc = init_unveil(fsl_cx_db_file_repo(f, NULL), fsl_cx_ckout_dir_name(f, NULL), false); if (rc) goto end; #endif view = view_open(0, 0, 0, 0, FNC_VIEW_TREE); if (view == NULL) { RC(FSL_RC_ERROR, "%s", "view_open"); goto end; } |
︙ | |||
5981 5982 5983 5984 5985 5986 5987 | 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 | - - + + | if (rc) goto end; } view->show = show_tree_view; view->input = tree_input_handler; view->close = close_tree_view; |
︙ | |||
6089 6090 6091 6092 6093 6094 6095 | 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 | - + - + - + + - | memset(ptr, 0, sizeof(struct fnc_repository_tree)); rc = fsl_deck_load_rid(f, &d, rid, FSL_SATYPE_CHECKIN); if (rc) return RC(rc, "fsl_deck_load_rid(%d) [%s]", rid, id); rc = fsl_deck_F_rewind(&d); if (rc) |
︙ | |||
6222 6223 6224 6225 6226 6227 6228 | 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 | - + | * path The repository relative pathname of the versioned file * uuid The SHA hash of the file * mtime Modification time of the file * Returns 0 on success, non-zero on error. */ static int link_tree_node(struct fnc_repository_tree *tree, const char *path, |
︙ | |||
6338 6339 6340 6341 6342 6343 6344 | 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 | - + | rc = tree_entry_path(&treepath, &s->parents, NULL); if (rc) return rc; rc = draw_tree(view, treepath); fsl_free(treepath); |
︙ | |||
6421 6422 6423 6424 6425 6426 6427 | 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 | - + - + + | static int draw_tree(struct fnc_view *view, const char *treepath) { struct fnc_tree_view_state *s = &view->state.tree; struct fnc_tree_entry *te; struct fnc_colour *c = NULL; wchar_t *wcstr; |
︙ | |||
6456 6457 6458 6459 6460 6461 6462 | 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 | - + - - + - + - - + + - + + | wattroff(view->window, A_REVERSE); fsl_free(wcstr); wcstr = NULL; if (--limit <= 0) return rc; /* Write this (sub)tree's absolute repository path subheader. */ |
︙ | |||
6541 6542 6543 6544 6545 6546 6547 | 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 | + + + + + + + - - - - - - + + + + + + + + - - + - - + - - + - + - + | } modestr = "@"; } else if (S_ISDIR(mode)) modestr = "/"; else if (mode & S_IXUSR) modestr = "*"; if (s->show_date) { char *t; if (fsl_julian_to_iso8601(te->mtime, iso8601, false)) *(t = strchr(iso8601, 'T')) = ' '; else rc = FSL_RC_ERROR; } |
︙ | |||
6647 6648 6649 6650 6651 6652 6653 | 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 | - - + + - - + + + | } static int tree_input_handler(struct fnc_view **new_view, struct fnc_view *view, int ch) { struct fnc_view *branch_view, *timeline_view; struct fnc_tree_view_state *s = &view->state.tree; |
︙ | |||
6732 6733 6734 6735 6736 6737 6738 | 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 | - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + - + + - + + + + + + + + + + + + + + + | } s->first_entry_onscreen = te; te = get_tree_entry(s->tree, te->idx - 1); } if (n > 0) s->selected_idx = n - 1; break; |
︙ | |||
6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 | 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 | + + + - + - - - - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + | TAILQ_REMOVE(&s->parents, parent, entry); fnc_object_tree_close(s->tree); s->tree = parent->tree; s->first_entry_onscreen = parent->first_entry_onscreen; s->selected_entry = parent->selected_entry; s->selected_idx = parent->selected_idx; if (s->selected_idx > view->nlines - 3) offset_selected_line(view); fsl_free(parent); } else if (s->selected_entry != NULL && S_ISDIR(s->selected_entry->mode)) { struct fnc_tree_object *subtree = NULL; rc = tree_builder(s->repo, &subtree, s->selected_entry->path); if (rc) break; rc = visit_subtree(s, subtree); if (rc) { fnc_object_tree_close(subtree); break; } } else if (s->selected_entry != NULL && |
︙ | |||
6897 6898 6899 6900 6901 6902 6903 | 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 | - - + + + - - + + - - - + + + + + + | break; } s->first_entry_onscreen = te; te = get_tree_entry(s->tree, te->idx - 1); } } |
︙ | |||
6941 6942 6943 6944 6945 6946 6947 | 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 | - + - + - - + + - - + + - + - + - + - + + | s->selected_idx = 0; s->first_entry_onscreen = NULL; return 0; } static int |
︙ | |||
7032 7033 7034 7035 7036 7037 7038 | 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 | - + - + + + + + + + + + - - + + + | if (match_tree_entry(te, &view->regex)) { view->search_status = SEARCH_CONTINUE; s->matched_entry = te; break; } if (view->searching == SEARCH_FORWARD) |
︙ | |||
7146 7147 7148 7149 7150 7151 7152 | 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 | - - + + + + + + + + + + + + + + - - + + - + - - - + + + - - - + + + - + - + - - - - - - - - + + - + - + - + - - - - - - - + - + - + - - - - - - - - + | } fsl_free(repo); } static int cmd_config(const fcli_command *argv) { |
︙ | |||
7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 | 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 | + + + + + + + + + + - + | } static void view_set_child(struct fnc_view *view, struct fnc_view *child) { view->child = child; child->parent = view; /* * If the timeline is open and has not yet loaded /all/ commits, cached * stmts require resetting the commit builder stmt before restepping. */ if (view->vid == FNC_VIEW_TIMELINE) { struct fnc_tl_thread_cx *tcx = &view->state.timeline.thread_cx; if (tcx && !tcx->eotl) tcx->reset = true; } } static int set_colours(struct fnc_colours *s, enum fnc_view_id vid) { |
︙ | |||
7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 | 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 | + + | nitems(regexp_branch)); break; } default: rc = RC(FSL_RC_TYPE, "invalid fnc_view_id: %s", vid); } init_pair(FNC_COLOUR_HL_SEARCH, init_colour(FNC_COLOUR_HL_SEARCH), -1); return rc; } static int set_colour_scheme(struct fnc_colours *colours, const int (*pairs)[2], const char **regexp, int n) { |
︙ | |||
7397 7398 7399 7400 7401 7402 7403 | 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 | - + - + | STAILQ_INSERT_HEAD(colours, colour, entries); } return rc; } static int |
︙ | |||
7439 7440 7441 7442 7443 7444 7445 | 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 | - + - + - + - - + + - - - - - - - - + + + + + + + + - + - + + - + - - - - - - - - - - - - + + + + + - - + - - + - - + - - - - - - - - - + + + + + + + + + + - - - - + + + + + - + | * found, return a dynamically allocated string obtained from fsl_db_g_text() or * strdup(), which must be disposed of by the caller. Alternatively, if ls is * set, search local settings and envvars for id. If found, dynamically allocate * and return a formatted string for pretty printing the current state of id, * which the caller must free. In either case, if not found, return NULL. */ static char * |
︙ | |||
7599 7600 7601 7602 7603 7604 7605 | 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 | - + + | cmd_blame(fcli_command const *argv) { fsl_cx *const f = fcli_cx(); struct fnc_view *view; char *path = NULL; fsl_uuid_str commit_id = NULL; fsl_id_t tip = 0, rid = 0; |
︙ | |||
7638 7639 7640 7641 7642 7643 7644 | 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 | - + + + + - + + + + + + + + + | rc = fsl_sym_to_rid(f, "tip", FSL_SATYPE_CHECKIN, &tip); if (rc) goto end; } rc = fsl_sym_to_rid(f, fnc_init.sym, FSL_SATYPE_CHECKIN, &rid); if (rc) goto end; |
︙ | |||
7717 7718 7719 7720 7721 7722 7723 | 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 | - - + + | if (rc) return rc; } view->show = show_blame_view; view->input = blame_input_handler; view->close = close_blame_view; |
︙ | |||
7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 | 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 | + + + + | rc = RC(FSL_RC_NOT_FOUND, "'%s' not found in tree [%s]", 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)) { rc = RC(FSL_RC_DIFF_BINARY, "%s", "cannot blame binary file"); goto end; } /* * We load f with the actual file content to map line offsets so we * accurately find tokens when running a search. */ blame->f = tmpfile(); if (blame->f == NULL) { |
︙ | |||
7842 7843 7844 7845 7846 7847 7848 | 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 | - + + | s->blame_complete = false; if (s->first_line_onscreen + view->nlines - 1 > blame->nlines) { s->first_line_onscreen = 1; s->last_line_onscreen = view->nlines; s->selected_line = 1; } |
︙ | |||
7877 7878 7879 7880 7881 7882 7883 | 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 | - - + + | if (filesz) *filesz = 0; if (nlines) *nlines = 0; len = buf->used; if (len == 0) |
︙ | |||
7972 7973 7974 7975 7976 7977 7978 | 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 | - + | halfdelay(1); /* Fast refresh while annotating. */ } if (s->blame_complete) cbreak(); /* Return to blocking mode. */ rc = draw_blame(view); |
︙ | |||
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 | 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 | + + - + - + + - + - - - - + - - + | /* -r can return lines with no version, so use root check-in. */ if (opt->originRid && !line->id) { line->id = fsl_strdup(cx->root_commit); line->annotated = true; } line->lineno = step->lineNumber; cx->maxlen = MAX(step->lineLength, cx->maxlen); ++cx->nlines; end: rc = pthread_mutex_unlock(&fnc_mutex); if (rc) rc = RC(fsl_errno_to_rc(rc, FSL_RC_ACCESS), "%s", "pthread_mutex_unlock"); return rc; } static int draw_blame(struct fnc_view *view) { struct fnc_blame_view_state *s = &view->state.blame; struct fnc_blame *blame = &s->blame; struct fnc_blame_line *blame_line; regmatch_t *regmatch = &view->regmatch; struct fnc_colour *c = NULL; wchar_t *wcstr; char *line = NULL; |
︙ | |||
8112 8113 8114 8115 8116 8117 8118 | 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 | - - - + + + - - + + + + + - - + + + + - + - - + | if (screen_is_shared(view)) wattroff(view->window, A_REVERSE); fsl_free(wcstr); wcstr = NULL; if (width < view->ncols - 1) waddch(view->window, '\n'); |
︙ | |||
8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 | 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 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 | + + + - - - + + + - + - - + - + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + | COLOR_PAIR(c->scheme), NULL); fsl_free(id_str); prev_id = blame_line->id; } else { waddstr(view->window, ".........."); prev_id = NULL; } if (s->showln) npad = draw_lineno(view, blame->nlines, blame_line->lineno, rx); } else { waddstr(view->window, ".........."); prev_id = NULL; } |
︙ | |||
8267 8268 8269 8270 8271 8272 8273 | 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 | - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | s->first_line_onscreen = 1; } else { s->selected_line = view->nlines - 2; s->first_line_onscreen = s->blame.nlines - (view->nlines - 3); } break; |
︙ | |||
8331 8332 8333 8334 8335 8336 8337 | 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 | - - + - - - - - - | if (fsl_deck_F_search(&d, s->path + (fnc_init.sym ? 0 : 1)) == NULL) { char *m = fsl_mprintf("-- %s not in [%.12s] --", s->path + (fnc_init.sym ? 0 : 1), pid); if (m == NULL) rc = RC(FSL_RC_ERROR, "%s", "fsl_mprintf"); |
︙ | |||
8439 8440 8441 8442 8443 8444 8445 | 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 | - + | 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); rc = RC(FSL_RC_ERROR, "%s", "view_open"); break; } |
︙ | |||
8462 8463 8464 8465 8466 8467 8468 | 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 | - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | view->focus_child = true; } else *new_view = diff_view; if (rc) break; break; } |
︙ | |||
8630 8631 8632 8633 8634 8635 8636 | 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 | - + | static int stop_blame(struct fnc_blame *blame) { int idx, rc = 0; if (blame->thread_id) { |
︙ | |||
8748 8749 8750 8751 8752 8753 8754 | 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 | - + + + + + + + + + + - + - - - + - - - + - - - + + + + + | when = fnc_init.after ? 1 : -1; rc = fnc_date_to_mtime(&dateline, d, when); if (rc) return rc; } glob = fsl_strdup(fcli_next_arg(true)); |
︙ | |||
8838 8839 8840 8841 8842 8843 8844 | 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 | + + - - - + + + + + | " FROM tmp_brlist WHERE isclosed", -1); break; } if (rc) goto end; if (s->branch_glob) { char *op = NULL, *str = NULL; rc = fnc_make_sql_glob(&op, &str, s->branch_glob, |
︙ | |||
8913 8914 8915 8916 8917 8918 8919 | 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 | - + | return rc; } static int create_tmp_branchlist_table(void) { fsl_cx *const f = fcli_cx(); |
︙ | |||
8939 8940 8941 8942 8943 8944 8945 | 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 | - + | " AND tagxref.tagtype>0" " AND tag.tagname='branch'" " AND event.objid=tagxref.rid " "GROUP BY 1;"; int rc = 0; if (!db) |
︙ | |||
9049 9050 9051 9052 9053 9054 9055 | 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 | - + | be = s->first_branch_onscreen; if ((line = fsl_mprintf("branches [%d/%d]", be->idx + s->selected + 1, s->nbranches)) == NULL) return RC(FSL_RC_ERROR, "%s", "fsl_mprintf"); |
︙ | |||
9089 9090 9091 9092 9093 9094 9095 | 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 | - + | s->show_date ? be->branch->date : 0); if (line == NULL) return RC(FSL_RC_ERROR, "%s", "fsl_mprintf"); if (s->colour) c = match_colour(&s->colours, line); |
︙ | |||
9120 9121 9122 9123 9124 9125 9126 | 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 | - + - + - + + - - - - - - + + + + + + - - - - - - - - + + + + + + + + + + | ++n; ++s->ndisplayed; --limit; s->last_branch_onscreen = be; be = TAILQ_NEXT(be, entries); } |
︙ | |||
9220 9221 9222 9223 9224 9225 9226 | 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 | - + + + + - - + + + + + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - | if (s->selected < s->ndisplayed - 1) { ++s->selected; break; } if (TAILQ_NEXT(s->last_branch_onscreen, entries) == NULL) /* Reached last entry. */ break; |
︙ | |||
9323 9324 9325 9326 9327 9328 9329 | 10218 10219 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 10255 10256 10257 10258 10259 10260 10261 | - - + + + - - - - + + + + + + - | if (be == NULL) break; s->first_branch_onscreen = be; be = TAILQ_PREV(be, fnc_branchlist_head, entries); } } |
︙ | |||
9412 9413 9414 9415 9416 9417 9418 | 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 | + + + + + - - - - - + + + + + + | if (view->searching == SEARCH_FORWARD) be = TAILQ_NEXT(be, entries); else be = TAILQ_PREV(be, fnc_branchlist_head, entries); } if (s->matched_branch) { int idx = s->matched_branch->idx; if (idx >= s->first_branch_onscreen->idx && idx <= s->last_branch_onscreen->idx) s->selected = idx - s->first_branch_onscreen->idx; else { |
︙ | |||
9577 9578 9579 9580 9581 9582 9583 | 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 | - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | static void fnc_show_version(void) { printf("%s %s\n", fcli_progname(), PRINT_VERSION); } static int |
︙ | |||
9660 9661 9662 9663 9664 9665 9666 9667 | 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | *token++ = '\0'; *ptr = token; } else *ptr = NULL; return s; } static bool fnc_str_has_upper(const char *str) { int idx; for (idx = 0; str[idx]; ++idx) if (fsl_isupper(str[idx])) return true; return false; } /* * If fold is true, construct a pairing for SQL queries using the SQLite LIKE * operator to fold case with dynamically allocated strings such that: * *op = "LIKE" * *glob = "%%%%str%%%%" * Otherwise, construct a case-sensitive pairing: * *op = "GLOB" * *glob = "*str*" * Both *op and *glob must be disposed of by the caller. Return non-zero on * allocation failure, else return zero. */ static int fnc_make_sql_glob(char **op, char **glob, const char *str, bool fold) { 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) return RC(FSL_RC_ERROR, "%s", "fsl_mprintf"); } else { *op = fsl_strdup("GLOB"); if (*op == NULL) return RC(FSL_RC_ERROR, "%s", "fsl_strdup"); *glob = fsl_mprintf("*%s*", str); if (*glob == NULL) return RC(FSL_RC_ERROR, "%s", "fsl_mprintf"); } return 0; } #ifdef __OpenBSD__ /* * Read permissions for the below unveil() calls are self-evident; we need * to read the repository and ckout databases, and ckout dir for most all fnc * operations. Write and create permissions are briefly listed inline, but we * effectively veil the entire fs except the repo db, ckout dir, and /tmp. */ static int init_unveil(const char *repodb, const char *ckoutdir, bool cfg) { /* w repo db for 'fnc config' command: fnc_conf_setopt(). */ if (unveil(repodb, cfg ? "rwc" : "rw") == -1) return RC(fsl_errno_to_rc(errno, FSL_RC_ACCESS), "unveil(%s, \"rw\")", repodb); /* w .fslckout for fsl_ckout_changes_scan() in cmd_diff(). */ if (unveil(ckoutdir, "rw") == -1) return RC(fsl_errno_to_rc(errno, FSL_RC_ACCESS), "unveil(%s, \"rw\")", ckoutdir); /* rwc /tmp for tmpfile() in help(), create_diff(), and run_blame(). */ if (unveil(P_tmpdir, "rwc") == -1) return RC(fsl_errno_to_rc(errno, FSL_RC_ACCESS), "unveil(%s, \"rwc\")", P_tmpdir); if (unveil(NULL, NULL) == -1) return RC(fsl_errno_to_rc(errno, FSL_RC_ACCESS), "%s", "unveil"); return FSL_RC_OK; } #endif |