git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] add-patch: do not use the_repository

From
Junio C Hamano <gitster@pobox.com>
Date
May 28, 2024, 21:41 UTC
Message-ID
<xmqqwmnd397o.fsf@gitster.g>
In-Reply-To
<c0bb37db12ea8724431fe4294d591cd8cef73e66.1716877921.git.gitgitgadget@gmail.com>
"Philip Peterson via GitGitGadget" <gitgitgadget@gmail.com> writes:
> -static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
> +static int parse_diff(struct repository *r, struct add_p_state *s, const struct pathspec *ps)

Given that add_p_state has add_i_state in it, which in turn as a pointer to the repository, which is initialized like so:

        int run_add_p(struct repository *r, enum add_p_mode mode,
                      const char *revision, const struct pathspec *ps)
        {
                struct add_p_state s = {
                        { r }, STRBUF_INIT, STRBUF_INIT, STRBUF_INIT, STRBUF_INIT
                };
                size_t i, binary_count = 0;
                init_add_i_state(&s.s, r);

this patch looks wrong. Adding a separate repository pointer to the function means you are saying that this function should be able to operate one repository in 'r' that may be DIFFERENT from the repository add_p_state was initialized for. I do not think you are achieving that with this patch (and I do not think such a feature makes much sense, either).

Instead just leave everything the same as before, and rewrite things that depend on the_repository (either by explicitly referring to it, or by implicitly using it, like empty_tree_oid_hex() which hardcodes the use of the_hash_algo which is the_repository->hash_algo) to refer to the repository the add_p_state was initialized for.

Previous: Philip Peterson via GitGitGadgetNext: Philip Peterson via GitGitGadget
Message 3 of 8 in “Remove some usages of the_repository”
  1. 0/2 Remove some usages of the_repositoryPhilip Peterson via GitGitGadget, May 28, 2024
  2. 1/2 add-patch: do not use the_repositoryPhilip Peterson via GitGitGadget, May 28, 2024
  3. Junio C HamanoMay 28, 2024
  4. 2/2 apply: do not use the_repositoryPhilip Peterson via GitGitGadget, May 28, 2024
  5. Patrick SteinhardtMay 28, 2024
  6. Junio C HamanoMay 28, 2024
  7. Patrick SteinhardtMay 28, 2024
  8. Junio C HamanoMay 28, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.