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

Re: [PATCH 2/2] apply: do not use the_repository

From
Patrick Steinhardt <ps@pks.im>
Date
May 28, 2024, 07:28 UTC
Message-ID
<ZlWHgBROsPBrmM0D@tanuki>
In-Reply-To
<36b44eb4c18cfd805ccecd8df695b0d5ee9c409f.1716877921.git.gitgitgadget@gmail.com>
On Tue, May 28, 2024 at 06:32:01AM +0000, Philip Peterson via GitGitGadget wrote:
Show 20 quoted lines
> diff --git a/apply.c b/apply.c
> index 901b67e6255..364c05fbd06 100644
> --- a/apply.c
> +++ b/apply.c
> @@ -3218,13 +3218,13 @@ static int apply_binary(struct apply_state *state,
>  		return 0; /* deletion patch */
>  	}
>  
> -	if (has_object(the_repository, &oid, 0)) {
> +	if (has_object(state->repo, &oid, 0)) {
>  		/* We already have the postimage */
>  		enum object_type type;
>  		unsigned long size;
>  		char *result;
>  
> -		result = repo_read_object_file(the_repository, &oid, &type,
> +		result = repo_read_object_file(state->repo, &oid, &type,
>  					       &size);
>  		if (!result)
>  			return error(_("the necessary postimage %s for "

We call `get_oid_hex()` in this function, which ultimately ends up accessing `the_repository` via `the_hash_algo`. We should likely convert those to `repo_get_oid()`.

There are also other accesses to `the_hash_algo` in this function, which should be converted to use `state->repo->hash_algo`, as well.

Show 12 quoted lines
> @@ -3539,9 +3539,9 @@ static int three_way_merge(struct apply_state *state,
>  
>  	/* resolve trivial cases first */
>  	if (oideq(base, ours))
> -		return resolve_to(image, theirs);
> +		return resolve_to(state->repo, image, theirs);
>  	else if (oideq(base, theirs) || oideq(ours, theirs))
> -		return resolve_to(image, ours);
> +		return resolve_to(state->repo, image, ours);
>  
>  	read_mmblob(&base_file, base);
>  	read_mmblob(&our_file, ours);
The calls to `read_mmblob()` also end up accessing `the_repository`.
Other than that the patches look good to me. Thanks for working on this!
Patrick
Previous: Philip Peterson via GitGitGadgetNext: Junio C Hamano
Message 5 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.