From list at eworm.de Tue May 16 15:05:35 2023 From: list at eworm.de (Christian Hesse) Date: Tue, 16 May 2023 17:05:35 +0200 Subject: [PATCH 1/1] RFC: git: update to v2.41.0-rc0 Message-ID: <20230516150535.79723-1-list@eworm.de> From: Christian Hesse Update to git version v2.41.0-rc0, lots of changes... Upstream commits to be referenced... Signed-off-by: Christian Hesse --- cgit.c | 2 +- cgit.h | 30 +++++++++++++++++------------- git | 2 +- parsing.c | 2 +- shared.c | 16 ++++++++++------ ui-atom.c | 2 +- ui-blame.c | 12 ++++++------ ui-blob.c | 10 +++++----- ui-commit.c | 2 +- ui-diff.c | 14 +++++++------- ui-log.c | 6 +++--- ui-patch.c | 6 +++--- ui-plain.c | 6 +++--- ui-shared.c | 8 ++++---- ui-snapshot.c | 14 +++++++------- ui-stats.c | 2 +- ui-tag.c | 2 +- ui-tree.c | 8 ++++---- 18 files changed, 76 insertions(+), 68 deletions(-) diff --git a/cgit.c b/cgit.c index 57d7097..e616292 100644 --- a/cgit.c +++ b/cgit.c @@ -631,7 +631,7 @@ static int prepare_repo_cmd(int nongit) return 1; } - if (get_oid(ctx.qry.head, &oid)) { + if (repo_get_oid(the_repository, ctx.qry.head, &oid)) { char *old_head = ctx.qry.head; ctx.qry.head = xstrdup(ctx.repo->defbranch); cgit_print_error_page(404, "Not found", diff --git a/cgit.h b/cgit.h index ddd2ccb..f788fd2 100644 --- a/cgit.h +++ b/cgit.h @@ -1,31 +1,35 @@ #ifndef CGIT_H #define CGIT_H +#include #include -#include +#include #include +#include +#include +#include +#include +#include #include +#include +#include +#include #include +#include #include -#include -#include -#include -#include -#include -#include #include #include -#include -#include +#include #include +#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include /* Add isgraph(x) to Git's sane ctype support (see git-compat-util.h) */ #undef isgraph diff --git a/git b/git index 0d1bd1d..0df2c18 160000 --- a/git +++ b/git @@ -1 +1 @@ -Subproject commit 0d1bd1dfb37ef25e1911777c94129fc769ffec38 +Subproject commit 0df2c180904f6b709766f9c24669a9d01543f915 diff --git a/parsing.c b/parsing.c index 72b59b3..dc44ffd 100644 --- a/parsing.c +++ b/parsing.c @@ -198,7 +198,7 @@ struct taginfo *cgit_parse_tag(struct tag *tag) const char *p; struct taginfo *ret = NULL; - data = read_object_file(&tag->object.oid, &type, &size); + data = repo_read_object_file(the_repository, &tag->object.oid, &type, &size); if (!data || type != OBJ_TAG) goto cleanup; diff --git a/shared.c b/shared.c index 0bceb98..8a6d0e9 100644 --- a/shared.c +++ b/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,9 +566,11 @@ 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); } diff --git a/ui-atom.c b/ui-atom.c index 5f4ad7d..636cb7e 100644 --- a/ui-atom.c +++ b/ui-atom.c @@ -97,7 +97,7 @@ void cgit_print_atom(char *tip, const char *path, int max_count) argv[argc++] = path; } - init_revisions(&rev, NULL); + repo_init_revisions(the_repository, &rev, NULL); rev.abbrev = DEFAULT_ABBREV; rev.commit_format = CMIT_FMT_DEFAULT; rev.verbose_header = 1; diff --git a/ui-blame.c b/ui-blame.c index aedce8d..e0f0593 100644 --- a/ui-blame.c +++ b/ui-blame.c @@ -49,12 +49,12 @@ static void emit_blame_entry_hash(struct blame_entry *ent) char *detail = emit_suspect_detail(suspect); html(""); - cgit_commit_link(find_unique_abbrev(oid, DEFAULT_ABBREV), detail, + cgit_commit_link(repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV), detail, NULL, ctx.qry.head, oid_to_hex(oid), suspect->path); html(""); free(detail); - if (!parse_commit(suspect->commit) && suspect->commit->parents) { + if (!repo_parse_commit(the_repository, suspect->commit) && suspect->commit->parents) { struct commit *parent = suspect->commit->parents->item; html(" "); @@ -126,7 +126,7 @@ static void print_object(const struct object_id *oid, const char *path, return; } - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) { cgit_print_error_page(500, "Internal server error", "Error reading object %s", oid_to_hex(oid)); @@ -135,7 +135,7 @@ static void print_object(const struct object_id *oid, const char *path, strvec_push(&rev_argv, "blame"); strvec_push(&rev_argv, rev); - init_revisions(&revs, NULL); + repo_init_revisions(the_repository, &revs, NULL); revs.diffopt.flags.allow_textconv = 1; setup_revisions(rev_argv.nr, rev_argv.v, &revs, NULL); init_scoreboard(&sb); @@ -287,13 +287,13 @@ void cgit_print_blame(void) if (!rev) rev = ctx.qry.head; - if (get_oid(rev, &oid)) { + if (repo_get_oid(the_repository, rev, &oid)) { cgit_print_error_page(404, "Not found", "Invalid revision name: %s", rev); return; } commit = lookup_commit_reference(the_repository, &oid); - if (!commit || parse_commit(commit)) { + if (!commit || repo_parse_commit(the_repository, commit)) { cgit_print_error_page(404, "Not found", "Invalid commit reference: %s", rev); return; diff --git a/ui-blob.c b/ui-blob.c index c10ae42..08f94ee 100644 --- a/ui-blob.c +++ b/ui-blob.c @@ -52,7 +52,7 @@ int cgit_ref_path_exists(const char *path, const char *ref, int file_only) .file_only = file_only }; - if (get_oid(ref, &oid)) + if (repo_get_oid(the_repository, ref, &oid)) goto done; if (oid_object_info(the_repository, &oid, &size) != OBJ_COMMIT) goto done; @@ -87,7 +87,7 @@ int cgit_print_file(char *path, const char *head, int file_only) .file_only = file_only }; - if (get_oid(head, &oid)) + if (repo_get_oid(the_repository, head, &oid)) return -1; type = oid_object_info(the_repository, &oid, &size); if (type == OBJ_COMMIT) { @@ -100,7 +100,7 @@ int cgit_print_file(char *path, const char *head, int file_only) } if (type == OBJ_BAD) return -1; - buf = read_object_file(&oid, &type, &size); + buf = repo_read_object_file(the_repository, &oid, &type, &size); if (!buf) return -1; buf[size] = '\0'; @@ -138,7 +138,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl return; } } else { - if (get_oid(head, &oid)) { + if (repo_get_oid(the_repository, head, &oid)) { cgit_print_error_page(404, "Not found", "Bad ref: %s", head); return; @@ -160,7 +160,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl return; } - buf = read_object_file(&oid, &type, &size); + buf = repo_read_object_file(the_repository, &oid, &type, &size); if (!buf) { cgit_print_error_page(500, "Internal server error", "Error reading object %s", hex); diff --git a/ui-commit.c b/ui-commit.c index 0787237..30672d0 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -26,7 +26,7 @@ void cgit_print_commit(char *hex, const char *prefix) if (!hex) hex = ctx.qry.head; - if (get_oid(hex, &oid)) { + if (repo_get_oid(the_repository, hex, &oid)) { cgit_print_error_page(400, "Bad request", "Bad object id: %s", hex); return; diff --git a/ui-diff.c b/ui-diff.c index 5ed5990..6f42dd4 100644 --- a/ui-diff.c +++ b/ui-diff.c @@ -258,8 +258,8 @@ static void header(const struct object_id *oid1, char *path1, int mode1, htmlf("
deleted file mode %.6o", mode1); if (!subproject) { - abbrev1 = xstrdup(find_unique_abbrev(oid1, DEFAULT_ABBREV)); - abbrev2 = xstrdup(find_unique_abbrev(oid2, DEFAULT_ABBREV)); + abbrev1 = xstrdup(repo_find_unique_abbrev(the_repository, oid1, DEFAULT_ABBREV)); + abbrev2 = xstrdup(repo_find_unique_abbrev(the_repository, oid2, DEFAULT_ABBREV)); htmlf("
index %s..%s", abbrev1, abbrev2); free(abbrev1); free(abbrev2); @@ -402,13 +402,13 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, if (!new_rev) new_rev = ctx.qry.head; - if (get_oid(new_rev, new_rev_oid)) { + if (repo_get_oid(the_repository, new_rev, new_rev_oid)) { cgit_print_error_page(404, "Not found", "Bad object name: %s", new_rev); return; } commit = lookup_commit_reference(the_repository, new_rev_oid); - if (!commit || parse_commit(commit)) { + if (!commit || repo_parse_commit(the_repository, commit)) { cgit_print_error_page(404, "Not found", "Bad commit: %s", oid_to_hex(new_rev_oid)); return; @@ -416,7 +416,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, new_tree_oid = get_commit_tree_oid(commit); if (old_rev) { - if (get_oid(old_rev, old_rev_oid)) { + if (repo_get_oid(the_repository, old_rev, old_rev_oid)) { cgit_print_error_page(404, "Not found", "Bad object name: %s", old_rev); return; @@ -429,7 +429,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, if (!is_null_oid(old_rev_oid)) { commit2 = lookup_commit_reference(the_repository, old_rev_oid); - if (!commit2 || parse_commit(commit2)) { + if (!commit2 || repo_parse_commit(the_repository, commit2)) { cgit_print_error_page(404, "Not found", "Bad commit: %s", oid_to_hex(old_rev_oid)); return; @@ -442,7 +442,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, if (raw) { struct diff_options diffopt; - diff_setup(&diffopt); + repo_diff_setup(the_repository, &diffopt); diffopt.output_format = DIFF_FORMAT_PATCH; diffopt.flags.recursive = 1; diff_setup_done(&diffopt); diff --git a/ui-log.c b/ui-log.c index 311304a..50d479d 100644 --- a/ui-log.c +++ b/ui-log.c @@ -146,7 +146,7 @@ static int show_commit(struct commit *commit, struct rev_info *revs) /* When we get here we have precisely one parent. */ parent = parents->item; /* If we can't parse the commit, let print_commit() report an error. */ - if (parse_commit(parent)) + if (repo_parse_commit(the_repository, parent)) return 1; files = 0; @@ -330,7 +330,7 @@ static const char *disambiguate_ref(const char *ref, int *must_free_result) struct strbuf longref = STRBUF_INIT; strbuf_addf(&longref, "refs/heads/%s", ref); - if (get_oid(longref.buf, &oid) == 0) { + if (repo_get_oid(the_repository, longref.buf, &oid) == 0) { *must_free_result = 1; return strbuf_detach(&longref, NULL); } @@ -430,7 +430,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern if (path) strvec_push(&rev_argv, path); - init_revisions(&rev, NULL); + repo_init_revisions(the_repository, &rev, NULL); rev.abbrev = DEFAULT_ABBREV; rev.commit_format = CMIT_FMT_DEFAULT; rev.verbose_header = 1; diff --git a/ui-patch.c b/ui-patch.c index 4ac03cb..3819a81 100644 --- a/ui-patch.c +++ b/ui-patch.c @@ -31,7 +31,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, if (!new_rev) new_rev = ctx.qry.head; - if (get_oid(new_rev, &new_rev_oid)) { + if (repo_get_oid(the_repository, new_rev, &new_rev_oid)) { cgit_print_error_page(404, "Not found", "Bad object id: %s", new_rev); return; @@ -44,7 +44,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, } if (old_rev) { - if (get_oid(old_rev, &old_rev_oid)) { + if (repo_get_oid(the_repository, old_rev, &old_rev_oid)) { cgit_print_error_page(404, "Not found", "Bad object id: %s", old_rev); return; @@ -78,7 +78,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, "%s%n%n%w(0)%b"; } - init_revisions(&rev, NULL); + repo_init_revisions(the_repository, &rev, NULL); rev.abbrev = DEFAULT_ABBREV; rev.verbose_header = 1; rev.diff = 1; diff --git a/ui-plain.c b/ui-plain.c index 65a205f..a66c5a1 100644 --- a/ui-plain.c +++ b/ui-plain.c @@ -28,7 +28,7 @@ static int print_object(const struct object_id *oid, const char *path) return 0; } - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) { cgit_print_error_page(404, "Not found", "Not found"); return 0; @@ -181,12 +181,12 @@ void cgit_print_plain(void) if (!rev) rev = ctx.qry.head; - if (get_oid(rev, &oid)) { + if (repo_get_oid(the_repository, rev, &oid)) { cgit_print_error_page(404, "Not found", "Not found"); return; } commit = lookup_commit_reference(the_repository, &oid); - if (!commit || parse_commit(commit)) { + if (!commit || repo_parse_commit(the_repository, commit)) { cgit_print_error_page(404, "Not found", "Not found"); return; } diff --git a/ui-shared.c b/ui-shared.c index baea6f2..eef2aa8 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -1188,11 +1188,11 @@ void cgit_compose_snapshot_prefix(struct strbuf *filename, const char *base, * name starts with {v,V}[0-9] and the prettify mapping is injective, * i.e. each stripped tag can be inverted without ambiguities. */ - if (get_oid(fmt("refs/tags/%s", ref), &oid) == 0 && + if (repo_get_oid(the_repository, fmt("refs/tags/%s", ref), &oid) == 0 && (ref[0] == 'v' || ref[0] == 'V') && isdigit(ref[1]) && - ((get_oid(fmt("refs/tags/%s", ref + 1), &oid) == 0) + - (get_oid(fmt("refs/tags/v%s", ref + 1), &oid) == 0) + - (get_oid(fmt("refs/tags/V%s", ref + 1), &oid) == 0) == 1)) + ((repo_get_oid(the_repository, fmt("refs/tags/%s", ref + 1), &oid) == 0) + + (repo_get_oid(the_repository, fmt("refs/tags/v%s", ref + 1), &oid) == 0) + + (repo_get_oid(the_repository, fmt("refs/tags/V%s", ref + 1), &oid) == 0) == 1)) ref++; strbuf_addf(filename, "%s-%s", base, ref); diff --git a/ui-snapshot.c b/ui-snapshot.c index 18361a6..9f629a9 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c @@ -117,7 +117,7 @@ const struct object_id *cgit_snapshot_get_sig(const char *ref, struct notes_tree *tree; struct object_id oid; - if (get_oid(ref, &oid)) + if (repo_get_oid(the_repository, ref, &oid)) return NULL; tree = &snapshot_sig_notes[f - &cgit_snapshot_formats[0]]; @@ -156,7 +156,7 @@ static int make_snapshot(const struct cgit_snapshot_format *format, { struct object_id oid; - if (get_oid(hex, &oid)) { + if (repo_get_oid(the_repository, hex, &oid)) { cgit_print_error_page(404, "Not found", "Bad object id: %s", hex); return 1; @@ -190,7 +190,7 @@ static int write_sig(const struct cgit_snapshot_format *format, return 0; } - buf = read_object_file(note, &type, &size); + buf = repo_read_object_file(the_repository, note, &type, &size); if (!buf) { cgit_print_error_page(404, "Not found", "Not found"); return 0; @@ -230,7 +230,7 @@ static const char *get_ref_from_filename(const struct cgit_repo *repo, strbuf_addstr(&snapshot, filename); strbuf_setlen(&snapshot, snapshot.len - strlen(format->suffix)); - if (get_oid(snapshot.buf, &oid) == 0) + if (repo_get_oid(the_repository, snapshot.buf, &oid) == 0) goto out; reponame = cgit_snapshot_prefix(repo); @@ -242,15 +242,15 @@ static const char *get_ref_from_filename(const struct cgit_repo *repo, strbuf_splice(&snapshot, 0, new_start - snapshot.buf, "", 0); } - if (get_oid(snapshot.buf, &oid) == 0) + if (repo_get_oid(the_repository, snapshot.buf, &oid) == 0) goto out; strbuf_insert(&snapshot, 0, "v", 1); - if (get_oid(snapshot.buf, &oid) == 0) + if (repo_get_oid(the_repository, snapshot.buf, &oid) == 0) goto out; strbuf_splice(&snapshot, 0, 1, "V", 1); - if (get_oid(snapshot.buf, &oid) == 0) + if (repo_get_oid(the_repository, snapshot.buf, &oid) == 0) goto out; result = 0; diff --git a/ui-stats.c b/ui-stats.c index 40ed6c2..9aed4ac 100644 --- a/ui-stats.c +++ b/ui-stats.c @@ -230,7 +230,7 @@ static struct string_list collect_stats(const struct cgit_period *period) argv[4] = ctx.qry.path; argc += 2; } - init_revisions(&rev, NULL); + repo_init_revisions(the_repository, &rev, NULL); rev.abbrev = DEFAULT_ABBREV; rev.commit_format = CMIT_FMT_DEFAULT; rev.max_parents = 1; diff --git a/ui-tag.c b/ui-tag.c index 424bbcc..5354827 100644 --- a/ui-tag.c +++ b/ui-tag.c @@ -48,7 +48,7 @@ void cgit_print_tag(char *revname) revname = ctx.qry.head; strbuf_addf(&fullref, "refs/tags/%s", revname); - if (get_oid(fullref.buf, &oid)) { + if (repo_get_oid(the_repository, fullref.buf, &oid)) { cgit_print_error_page(404, "Not found", "Bad tag reference: %s", revname); goto cleanup; diff --git a/ui-tree.c b/ui-tree.c index 98ce1ca..0640336 100644 --- a/ui-tree.c +++ b/ui-tree.c @@ -98,7 +98,7 @@ static void print_object(const struct object_id *oid, const char *path, const ch return; } - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) { cgit_print_error_page(500, "Internal server error", "Error reading object %s", oid_to_hex(oid)); @@ -242,7 +242,7 @@ static int ls_item(const struct object_id *oid, struct strbuf *base, } if (S_ISLNK(mode)) { html(" -> "); - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) { htmlf("Error reading object: %s", oid_to_hex(oid)); goto cleanup; @@ -372,13 +372,13 @@ void cgit_print_tree(const char *rev, char *path) if (!rev) rev = ctx.qry.head; - if (get_oid(rev, &oid)) { + if (repo_get_oid(the_repository, rev, &oid)) { cgit_print_error_page(404, "Not found", "Invalid revision name: %s", rev); return; } commit = lookup_commit_reference(the_repository, &oid); - if (!commit || parse_commit(commit)) { + if (!commit || repo_parse_commit(the_repository, commit)) { cgit_print_error_page(404, "Not found", "Invalid commit reference: %s", rev); return; -- 2.40.1 From list at eworm.de Sat May 20 20:39:49 2023 From: list at eworm.de (Christian Hesse) Date: Sat, 20 May 2023 22:39:49 +0200 Subject: [PATCH 1/1] RFC: git: update to v2.41.0-rc1 Message-ID: <20230520203949.43821-1-list@eworm.de> From: Christian Hesse Update to git version v2.41.0-rc1, lots of changes... Upstream commits to be referenced... Signed-off-by: Christian Hesse --- Makefile | 4 ++-- cgit.c | 2 +- cgit.h | 30 +++++++++++++++++------------- git | 2 +- parsing.c | 2 +- shared.c | 16 ++++++++++------ ui-atom.c | 2 +- ui-blame.c | 12 ++++++------ ui-blob.c | 10 +++++----- ui-commit.c | 2 +- ui-diff.c | 14 +++++++------- ui-log.c | 6 +++--- ui-patch.c | 6 +++--- ui-plain.c | 6 +++--- ui-shared.c | 8 ++++---- ui-snapshot.c | 14 +++++++------- ui-stats.c | 2 +- ui-tag.c | 2 +- ui-tree.c | 8 ++++---- 19 files changed, 78 insertions(+), 70 deletions(-) diff --git a/Makefile b/Makefile index 3fc1d5a..9d7fc63 100644 --- a/Makefile +++ b/Makefile @@ -14,8 +14,8 @@ htmldir = $(docdir) pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = -GIT_VER = 2.40.1 -GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz +GIT_VER = 2.41.0.rc1 +GIT_URL = https://www.kernel.org/pub/software/scm/git/testing/git-$(GIT_VER).tar.xz INSTALL = install COPYTREE = cp -r MAN5_TXT = $(wildcard *.5.txt) diff --git a/cgit.c b/cgit.c index 57d7097..e616292 100644 --- a/cgit.c +++ b/cgit.c @@ -631,7 +631,7 @@ static int prepare_repo_cmd(int nongit) return 1; } - if (get_oid(ctx.qry.head, &oid)) { + if (repo_get_oid(the_repository, ctx.qry.head, &oid)) { char *old_head = ctx.qry.head; ctx.qry.head = xstrdup(ctx.repo->defbranch); cgit_print_error_page(404, "Not found", diff --git a/cgit.h b/cgit.h index ddd2ccb..f788fd2 100644 --- a/cgit.h +++ b/cgit.h @@ -1,31 +1,35 @@ #ifndef CGIT_H #define CGIT_H +#include #include -#include +#include #include +#include +#include +#include +#include +#include #include +#include +#include +#include #include +#include #include -#include -#include -#include -#include -#include -#include #include #include -#include -#include +#include #include +#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include /* Add isgraph(x) to Git's sane ctype support (see git-compat-util.h) */ #undef isgraph diff --git a/git b/git index 0d1bd1d..4a714b3 160000 --- a/git +++ b/git @@ -1 +1 @@ -Subproject commit 0d1bd1dfb37ef25e1911777c94129fc769ffec38 +Subproject commit 4a714b37029a4b63dbd22f7d7ed81f7a0d693680 diff --git a/parsing.c b/parsing.c index 72b59b3..dc44ffd 100644 --- a/parsing.c +++ b/parsing.c @@ -198,7 +198,7 @@ struct taginfo *cgit_parse_tag(struct tag *tag) const char *p; struct taginfo *ret = NULL; - data = read_object_file(&tag->object.oid, &type, &size); + data = repo_read_object_file(the_repository, &tag->object.oid, &type, &size); if (!data || type != OBJ_TAG) goto cleanup; diff --git a/shared.c b/shared.c index 0bceb98..8a6d0e9 100644 --- a/shared.c +++ b/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,9 +566,11 @@ 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); } diff --git a/ui-atom.c b/ui-atom.c index 5f4ad7d..636cb7e 100644 --- a/ui-atom.c +++ b/ui-atom.c @@ -97,7 +97,7 @@ void cgit_print_atom(char *tip, const char *path, int max_count) argv[argc++] = path; } - init_revisions(&rev, NULL); + repo_init_revisions(the_repository, &rev, NULL); rev.abbrev = DEFAULT_ABBREV; rev.commit_format = CMIT_FMT_DEFAULT; rev.verbose_header = 1; diff --git a/ui-blame.c b/ui-blame.c index aedce8d..e0f0593 100644 --- a/ui-blame.c +++ b/ui-blame.c @@ -49,12 +49,12 @@ static void emit_blame_entry_hash(struct blame_entry *ent) char *detail = emit_suspect_detail(suspect); html(""); - cgit_commit_link(find_unique_abbrev(oid, DEFAULT_ABBREV), detail, + cgit_commit_link(repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV), detail, NULL, ctx.qry.head, oid_to_hex(oid), suspect->path); html(""); free(detail); - if (!parse_commit(suspect->commit) && suspect->commit->parents) { + if (!repo_parse_commit(the_repository, suspect->commit) && suspect->commit->parents) { struct commit *parent = suspect->commit->parents->item; html(" "); @@ -126,7 +126,7 @@ static void print_object(const struct object_id *oid, const char *path, return; } - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) { cgit_print_error_page(500, "Internal server error", "Error reading object %s", oid_to_hex(oid)); @@ -135,7 +135,7 @@ static void print_object(const struct object_id *oid, const char *path, strvec_push(&rev_argv, "blame"); strvec_push(&rev_argv, rev); - init_revisions(&revs, NULL); + repo_init_revisions(the_repository, &revs, NULL); revs.diffopt.flags.allow_textconv = 1; setup_revisions(rev_argv.nr, rev_argv.v, &revs, NULL); init_scoreboard(&sb); @@ -287,13 +287,13 @@ void cgit_print_blame(void) if (!rev) rev = ctx.qry.head; - if (get_oid(rev, &oid)) { + if (repo_get_oid(the_repository, rev, &oid)) { cgit_print_error_page(404, "Not found", "Invalid revision name: %s", rev); return; } commit = lookup_commit_reference(the_repository, &oid); - if (!commit || parse_commit(commit)) { + if (!commit || repo_parse_commit(the_repository, commit)) { cgit_print_error_page(404, "Not found", "Invalid commit reference: %s", rev); return; diff --git a/ui-blob.c b/ui-blob.c index c10ae42..08f94ee 100644 --- a/ui-blob.c +++ b/ui-blob.c @@ -52,7 +52,7 @@ int cgit_ref_path_exists(const char *path, const char *ref, int file_only) .file_only = file_only }; - if (get_oid(ref, &oid)) + if (repo_get_oid(the_repository, ref, &oid)) goto done; if (oid_object_info(the_repository, &oid, &size) != OBJ_COMMIT) goto done; @@ -87,7 +87,7 @@ int cgit_print_file(char *path, const char *head, int file_only) .file_only = file_only }; - if (get_oid(head, &oid)) + if (repo_get_oid(the_repository, head, &oid)) return -1; type = oid_object_info(the_repository, &oid, &size); if (type == OBJ_COMMIT) { @@ -100,7 +100,7 @@ int cgit_print_file(char *path, const char *head, int file_only) } if (type == OBJ_BAD) return -1; - buf = read_object_file(&oid, &type, &size); + buf = repo_read_object_file(the_repository, &oid, &type, &size); if (!buf) return -1; buf[size] = '\0'; @@ -138,7 +138,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl return; } } else { - if (get_oid(head, &oid)) { + if (repo_get_oid(the_repository, head, &oid)) { cgit_print_error_page(404, "Not found", "Bad ref: %s", head); return; @@ -160,7 +160,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl return; } - buf = read_object_file(&oid, &type, &size); + buf = repo_read_object_file(the_repository, &oid, &type, &size); if (!buf) { cgit_print_error_page(500, "Internal server error", "Error reading object %s", hex); diff --git a/ui-commit.c b/ui-commit.c index 0787237..30672d0 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -26,7 +26,7 @@ void cgit_print_commit(char *hex, const char *prefix) if (!hex) hex = ctx.qry.head; - if (get_oid(hex, &oid)) { + if (repo_get_oid(the_repository, hex, &oid)) { cgit_print_error_page(400, "Bad request", "Bad object id: %s", hex); return; diff --git a/ui-diff.c b/ui-diff.c index 5ed5990..6f42dd4 100644 --- a/ui-diff.c +++ b/ui-diff.c @@ -258,8 +258,8 @@ static void header(const struct object_id *oid1, char *path1, int mode1, htmlf("
deleted file mode %.6o", mode1); if (!subproject) { - abbrev1 = xstrdup(find_unique_abbrev(oid1, DEFAULT_ABBREV)); - abbrev2 = xstrdup(find_unique_abbrev(oid2, DEFAULT_ABBREV)); + abbrev1 = xstrdup(repo_find_unique_abbrev(the_repository, oid1, DEFAULT_ABBREV)); + abbrev2 = xstrdup(repo_find_unique_abbrev(the_repository, oid2, DEFAULT_ABBREV)); htmlf("
index %s..%s", abbrev1, abbrev2); free(abbrev1); free(abbrev2); @@ -402,13 +402,13 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, if (!new_rev) new_rev = ctx.qry.head; - if (get_oid(new_rev, new_rev_oid)) { + if (repo_get_oid(the_repository, new_rev, new_rev_oid)) { cgit_print_error_page(404, "Not found", "Bad object name: %s", new_rev); return; } commit = lookup_commit_reference(the_repository, new_rev_oid); - if (!commit || parse_commit(commit)) { + if (!commit || repo_parse_commit(the_repository, commit)) { cgit_print_error_page(404, "Not found", "Bad commit: %s", oid_to_hex(new_rev_oid)); return; @@ -416,7 +416,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, new_tree_oid = get_commit_tree_oid(commit); if (old_rev) { - if (get_oid(old_rev, old_rev_oid)) { + if (repo_get_oid(the_repository, old_rev, old_rev_oid)) { cgit_print_error_page(404, "Not found", "Bad object name: %s", old_rev); return; @@ -429,7 +429,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, if (!is_null_oid(old_rev_oid)) { commit2 = lookup_commit_reference(the_repository, old_rev_oid); - if (!commit2 || parse_commit(commit2)) { + if (!commit2 || repo_parse_commit(the_repository, commit2)) { cgit_print_error_page(404, "Not found", "Bad commit: %s", oid_to_hex(old_rev_oid)); return; @@ -442,7 +442,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, if (raw) { struct diff_options diffopt; - diff_setup(&diffopt); + repo_diff_setup(the_repository, &diffopt); diffopt.output_format = DIFF_FORMAT_PATCH; diffopt.flags.recursive = 1; diff_setup_done(&diffopt); diff --git a/ui-log.c b/ui-log.c index 311304a..50d479d 100644 --- a/ui-log.c +++ b/ui-log.c @@ -146,7 +146,7 @@ static int show_commit(struct commit *commit, struct rev_info *revs) /* When we get here we have precisely one parent. */ parent = parents->item; /* If we can't parse the commit, let print_commit() report an error. */ - if (parse_commit(parent)) + if (repo_parse_commit(the_repository, parent)) return 1; files = 0; @@ -330,7 +330,7 @@ static const char *disambiguate_ref(const char *ref, int *must_free_result) struct strbuf longref = STRBUF_INIT; strbuf_addf(&longref, "refs/heads/%s", ref); - if (get_oid(longref.buf, &oid) == 0) { + if (repo_get_oid(the_repository, longref.buf, &oid) == 0) { *must_free_result = 1; return strbuf_detach(&longref, NULL); } @@ -430,7 +430,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern if (path) strvec_push(&rev_argv, path); - init_revisions(&rev, NULL); + repo_init_revisions(the_repository, &rev, NULL); rev.abbrev = DEFAULT_ABBREV; rev.commit_format = CMIT_FMT_DEFAULT; rev.verbose_header = 1; diff --git a/ui-patch.c b/ui-patch.c index 4ac03cb..3819a81 100644 --- a/ui-patch.c +++ b/ui-patch.c @@ -31,7 +31,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, if (!new_rev) new_rev = ctx.qry.head; - if (get_oid(new_rev, &new_rev_oid)) { + if (repo_get_oid(the_repository, new_rev, &new_rev_oid)) { cgit_print_error_page(404, "Not found", "Bad object id: %s", new_rev); return; @@ -44,7 +44,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, } if (old_rev) { - if (get_oid(old_rev, &old_rev_oid)) { + if (repo_get_oid(the_repository, old_rev, &old_rev_oid)) { cgit_print_error_page(404, "Not found", "Bad object id: %s", old_rev); return; @@ -78,7 +78,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, "%s%n%n%w(0)%b"; } - init_revisions(&rev, NULL); + repo_init_revisions(the_repository, &rev, NULL); rev.abbrev = DEFAULT_ABBREV; rev.verbose_header = 1; rev.diff = 1; diff --git a/ui-plain.c b/ui-plain.c index 65a205f..a66c5a1 100644 --- a/ui-plain.c +++ b/ui-plain.c @@ -28,7 +28,7 @@ static int print_object(const struct object_id *oid, const char *path) return 0; } - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) { cgit_print_error_page(404, "Not found", "Not found"); return 0; @@ -181,12 +181,12 @@ void cgit_print_plain(void) if (!rev) rev = ctx.qry.head; - if (get_oid(rev, &oid)) { + if (repo_get_oid(the_repository, rev, &oid)) { cgit_print_error_page(404, "Not found", "Not found"); return; } commit = lookup_commit_reference(the_repository, &oid); - if (!commit || parse_commit(commit)) { + if (!commit || repo_parse_commit(the_repository, commit)) { cgit_print_error_page(404, "Not found", "Not found"); return; } diff --git a/ui-shared.c b/ui-shared.c index baea6f2..eef2aa8 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -1188,11 +1188,11 @@ void cgit_compose_snapshot_prefix(struct strbuf *filename, const char *base, * name starts with {v,V}[0-9] and the prettify mapping is injective, * i.e. each stripped tag can be inverted without ambiguities. */ - if (get_oid(fmt("refs/tags/%s", ref), &oid) == 0 && + if (repo_get_oid(the_repository, fmt("refs/tags/%s", ref), &oid) == 0 && (ref[0] == 'v' || ref[0] == 'V') && isdigit(ref[1]) && - ((get_oid(fmt("refs/tags/%s", ref + 1), &oid) == 0) + - (get_oid(fmt("refs/tags/v%s", ref + 1), &oid) == 0) + - (get_oid(fmt("refs/tags/V%s", ref + 1), &oid) == 0) == 1)) + ((repo_get_oid(the_repository, fmt("refs/tags/%s", ref + 1), &oid) == 0) + + (repo_get_oid(the_repository, fmt("refs/tags/v%s", ref + 1), &oid) == 0) + + (repo_get_oid(the_repository, fmt("refs/tags/V%s", ref + 1), &oid) == 0) == 1)) ref++; strbuf_addf(filename, "%s-%s", base, ref); diff --git a/ui-snapshot.c b/ui-snapshot.c index 18361a6..9f629a9 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c @@ -117,7 +117,7 @@ const struct object_id *cgit_snapshot_get_sig(const char *ref, struct notes_tree *tree; struct object_id oid; - if (get_oid(ref, &oid)) + if (repo_get_oid(the_repository, ref, &oid)) return NULL; tree = &snapshot_sig_notes[f - &cgit_snapshot_formats[0]]; @@ -156,7 +156,7 @@ static int make_snapshot(const struct cgit_snapshot_format *format, { struct object_id oid; - if (get_oid(hex, &oid)) { + if (repo_get_oid(the_repository, hex, &oid)) { cgit_print_error_page(404, "Not found", "Bad object id: %s", hex); return 1; @@ -190,7 +190,7 @@ static int write_sig(const struct cgit_snapshot_format *format, return 0; } - buf = read_object_file(note, &type, &size); + buf = repo_read_object_file(the_repository, note, &type, &size); if (!buf) { cgit_print_error_page(404, "Not found", "Not found"); return 0; @@ -230,7 +230,7 @@ static const char *get_ref_from_filename(const struct cgit_repo *repo, strbuf_addstr(&snapshot, filename); strbuf_setlen(&snapshot, snapshot.len - strlen(format->suffix)); - if (get_oid(snapshot.buf, &oid) == 0) + if (repo_get_oid(the_repository, snapshot.buf, &oid) == 0) goto out; reponame = cgit_snapshot_prefix(repo); @@ -242,15 +242,15 @@ static const char *get_ref_from_filename(const struct cgit_repo *repo, strbuf_splice(&snapshot, 0, new_start - snapshot.buf, "", 0); } - if (get_oid(snapshot.buf, &oid) == 0) + if (repo_get_oid(the_repository, snapshot.buf, &oid) == 0) goto out; strbuf_insert(&snapshot, 0, "v", 1); - if (get_oid(snapshot.buf, &oid) == 0) + if (repo_get_oid(the_repository, snapshot.buf, &oid) == 0) goto out; strbuf_splice(&snapshot, 0, 1, "V", 1); - if (get_oid(snapshot.buf, &oid) == 0) + if (repo_get_oid(the_repository, snapshot.buf, &oid) == 0) goto out; result = 0; diff --git a/ui-stats.c b/ui-stats.c index 40ed6c2..9aed4ac 100644 --- a/ui-stats.c +++ b/ui-stats.c @@ -230,7 +230,7 @@ static struct string_list collect_stats(const struct cgit_period *period) argv[4] = ctx.qry.path; argc += 2; } - init_revisions(&rev, NULL); + repo_init_revisions(the_repository, &rev, NULL); rev.abbrev = DEFAULT_ABBREV; rev.commit_format = CMIT_FMT_DEFAULT; rev.max_parents = 1; diff --git a/ui-tag.c b/ui-tag.c index 424bbcc..5354827 100644 --- a/ui-tag.c +++ b/ui-tag.c @@ -48,7 +48,7 @@ void cgit_print_tag(char *revname) revname = ctx.qry.head; strbuf_addf(&fullref, "refs/tags/%s", revname); - if (get_oid(fullref.buf, &oid)) { + if (repo_get_oid(the_repository, fullref.buf, &oid)) { cgit_print_error_page(404, "Not found", "Bad tag reference: %s", revname); goto cleanup; diff --git a/ui-tree.c b/ui-tree.c index 98ce1ca..0640336 100644 --- a/ui-tree.c +++ b/ui-tree.c @@ -98,7 +98,7 @@ static void print_object(const struct object_id *oid, const char *path, const ch return; } - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) { cgit_print_error_page(500, "Internal server error", "Error reading object %s", oid_to_hex(oid)); @@ -242,7 +242,7 @@ static int ls_item(const struct object_id *oid, struct strbuf *base, } if (S_ISLNK(mode)) { html(" -> "); - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) { htmlf("Error reading object: %s", oid_to_hex(oid)); goto cleanup; @@ -372,13 +372,13 @@ void cgit_print_tree(const char *rev, char *path) if (!rev) rev = ctx.qry.head; - if (get_oid(rev, &oid)) { + if (repo_get_oid(the_repository, rev, &oid)) { cgit_print_error_page(404, "Not found", "Invalid revision name: %s", rev); return; } commit = lookup_commit_reference(the_repository, &oid); - if (!commit || parse_commit(commit)) { + if (!commit || repo_parse_commit(the_repository, commit)) { cgit_print_error_page(404, "Not found", "Invalid commit reference: %s", rev); return; -- 2.40.1 From list at eworm.de Fri May 26 11:06:46 2023 From: list at eworm.de (Christian Hesse) Date: Fri, 26 May 2023 13:06:46 +0200 Subject: [PATCH 1/1] RFC: git: update to v2.41.0-rc2 Message-ID: <20230526110646.60621-1-list@eworm.de> From: Christian Hesse Update to git version v2.41.0-rc2, with lots of changes... This requires changes for these upstream commits: * 60ff56f50372c1498718938ef504e744fe011ffb banned.h: mark `strtok()` and `strtok_r()` as banned * 52acddf36c8cb3778ab2098a0d95cc2e375a4069 string-list: multi-delimiter `string_list_split_in_place()` * d850b7a545fcfbd97460a921c7f7c59d933eb0f7 cocci: apply the "cache.h" part of "the_repository.pending" * cb338c23d6d518947bf6f7240bf30e2ec232bd3b cocci: apply the "commit-reach.h" part of "the_repository.pending" * ecb5091fd4301ac647db0bd2504112b38f7ee06d cocci: apply the "commit.h" part of "the_repository.pending" * 085390328f5fe1dfba67039b1fd6cc51546a4e41 cocci: apply the "diff.h" part of "the_repository.pending" * bc726bd075929aab6b3e09d4dd5c2b0726fd5350 cocci: apply the "object-store.h" part of "the_repository.pending" * bab821646a74c446370fa8d01ca851f247df5033 cocci: apply the "pretty.h" part of "the_repository.pending" * afe27c889429438829bc8818ed17e4960bd3ef02 cocci: apply the "packfile.h" part of "the_repository.pending" * 12cb1c10a64170a5d600dd1c6c8abfeec105fb6b cocci: apply the "refs.h" part of "the_repository.pending" * 035c7de9e9ea11d26df5f9e4bb117f91ed11a9fd cocci: apply the "revision.h" part of "the_repository.pending" ... and possibly more I missed to list. ? Signed-off-by: Christian Hesse --- Makefile | 4 ++-- cgit.c | 2 +- cgit.h | 30 +++++++++++++++++------------- git | 2 +- parsing.c | 2 +- shared.c | 16 ++++++++++------ ui-atom.c | 2 +- ui-blame.c | 12 ++++++------ ui-blob.c | 10 +++++----- ui-commit.c | 2 +- ui-diff.c | 14 +++++++------- ui-log.c | 6 +++--- ui-patch.c | 6 +++--- ui-plain.c | 6 +++--- ui-shared.c | 8 ++++---- ui-snapshot.c | 14 +++++++------- ui-stats.c | 2 +- ui-tag.c | 2 +- ui-tree.c | 8 ++++---- 19 files changed, 78 insertions(+), 70 deletions(-) diff --git a/Makefile b/Makefile index 3fc1d5a..b903c09 100644 --- a/Makefile +++ b/Makefile @@ -14,8 +14,8 @@ htmldir = $(docdir) pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = -GIT_VER = 2.40.1 -GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz +GIT_VER = 2.41.0.rc2 +GIT_URL = https://www.kernel.org/pub/software/scm/git/testing/git-$(GIT_VER).tar.xz INSTALL = install COPYTREE = cp -r MAN5_TXT = $(wildcard *.5.txt) diff --git a/cgit.c b/cgit.c index 57d7097..e616292 100644 --- a/cgit.c +++ b/cgit.c @@ -631,7 +631,7 @@ static int prepare_repo_cmd(int nongit) return 1; } - if (get_oid(ctx.qry.head, &oid)) { + if (repo_get_oid(the_repository, ctx.qry.head, &oid)) { char *old_head = ctx.qry.head; ctx.qry.head = xstrdup(ctx.repo->defbranch); cgit_print_error_page(404, "Not found", diff --git a/cgit.h b/cgit.h index ddd2ccb..f788fd2 100644 --- a/cgit.h +++ b/cgit.h @@ -1,31 +1,35 @@ #ifndef CGIT_H #define CGIT_H +#include #include -#include +#include #include +#include +#include +#include +#include +#include #include +#include +#include +#include #include +#include #include -#include -#include -#include -#include -#include -#include #include #include -#include -#include +#include #include +#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include /* Add isgraph(x) to Git's sane ctype support (see git-compat-util.h) */ #undef isgraph diff --git a/git b/git index 0d1bd1d..79bdd48 160000 --- a/git +++ b/git @@ -1 +1 @@ -Subproject commit 0d1bd1dfb37ef25e1911777c94129fc769ffec38 +Subproject commit 79bdd48716a4c455bdc8ffd91d57a18d5cd55baa diff --git a/parsing.c b/parsing.c index 72b59b3..dc44ffd 100644 --- a/parsing.c +++ b/parsing.c @@ -198,7 +198,7 @@ struct taginfo *cgit_parse_tag(struct tag *tag) const char *p; struct taginfo *ret = NULL; - data = read_object_file(&tag->object.oid, &type, &size); + data = repo_read_object_file(the_repository, &tag->object.oid, &type, &size); if (!data || type != OBJ_TAG) goto cleanup; diff --git a/shared.c b/shared.c index 0bceb98..8a6d0e9 100644 --- a/shared.c +++ b/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,9 +566,11 @@ 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); } diff --git a/ui-atom.c b/ui-atom.c index 5f4ad7d..636cb7e 100644 --- a/ui-atom.c +++ b/ui-atom.c @@ -97,7 +97,7 @@ void cgit_print_atom(char *tip, const char *path, int max_count) argv[argc++] = path; } - init_revisions(&rev, NULL); + repo_init_revisions(the_repository, &rev, NULL); rev.abbrev = DEFAULT_ABBREV; rev.commit_format = CMIT_FMT_DEFAULT; rev.verbose_header = 1; diff --git a/ui-blame.c b/ui-blame.c index aedce8d..e0f0593 100644 --- a/ui-blame.c +++ b/ui-blame.c @@ -49,12 +49,12 @@ static void emit_blame_entry_hash(struct blame_entry *ent) char *detail = emit_suspect_detail(suspect); html(""); - cgit_commit_link(find_unique_abbrev(oid, DEFAULT_ABBREV), detail, + cgit_commit_link(repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV), detail, NULL, ctx.qry.head, oid_to_hex(oid), suspect->path); html(""); free(detail); - if (!parse_commit(suspect->commit) && suspect->commit->parents) { + if (!repo_parse_commit(the_repository, suspect->commit) && suspect->commit->parents) { struct commit *parent = suspect->commit->parents->item; html(" "); @@ -126,7 +126,7 @@ static void print_object(const struct object_id *oid, const char *path, return; } - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) { cgit_print_error_page(500, "Internal server error", "Error reading object %s", oid_to_hex(oid)); @@ -135,7 +135,7 @@ static void print_object(const struct object_id *oid, const char *path, strvec_push(&rev_argv, "blame"); strvec_push(&rev_argv, rev); - init_revisions(&revs, NULL); + repo_init_revisions(the_repository, &revs, NULL); revs.diffopt.flags.allow_textconv = 1; setup_revisions(rev_argv.nr, rev_argv.v, &revs, NULL); init_scoreboard(&sb); @@ -287,13 +287,13 @@ void cgit_print_blame(void) if (!rev) rev = ctx.qry.head; - if (get_oid(rev, &oid)) { + if (repo_get_oid(the_repository, rev, &oid)) { cgit_print_error_page(404, "Not found", "Invalid revision name: %s", rev); return; } commit = lookup_commit_reference(the_repository, &oid); - if (!commit || parse_commit(commit)) { + if (!commit || repo_parse_commit(the_repository, commit)) { cgit_print_error_page(404, "Not found", "Invalid commit reference: %s", rev); return; diff --git a/ui-blob.c b/ui-blob.c index c10ae42..08f94ee 100644 --- a/ui-blob.c +++ b/ui-blob.c @@ -52,7 +52,7 @@ int cgit_ref_path_exists(const char *path, const char *ref, int file_only) .file_only = file_only }; - if (get_oid(ref, &oid)) + if (repo_get_oid(the_repository, ref, &oid)) goto done; if (oid_object_info(the_repository, &oid, &size) != OBJ_COMMIT) goto done; @@ -87,7 +87,7 @@ int cgit_print_file(char *path, const char *head, int file_only) .file_only = file_only }; - if (get_oid(head, &oid)) + if (repo_get_oid(the_repository, head, &oid)) return -1; type = oid_object_info(the_repository, &oid, &size); if (type == OBJ_COMMIT) { @@ -100,7 +100,7 @@ int cgit_print_file(char *path, const char *head, int file_only) } if (type == OBJ_BAD) return -1; - buf = read_object_file(&oid, &type, &size); + buf = repo_read_object_file(the_repository, &oid, &type, &size); if (!buf) return -1; buf[size] = '\0'; @@ -138,7 +138,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl return; } } else { - if (get_oid(head, &oid)) { + if (repo_get_oid(the_repository, head, &oid)) { cgit_print_error_page(404, "Not found", "Bad ref: %s", head); return; @@ -160,7 +160,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl return; } - buf = read_object_file(&oid, &type, &size); + buf = repo_read_object_file(the_repository, &oid, &type, &size); if (!buf) { cgit_print_error_page(500, "Internal server error", "Error reading object %s", hex); diff --git a/ui-commit.c b/ui-commit.c index 0787237..30672d0 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -26,7 +26,7 @@ void cgit_print_commit(char *hex, const char *prefix) if (!hex) hex = ctx.qry.head; - if (get_oid(hex, &oid)) { + if (repo_get_oid(the_repository, hex, &oid)) { cgit_print_error_page(400, "Bad request", "Bad object id: %s", hex); return; diff --git a/ui-diff.c b/ui-diff.c index 5ed5990..6f42dd4 100644 --- a/ui-diff.c +++ b/ui-diff.c @@ -258,8 +258,8 @@ static void header(const struct object_id *oid1, char *path1, int mode1, htmlf("
deleted file mode %.6o", mode1); if (!subproject) { - abbrev1 = xstrdup(find_unique_abbrev(oid1, DEFAULT_ABBREV)); - abbrev2 = xstrdup(find_unique_abbrev(oid2, DEFAULT_ABBREV)); + abbrev1 = xstrdup(repo_find_unique_abbrev(the_repository, oid1, DEFAULT_ABBREV)); + abbrev2 = xstrdup(repo_find_unique_abbrev(the_repository, oid2, DEFAULT_ABBREV)); htmlf("
index %s..%s", abbrev1, abbrev2); free(abbrev1); free(abbrev2); @@ -402,13 +402,13 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, if (!new_rev) new_rev = ctx.qry.head; - if (get_oid(new_rev, new_rev_oid)) { + if (repo_get_oid(the_repository, new_rev, new_rev_oid)) { cgit_print_error_page(404, "Not found", "Bad object name: %s", new_rev); return; } commit = lookup_commit_reference(the_repository, new_rev_oid); - if (!commit || parse_commit(commit)) { + if (!commit || repo_parse_commit(the_repository, commit)) { cgit_print_error_page(404, "Not found", "Bad commit: %s", oid_to_hex(new_rev_oid)); return; @@ -416,7 +416,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, new_tree_oid = get_commit_tree_oid(commit); if (old_rev) { - if (get_oid(old_rev, old_rev_oid)) { + if (repo_get_oid(the_repository, old_rev, old_rev_oid)) { cgit_print_error_page(404, "Not found", "Bad object name: %s", old_rev); return; @@ -429,7 +429,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, if (!is_null_oid(old_rev_oid)) { commit2 = lookup_commit_reference(the_repository, old_rev_oid); - if (!commit2 || parse_commit(commit2)) { + if (!commit2 || repo_parse_commit(the_repository, commit2)) { cgit_print_error_page(404, "Not found", "Bad commit: %s", oid_to_hex(old_rev_oid)); return; @@ -442,7 +442,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, if (raw) { struct diff_options diffopt; - diff_setup(&diffopt); + repo_diff_setup(the_repository, &diffopt); diffopt.output_format = DIFF_FORMAT_PATCH; diffopt.flags.recursive = 1; diff_setup_done(&diffopt); diff --git a/ui-log.c b/ui-log.c index 311304a..50d479d 100644 --- a/ui-log.c +++ b/ui-log.c @@ -146,7 +146,7 @@ static int show_commit(struct commit *commit, struct rev_info *revs) /* When we get here we have precisely one parent. */ parent = parents->item; /* If we can't parse the commit, let print_commit() report an error. */ - if (parse_commit(parent)) + if (repo_parse_commit(the_repository, parent)) return 1; files = 0; @@ -330,7 +330,7 @@ static const char *disambiguate_ref(const char *ref, int *must_free_result) struct strbuf longref = STRBUF_INIT; strbuf_addf(&longref, "refs/heads/%s", ref); - if (get_oid(longref.buf, &oid) == 0) { + if (repo_get_oid(the_repository, longref.buf, &oid) == 0) { *must_free_result = 1; return strbuf_detach(&longref, NULL); } @@ -430,7 +430,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern if (path) strvec_push(&rev_argv, path); - init_revisions(&rev, NULL); + repo_init_revisions(the_repository, &rev, NULL); rev.abbrev = DEFAULT_ABBREV; rev.commit_format = CMIT_FMT_DEFAULT; rev.verbose_header = 1; diff --git a/ui-patch.c b/ui-patch.c index 4ac03cb..3819a81 100644 --- a/ui-patch.c +++ b/ui-patch.c @@ -31,7 +31,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, if (!new_rev) new_rev = ctx.qry.head; - if (get_oid(new_rev, &new_rev_oid)) { + if (repo_get_oid(the_repository, new_rev, &new_rev_oid)) { cgit_print_error_page(404, "Not found", "Bad object id: %s", new_rev); return; @@ -44,7 +44,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, } if (old_rev) { - if (get_oid(old_rev, &old_rev_oid)) { + if (repo_get_oid(the_repository, old_rev, &old_rev_oid)) { cgit_print_error_page(404, "Not found", "Bad object id: %s", old_rev); return; @@ -78,7 +78,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, "%s%n%n%w(0)%b"; } - init_revisions(&rev, NULL); + repo_init_revisions(the_repository, &rev, NULL); rev.abbrev = DEFAULT_ABBREV; rev.verbose_header = 1; rev.diff = 1; diff --git a/ui-plain.c b/ui-plain.c index 65a205f..a66c5a1 100644 --- a/ui-plain.c +++ b/ui-plain.c @@ -28,7 +28,7 @@ static int print_object(const struct object_id *oid, const char *path) return 0; } - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) { cgit_print_error_page(404, "Not found", "Not found"); return 0; @@ -181,12 +181,12 @@ void cgit_print_plain(void) if (!rev) rev = ctx.qry.head; - if (get_oid(rev, &oid)) { + if (repo_get_oid(the_repository, rev, &oid)) { cgit_print_error_page(404, "Not found", "Not found"); return; } commit = lookup_commit_reference(the_repository, &oid); - if (!commit || parse_commit(commit)) { + if (!commit || repo_parse_commit(the_repository, commit)) { cgit_print_error_page(404, "Not found", "Not found"); return; } diff --git a/ui-shared.c b/ui-shared.c index baea6f2..eef2aa8 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -1188,11 +1188,11 @@ void cgit_compose_snapshot_prefix(struct strbuf *filename, const char *base, * name starts with {v,V}[0-9] and the prettify mapping is injective, * i.e. each stripped tag can be inverted without ambiguities. */ - if (get_oid(fmt("refs/tags/%s", ref), &oid) == 0 && + if (repo_get_oid(the_repository, fmt("refs/tags/%s", ref), &oid) == 0 && (ref[0] == 'v' || ref[0] == 'V') && isdigit(ref[1]) && - ((get_oid(fmt("refs/tags/%s", ref + 1), &oid) == 0) + - (get_oid(fmt("refs/tags/v%s", ref + 1), &oid) == 0) + - (get_oid(fmt("refs/tags/V%s", ref + 1), &oid) == 0) == 1)) + ((repo_get_oid(the_repository, fmt("refs/tags/%s", ref + 1), &oid) == 0) + + (repo_get_oid(the_repository, fmt("refs/tags/v%s", ref + 1), &oid) == 0) + + (repo_get_oid(the_repository, fmt("refs/tags/V%s", ref + 1), &oid) == 0) == 1)) ref++; strbuf_addf(filename, "%s-%s", base, ref); diff --git a/ui-snapshot.c b/ui-snapshot.c index 18361a6..9f629a9 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c @@ -117,7 +117,7 @@ const struct object_id *cgit_snapshot_get_sig(const char *ref, struct notes_tree *tree; struct object_id oid; - if (get_oid(ref, &oid)) + if (repo_get_oid(the_repository, ref, &oid)) return NULL; tree = &snapshot_sig_notes[f - &cgit_snapshot_formats[0]]; @@ -156,7 +156,7 @@ static int make_snapshot(const struct cgit_snapshot_format *format, { struct object_id oid; - if (get_oid(hex, &oid)) { + if (repo_get_oid(the_repository, hex, &oid)) { cgit_print_error_page(404, "Not found", "Bad object id: %s", hex); return 1; @@ -190,7 +190,7 @@ static int write_sig(const struct cgit_snapshot_format *format, return 0; } - buf = read_object_file(note, &type, &size); + buf = repo_read_object_file(the_repository, note, &type, &size); if (!buf) { cgit_print_error_page(404, "Not found", "Not found"); return 0; @@ -230,7 +230,7 @@ static const char *get_ref_from_filename(const struct cgit_repo *repo, strbuf_addstr(&snapshot, filename); strbuf_setlen(&snapshot, snapshot.len - strlen(format->suffix)); - if (get_oid(snapshot.buf, &oid) == 0) + if (repo_get_oid(the_repository, snapshot.buf, &oid) == 0) goto out; reponame = cgit_snapshot_prefix(repo); @@ -242,15 +242,15 @@ static const char *get_ref_from_filename(const struct cgit_repo *repo, strbuf_splice(&snapshot, 0, new_start - snapshot.buf, "", 0); } - if (get_oid(snapshot.buf, &oid) == 0) + if (repo_get_oid(the_repository, snapshot.buf, &oid) == 0) goto out; strbuf_insert(&snapshot, 0, "v", 1); - if (get_oid(snapshot.buf, &oid) == 0) + if (repo_get_oid(the_repository, snapshot.buf, &oid) == 0) goto out; strbuf_splice(&snapshot, 0, 1, "V", 1); - if (get_oid(snapshot.buf, &oid) == 0) + if (repo_get_oid(the_repository, snapshot.buf, &oid) == 0) goto out; result = 0; diff --git a/ui-stats.c b/ui-stats.c index 40ed6c2..9aed4ac 100644 --- a/ui-stats.c +++ b/ui-stats.c @@ -230,7 +230,7 @@ static struct string_list collect_stats(const struct cgit_period *period) argv[4] = ctx.qry.path; argc += 2; } - init_revisions(&rev, NULL); + repo_init_revisions(the_repository, &rev, NULL); rev.abbrev = DEFAULT_ABBREV; rev.commit_format = CMIT_FMT_DEFAULT; rev.max_parents = 1; diff --git a/ui-tag.c b/ui-tag.c index 424bbcc..5354827 100644 --- a/ui-tag.c +++ b/ui-tag.c @@ -48,7 +48,7 @@ void cgit_print_tag(char *revname) revname = ctx.qry.head; strbuf_addf(&fullref, "refs/tags/%s", revname); - if (get_oid(fullref.buf, &oid)) { + if (repo_get_oid(the_repository, fullref.buf, &oid)) { cgit_print_error_page(404, "Not found", "Bad tag reference: %s", revname); goto cleanup; diff --git a/ui-tree.c b/ui-tree.c index 98ce1ca..0640336 100644 --- a/ui-tree.c +++ b/ui-tree.c @@ -98,7 +98,7 @@ static void print_object(const struct object_id *oid, const char *path, const ch return; } - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) { cgit_print_error_page(500, "Internal server error", "Error reading object %s", oid_to_hex(oid)); @@ -242,7 +242,7 @@ static int ls_item(const struct object_id *oid, struct strbuf *base, } if (S_ISLNK(mode)) { html(" -> "); - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) { htmlf("Error reading object: %s", oid_to_hex(oid)); goto cleanup; @@ -372,13 +372,13 @@ void cgit_print_tree(const char *rev, char *path) if (!rev) rev = ctx.qry.head; - if (get_oid(rev, &oid)) { + if (repo_get_oid(the_repository, rev, &oid)) { cgit_print_error_page(404, "Not found", "Invalid revision name: %s", rev); return; } commit = lookup_commit_reference(the_repository, &oid); - if (!commit || parse_commit(commit)) { + if (!commit || repo_parse_commit(the_repository, commit)) { cgit_print_error_page(404, "Not found", "Invalid commit reference: %s", rev); return; -- 2.40.1 From Jason at zx2c4.com Fri May 26 13:42:55 2023 From: Jason at zx2c4.com (Jason A. Donenfeld) Date: Fri, 26 May 2023 15:42:55 +0200 Subject: [PATCH 1/1] RFC: git: update to v2.41.0-rc2 In-Reply-To: <20230526110646.60621-1-list@eworm.de> References: <20230526110646.60621-1-list@eworm.de> Message-ID: On Fri, May 26, 2023 at 1:07?PM Christian Hesse wrote: > @@ -564,9 +566,11 @@ 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); > } What's the motivation here exactly? string_list allocates, I believe, for its items array even if you set nostrdup, so that code probably needs a free path. But also, what's the point of doing the splitting up front and then iterating, rather than just munging the string like usual with strtok_r? Jason From list at eworm.de Fri May 26 14:06:53 2023 From: list at eworm.de (Christian Hesse) Date: Fri, 26 May 2023 16:06:53 +0200 Subject: [PATCH 1/1] RFC: git: update to v2.41.0-rc2 In-Reply-To: References: <20230526110646.60621-1-list@eworm.de> Message-ID: <20230526160653.7962c827@leda.eworm.net> "Jason A. Donenfeld" on Fri, 2023/05/26 15:42: > On Fri, May 26, 2023 at 1:07?PM Christian Hesse wrote: > > @@ -564,9 +566,11 @@ 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); > > } > > What's the motivation here exactly? string_list allocates, I believe, > for its items array even if you set nostrdup, so that code probably > needs a free path. But also, what's the point of doing the splitting > up front and then iterating, rather than just munging the string like > usual with strtok_r? Well, `strtok_r()` is now banned... https://github.com/gitster/git/commit/60ff56f50372c1498718938ef504e744fe011ffb ... and the commit messages suggests to use `string_list_split_in_place()` instead. In contrast to `string_list_split()` it does not allocate but splits - as the name suggests - in place. From `string-list.h`: > Like string_list_split(), except that string is split in-place: the > delimiter characters in string are overwritten with NULs, and the > new string_list_items point into string (which therefore must not > be modified or freed while the string_list is in use). > list->strdup_strings must *not* be set. So we should be fine with the change, no? -- main(a){char*c=/* Schoene Gruesse */"B?IJj;MEH" "CX:;",b;for(a/* Best regards my address: */=0;b=c[a++];) putchar(b-1/(/* Chris cc -ox -xc - && ./x */b/42*2-3)*42);} -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: From list at eworm.de Fri May 26 14:17:35 2023 From: list at eworm.de (Christian Hesse) Date: Fri, 26 May 2023 16:17:35 +0200 Subject: [PATCH 1/1] RFC: git: update to v2.41.0-rc2 In-Reply-To: <20230526160653.7962c827@leda.eworm.net> References: <20230526110646.60621-1-list@eworm.de> <20230526160653.7962c827@leda.eworm.net> Message-ID: <20230526161735.57ebdc54@leda.eworm.net> Christian Hesse on Fri, 2023/05/26 16:06: > > Like string_list_split(), except that string is split in-place: the > > delimiter characters in string are overwritten with NULs, and the > > new string_list_items point into string (which therefore must not > > be modified or freed while the string_list is in use). > > list->strdup_strings must *not* be set. > > So we should be fine with the change, no? Ah, the strings are not allocated, but we should run: string_list_clear(&list, 0); Is it fine then? -- main(a){char*c=/* Schoene Gruesse */"B?IJj;MEH" "CX:;",b;for(a/* Best regards my address: */=0;b=c[a++];) putchar(b-1/(/* Chris cc -ox -xc - && ./x */b/42*2-3)*42);} -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: From Jason at zx2c4.com Fri May 26 14:18:42 2023 From: Jason at zx2c4.com (Jason A. Donenfeld) Date: Fri, 26 May 2023 16:18:42 +0200 Subject: [PATCH 1/1] RFC: git: update to v2.41.0-rc2 In-Reply-To: <20230526161735.57ebdc54@leda.eworm.net> References: <20230526110646.60621-1-list@eworm.de> <20230526160653.7962c827@leda.eworm.net> <20230526161735.57ebdc54@leda.eworm.net> Message-ID: On Fri, May 26, 2023 at 4:17?PM Christian Hesse wrote: > > Christian Hesse on Fri, 2023/05/26 16:06: > > > Like string_list_split(), except that string is split in-place: the > > > delimiter characters in string are overwritten with NULs, and the > > > new string_list_items point into string (which therefore must not > > > be modified or freed while the string_list is in use). > > > list->strdup_strings must *not* be set. > > > > So we should be fine with the change, no? > > Ah, the strings are not allocated, but we should run: > > string_list_clear(&list, 0); > > Is it fine then? Right. My understanding is that while the strings themselves are not allocated, the array of string list items still is. From list at eworm.de Fri May 26 14:21:13 2023 From: list at eworm.de (Christian Hesse) Date: Fri, 26 May 2023 16:21:13 +0200 Subject: [PATCH 1/1] RFC: git: update to v2.41.0-rc2 In-Reply-To: References: <20230526110646.60621-1-list@eworm.de> <20230526160653.7962c827@leda.eworm.net> <20230526161735.57ebdc54@leda.eworm.net> Message-ID: <20230526162113.0c8763c3@leda.eworm.net> "Jason A. Donenfeld" on Fri, 2023/05/26 16:18: > On Fri, May 26, 2023 at 4:17?PM Christian Hesse wrote: > > > > Christian Hesse on Fri, 2023/05/26 16:06: > > > > Like string_list_split(), except that string is split in-place: the > > > > delimiter characters in string are overwritten with NULs, and the > > > > new string_list_items point into string (which therefore must not > > > > be modified or freed while the string_list is in use). > > > > list->strdup_strings must *not* be set. > > > > > > So we should be fine with the change, no? > > > > Ah, the strings are not allocated, but we should run: > > > > string_list_clear(&list, 0); > > > > Is it fine then? > > Right. My understanding is that while the strings themselves are not > allocated, the array of string list items still is. Probably. But is there a better alternative now that `strtok_r()` is banned? -- main(a){char*c=/* Schoene Gruesse */"B?IJj;MEH" "CX:;",b;for(a/* Best regards my address: */=0;b=c[a++];) putchar(b-1/(/* Chris cc -ox -xc - && ./x */b/42*2-3)*42);} -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: