Skip to content

replay: replace the_repository with repo parameter passed to cmd_replay #1921

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

newren
Copy link

@newren newren commented May 14, 2025

The point of this patch is not to remove USE_THE_REPOSITORY_VARIABLE; I can't yet because DEFAULT_ABBREV and get_commit_output_encoding() both require it and have no current alternatives. However, I still think it's worthwhile to stop using the_repository everywhere while ignoring the repo parameter explicitly passed in. That looks kinda ugly, and since I'm poking around in replay right now, I don't want to push the_repository in even more places when we have the appropriate value available -- especially since that might make my local work conflict should someone else come along and try to clean this up.

--color-words is handy when viewing this patch; it may make it easier to see the changes.

cc: Patrick Steinhardt [email protected]

…ay()

Replace the_repository everywhere with repo, feed repo from cmd_replay()
to all the other functions in the file that need it, and remove the
UNUSED annotation on repo.

Signed-off-by: Elijah Newren <[email protected]>
@newren
Copy link
Author

newren commented May 14, 2025

/submit

Copy link

gitgitgadget bot commented May 14, 2025

Submitted as [email protected]

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-1921/newren/replay-repo-v1

To fetch this version to local tag pr-1921/newren/replay-repo-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-1921/newren/replay-repo-v1

Copy link

gitgitgadget bot commented May 14, 2025

On the Git mailing list, Junio C Hamano wrote (reply to this):

"Elijah Newren via GitGitGadget" <[email protected]> writes:

>     require it and have no current alternatives. However, I still think it's
>     worthwhile to stop using the_repository everywhere while ignoring the
>     repo parameter explicitly passed in.

Sensible.

> diff --git a/builtin/replay.c b/builtin/replay.c
> index 032c172b65e..225cef08807 100644
> --- a/builtin/replay.c
> +++ b/builtin/replay.c
> @@ -20,21 +20,22 @@
>  #include <oidset.h>
>  #include <tree.h>
>  
> -static const char *short_commit_name(struct commit *commit)
> +static const char *short_commit_name(struct repository *repo,
> +				     struct commit *commit)
>  {
> -	return repo_find_unique_abbrev(the_repository, &commit->object.oid,
> +	return repo_find_unique_abbrev(repo, &commit->object.oid,
>  				       DEFAULT_ABBREV);
>  }

I do not mind this, but I do have to wonder if it is simpler to make
the two callers of this "helper" (which is not quite helping anything)
to make these calls themselves.

>  int cmd_replay(int argc,
>  	       const char **argv,
>  	       const char *prefix,
> -	       struct repository *repo UNUSED)
> +	       struct repository *repo)
>  {
>  	const char *advance_name_opt = NULL;
>  	char *advance_name = NULL;
> @@ -329,7 +334,7 @@ int cmd_replay(int argc,
>  		    "--advance", "--contained");
>  	advance_name = xstrdup_or_null(advance_name_opt);
>  
> -	repo_init_revisions(the_repository, &revs, prefix);
> +	repo_init_revisions(repo, &revs, prefix);

OK, since this command is marked as RUN_SETUP, it is safe to
unconditionally use repo here.  The only situation where it is
called with repo==NULL is when somebody said "git replay -h" outside
a repository, which would have made parse_options() to do the right
thing and exited already without reaching this code, so we should be
able to trust "repo" to be usable.

Will queue.  Thanks.

Copy link

gitgitgadget bot commented May 14, 2025

This patch series was integrated into seen via git@4a19d0c.

@gitgitgadget gitgitgadget bot added the seen label May 14, 2025
Copy link

gitgitgadget bot commented May 15, 2025

On the Git mailing list, Patrick Steinhardt wrote (reply to this):

On Wed, May 14, 2025 at 08:33:25PM +0000, Elijah Newren via GitGitGadget wrote:
> From: Elijah Newren <[email protected]>
> 
> Replace the_repository everywhere with repo, feed repo from cmd_replay()
> to all the other functions in the file that need it, and remove the
> UNUSED annotation on repo.
> 
> Signed-off-by: Elijah Newren <[email protected]>
> ---
>     replay: replace the_repository with repo parameter passed to cmd_replay
>     
>     The point of this patch is not to remove USE_THE_REPOSITORY_VARIABLE; I
>     can't yet because DEFAULT_ABBREV and get_commit_output_encoding() both
>     require it and have no current alternatives. However, I still think it's
>     worthwhile to stop using the_repository everywhere while ignoring the
>     repo parameter explicitly passed in. That looks kinda ugly, and since
>     I'm poking around in replay right now, I don't want to push
>     the_repository in even more places when we have the appropriate value
>     available -- especially since that might make my local work conflict
>     should someone else come along and try to clean this up.

Makes sense. Especially the first one is something I have encountered as
a frequent blocker for removing `USE_THE_REPOSITORY_VARIABLE`. I guess
it would be nice to tackle it sooner rather than later.

Cc'd Ayush, as he will be working on the global state reduction project
as part of GSoC.

Patrick

Copy link

gitgitgadget bot commented May 15, 2025

User Patrick Steinhardt <[email protected]> has been added to the cc: list.

Copy link

gitgitgadget bot commented May 15, 2025

This branch is now known as en/replay-wo-the-repository.

Copy link

gitgitgadget bot commented May 15, 2025

This patch series was integrated into seen via git@5a8c154.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant