git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Ayush Chandekar <ayu.chandekar@gmail.com>
Cc: christian.couder@gmail.com, git@vger.kernel.org,
	shejialuo@gmail.com, shyamthakkar001@gmail.com,
	gitster@pobox.com, usmanakinyemi202@gmail.com
Subject: Re: [GSOC PATCH v3 2/2] builtin/prune: stop depending on 'the_repository'
Date: Mon, 7 Jul 2025 08:08:38 +0200	[thread overview]
Message-ID: <aGtkZgbJhO-GQ1XX@pks.im> (raw)
In-Reply-To: <22fbbc8cf1b5cd622197e6d9f009acdbbcc0e802.1751630981.git.ayu.chandekar@gmail.com>

On Fri, Jul 04, 2025 at 07:42:35PM +0530, Ayush Chandekar wrote:
> diff --git a/builtin/prune.c b/builtin/prune.c
> index dab3c19b6f..320e9c2341 100644
> --- a/builtin/prune.c
> +++ b/builtin/prune.c
> @@ -173,20 +171,19 @@ int cmd_prune(int argc,
>  	expire = TIME_MAX;
>  	save_commit_buffer = 0;
>  	disable_replace_refs();
> -	repo_init_revisions(the_repository, &revs, prefix);
>  
>  	argc = parse_options(argc, argv, prefix, options, prune_usage, 0);
>  
> -	if (the_repository->repository_format_precious_objects)
> +	repo_init_revisions(repo, &revs, prefix);
> +	if (repo->repository_format_precious_objects)
>  		die(_("cannot prune in a precious-objects repo"));
>  

Okay, we now only end up using the passed-in potentially-NULL `repo`
after we have called `parse_options`. Makes sense.

> diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
> index 6824581317..8f59b867f2 100755
> --- a/t/t1517-outside-repo.sh
> +++ b/t/t1517-outside-repo.sh
> @@ -114,4 +114,11 @@ test_expect_success 'update-server-info does not crash with -h' '
>  	test_grep "[Uu]sage: git update-server-info " usage
>  '
>  
> +test_expect_success 'prune does not crash with -h' '
> +	test_expect_code 129 git prune -h >usage &&
> +	test_grep "[Uu]sage: git prune " usage &&
> +	test_expect_code 129 nongit git prune -h >usage &&
> +	test_grep "[Uu]sage: git prune " usage
> +'
> +
>  test_done

And we have another test that verifies that all of this works outside of
a repository.

This addresses my review comments, so this version looks good to me.
Thanks!

Patrick

  reply	other threads:[~2025-07-07  6:08 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-08  1:06 [GSOC PATCH 0/2] builtin/prune: remove dependency on global variables and 'the_repository' Ayush Chandekar
2025-06-08  1:06 ` [GSOC PATCH 1/2] repository: move 'repository_format_precious_objects' to repo scope Ayush Chandekar
2025-06-28  7:26   ` shejialuo
2025-06-28 13:14     ` Ayush Chandekar
2025-06-08  1:06 ` [GSOC PATCH 2/2] builtin/prune: stop depending on 'the_repository' Ayush Chandekar
2025-06-28  7:33   ` shejialuo
2025-06-28 13:21     ` Ayush Chandekar
2025-06-25 15:59 ` [GSOC PATCH 0/2] builtin/prune: remove dependency on global variables and 'the_repository' Ayush Chandekar
2025-06-30 16:41 ` [GSOC PATCH v2 " Ayush Chandekar
2025-06-30 16:41   ` [GSOC PATCH v2 1/2] repository: move 'repository_format_precious_objects' to repo scope Ayush Chandekar
2025-07-01 13:01     ` Patrick Steinhardt
2025-07-01 18:24       ` Ayush Chandekar
2025-07-02  2:23         ` Patrick Steinhardt
2025-06-30 16:41   ` [GSOC PATCH v2 2/2] builtin/prune: stop depending on 'the_repository' Ayush Chandekar
2025-07-01 13:01     ` Patrick Steinhardt
2025-07-01 16:42       ` Junio C Hamano
2025-07-01 18:09         ` Ayush Chandekar
2025-07-01 19:44           ` Usman Akinyemi
2025-07-01 22:04             ` Ayush Chandekar
2025-07-02  2:23           ` Patrick Steinhardt
2025-07-02 11:18             ` Usman Akinyemi
2025-07-02 16:53               ` Ben Knoble
2025-07-02 17:06               ` Junio C Hamano
2025-07-02 23:51               ` Ayush Chandekar
2025-07-04 14:12   ` [GSOC PATCH v3 0/2] builtin/prune: remove dependency on global variables and 'the_repository' Ayush Chandekar
2025-07-04 14:12     ` [GSOC PATCH v3 1/2] repository: move 'repository_format_precious_objects' to repo scope Ayush Chandekar
2025-07-04 14:12     ` [GSOC PATCH v3 2/2] builtin/prune: stop depending on 'the_repository' Ayush Chandekar
2025-07-07  6:08       ` Patrick Steinhardt [this message]
2025-07-08 13:52         ` Ayush Chandekar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aGtkZgbJhO-GQ1XX@pks.im \
    --to=ps@pks.im \
    --cc=ayu.chandekar@gmail.com \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=shejialuo@gmail.com \
    --cc=shyamthakkar001@gmail.com \
    --cc=usmanakinyemi202@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).