diff options
author | sterni <sternenseemann@systemli.org> | 2023-06-23T13·02+0200 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-06-29T10·15+0000 |
commit | 12b979e41b6b639f058ba3634639a69840be4597 (patch) | |
tree | aeec16c0f81de4101f623430e33cc97942238ebe /third_party/cgit/shared.c | |
parent | d356f94ef15f9f8e517cc1bcc4b997b1c60d3b63 (diff) |
chore(3p/sources): Bump channels & overlays r/6361
* //3p/sources: switch stable channel from 21.11 (!) to 23.05 * //users: adapt to emacsUnstable to emacs-unstable rename * //users/grfn: use default Linux kernel version everywhere, as 5.15 has broken in this version of nixos-unstable. * //3p/cgit: adapt to git 2.41.0 The committed changes are the same as the [patch1] I've submitted to cgit-pink which is in turn based on Christian Hesse's [patch2]. patch1: https://causal.agency/list/thread/20230624144033.802270-1-sternenseemann%40systemli.org.html#20230624144033.802270-2-sternenseemann@systemli.org> patch2: https://lists.zx2c4.com/pipermail/cgit/2023-June/004843.html Co-authored-by: Christian Hesse <mail@eworm.de> Change-Id: I549a62e7c85c66d772edda997819a40f2d5835d7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8855 Autosubmit: sterni <sternenseemann@systemli.org> Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de> Reviewed-by: grfn <grfn@gws.fyi>
Diffstat (limited to 'third_party/cgit/shared.c')
-rw-r--r-- | third_party/cgit/shared.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/third_party/cgit/shared.c b/third_party/cgit/shared.c index 0bceb9891228..26b6ddb32974 100644 --- a/third_party/cgit/shared.c +++ b/third_party/cgit/shared.c @@ -241,7 +241,7 @@ static int load_mmfile(mmfile_t *file, const struct object_id *oid) file->ptr = (char *)""; file->size = 0; } else { - file->ptr = read_object_file(oid, &type, + file->ptr = repo_read_object_file(the_repository, oid, &type, (unsigned long *)&file->size); } return 1; @@ -343,7 +343,7 @@ void cgit_diff_tree(const struct object_id *old_oid, struct diff_options opt; struct pathspec_item *item; - diff_setup(&opt); + repo_diff_setup(the_repository, &opt); opt.output_format = DIFF_FORMAT_CALLBACK; opt.detect_rename = 1; opt.rename_limit = ctx.cfg.renamelimit; @@ -539,7 +539,9 @@ char *expand_macros(const char *txt) char *get_mimetype_for_filename(const char *filename) { - char *ext, *mimetype, *token, line[1024], *saveptr; + char *ext, *mimetype, line[1024]; + struct string_list list = STRING_LIST_INIT_NODUP; + int i; FILE *file; struct string_list_item *mime; @@ -564,13 +566,16 @@ char *get_mimetype_for_filename(const char *filename) while (fgets(line, sizeof(line), file)) { if (!line[0] || line[0] == '#') continue; - mimetype = strtok_r(line, " \t\r\n", &saveptr); - while ((token = strtok_r(NULL, " \t\r\n", &saveptr))) { - if (!strcasecmp(ext, token)) { + string_list_split_in_place(&list, line, " \t\r\n", -1); + string_list_remove_empty_items(&list, 0); + mimetype = list.items[0].string; + for (i = 1; i < list.nr; i++) { + if (!strcasecmp(ext, list.items[i].string)) { fclose(file); return xstrdup(mimetype); } } + string_list_clear(&list, 0); } fclose(file); return NULL; |