All of lore.kernel.org
 help / color / mirror / Atom feed
* [Outreachy PATCH] merge: stop using the_repository
@ 2026-10-15 14:25 Okhuomon Ajayi
  2026-10-15 16:59 ` Usman Akinyemi
  2026-10-15 19:20 ` Junio C Hamano
  0 siblings, 2 replies; 5+ messages in thread
From: Okhuomon Ajayi @ 2026-10-15 14:25 UTC (permalink / raw)
  To: gitster
  Cc: git, christian.couder, usmanakinyemi202, siddharthasthana31,
	kaartic.sivaraam, Okhuomon Ajayi

try_merge_command() and checkout_fast_forward() already receive a
repository, so use it instead of relying on global variables.

Add a repository parameter to merge_argument() and pass it
from try_merge_command(). Use the repository in
checkout_fast_forward() when parsing trees.

Remove the now-unnecessary USE_THE_REPOSITORY_VARIABLE
definition.

Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
---
 merge.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/merge.c b/merge.c
index 0f5e823e63..85dad63a94 100644
--- a/merge.c
+++ b/merge.c
@@ -1,5 +1,3 @@
-#define USE_THE_REPOSITORY_VARIABLE
-
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "hash.h"
@@ -14,9 +12,9 @@
 #include "tree-walk.h"
 #include "unpack-trees.h"
 
-static const char *merge_argument(struct commit *commit)
+static const char *merge_argument(struct repository *r, struct commit *commit)
 {
-	return oid_to_hex(commit ? &commit->object.oid : the_hash_algo->empty_tree);
+	return oid_to_hex(commit ? &commit->object.oid : r->hash_algo->empty_tree);
 }
 
 int try_merge_command(struct repository *r,
@@ -32,11 +30,11 @@ int try_merge_command(struct repository *r,
 	for (size_t i = 0; i < xopts_nr; i++)
 		strvec_pushf(&cmd.args, "--%s", xopts[i]);
 	for (j = common; j; j = j->next)
-		strvec_push(&cmd.args, merge_argument(j->item));
+		strvec_push(&cmd.args, merge_argument(r, j->item));
 	strvec_push(&cmd.args, "--");
 	strvec_push(&cmd.args, head_arg);
 	for (j = remotes; j; j = j->next)
-		strvec_push(&cmd.args, merge_argument(j->item));
+		strvec_push(&cmd.args, merge_argument(r, j->item));
 
 	cmd.git_cmd = 1;
 	ret = run_command(&cmd);
@@ -68,18 +66,18 @@ int checkout_fast_forward(struct repository *r,
 	memset(&trees, 0, sizeof(trees));
 	memset(&t, 0, sizeof(t));
 
-	trees[nr_trees] = repo_parse_tree_indirect(the_repository, head);
+	trees[nr_trees] = repo_parse_tree_indirect(r, head);
 	if (!trees[nr_trees++]) {
 		rollback_lock_file(&lock_file);
 		return -1;
 	}
-	trees[nr_trees] = repo_parse_tree_indirect(the_repository, remote);
+	trees[nr_trees] = repo_parse_tree_indirect(r, remote);
 	if (!trees[nr_trees++]) {
 		rollback_lock_file(&lock_file);
 		return -1;
 	}
 	for (i = 0; i < nr_trees; i++) {
-		if (repo_parse_tree(the_repository, trees[i]) < 0) {
+		if (repo_parse_tree(r, trees[i]) < 0) {
 			rollback_lock_file(&lock_file);
 			return -1;
 		}
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Outreachy PATCH] merge: stop using the_repository
  2026-10-15 14:25 [Outreachy PATCH] merge: stop using the_repository Okhuomon Ajayi
@ 2026-10-15 16:59 ` Usman Akinyemi
  2026-10-15 17:20   ` Okhuomon Ajayi
  2026-10-15 19:20 ` Junio C Hamano
  1 sibling, 1 reply; 5+ messages in thread
From: Usman Akinyemi @ 2026-10-15 16:59 UTC (permalink / raw)
  To: Okhuomon Ajayi
  Cc: gitster, git, christian.couder, siddharthasthana31,
	kaartic.sivaraam

>
> try_merge_command() and checkout_fast_forward() already receive a
> repository, so use it instead of relying on global variables.
>
> Add a repository parameter to merge_argument() and pass it
> from try_merge_command(). Use the repository in
> checkout_fast_forward() when parsing trees.
>
> Remove the now-unnecessary USE_THE_REPOSITORY_VARIABLE
> definition.
>
> Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
Good catch.
> ---
>  merge.c | 16 +++++++---------
>  1 file changed, 7 insertions(+), 9 deletions(-)

> +               strvec_push(&cmd.args, merge_argument(r, j->item));
>         strvec_push(&cmd.args, "--");
>         strvec_push(&cmd.args, head_arg);
>         for (j = remotes; j; j = j->next)
> -               strvec_push(&cmd.args, merge_argument(j->item));
> +               strvec_push(&cmd.args, merge_argument(r, j->item));
>
>         cmd.git_cmd = 1;
>         ret = run_command(&cmd);
> @@ -68,18 +66,18 @@ int checkout_fast_forward(struct repository *r,
>         memset(&trees, 0, sizeof(trees));
>         memset(&t, 0, sizeof(t));
>         }
>         for (i = 0; i < nr_trees; i++) {
> -               if (repo_parse_tree(the_repository, trees[i]) < 0) {
> +               if (repo_parse_tree(r, trees[i]) < 0) {
>                         rollback_lock_file(&lock_file);
>                         return -1;
>                 }
> --
> 2.54.0
>
looks good to me.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Outreachy PATCH] merge: stop using the_repository
  2026-10-15 16:59 ` Usman Akinyemi
@ 2026-10-15 17:20   ` Okhuomon Ajayi
  0 siblings, 0 replies; 5+ messages in thread
From: Okhuomon Ajayi @ 2026-10-15 17:20 UTC (permalink / raw)
  To: Usman Akinyemi
  Cc: gitster, git, christian.couder, siddharthasthana31,
	kaartic.sivaraam

On Thu, Oct 15, 2026 at 5:59 PM Usman Akinyemi
<usmanakinyemi202@gmail.com> wrote:
> looks good to me.

Thank you

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Outreachy PATCH] merge: stop using the_repository
  2026-10-15 14:25 [Outreachy PATCH] merge: stop using the_repository Okhuomon Ajayi
  2026-10-15 16:59 ` Usman Akinyemi
@ 2026-10-15 19:20 ` Junio C Hamano
  2026-10-15 19:56   ` Okhuomon Ajayi
  1 sibling, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2026-10-15 19:20 UTC (permalink / raw)
  To: Okhuomon Ajayi
  Cc: git, christian.couder, usmanakinyemi202, siddharthasthana31,
	kaartic.sivaraam

Okhuomon Ajayi <okhuomonajayi54@gmail.com> writes:

> try_merge_command() and checkout_fast_forward() already receive a
> repository, so use it instead of relying on global variables.
>
> Add a repository parameter to merge_argument() and pass it
> from try_merge_command(). Use the repository in
> checkout_fast_forward() when parsing trees.
>
> Remove the now-unnecessary USE_THE_REPOSITORY_VARIABLE
> definition.
>
> Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
> ---
>  merge.c | 16 +++++++---------
>  1 file changed, 7 insertions(+), 9 deletions(-)

    To: gitster@pobox.com
    Cc: git@vger.kernel.org, christian.couder@gmail.com, usmanakinyemi202@gmail.com,
     siddharthasthana31@gmail.com, kaartic.sivaraam@gmail.com, Okhuomon Ajayi
     <okhuomonajayi54@gmail.com> 

Please do not put me on "To:" alone unless the patch has been fully
reviewed and reviewered acked it.  Placing reviewers on Cc: line (or
To: line) as "area experts" asking for review is fine, and if the
patch is in the area where I happen to be an area expert, my address
may appear there together with other reviewers, but the default
"To:" address on this list for a brand new patch should be the list
address itself.

> diff --git a/merge.c b/merge.c
> index 0f5e823e63..85dad63a94 100644
> --- a/merge.c
> +++ b/merge.c
> @@ -1,5 +1,3 @@
> -#define USE_THE_REPOSITORY_VARIABLE
> -
>  #include "git-compat-util.h"
>  #include "gettext.h"
>  #include "hash.h"
> @@ -14,9 +12,9 @@
>  #include "tree-walk.h"
>  #include "unpack-trees.h"
>  
> -static const char *merge_argument(struct commit *commit)
> +static const char *merge_argument(struct repository *r, struct commit *commit)
>  {
> -	return oid_to_hex(commit ? &commit->object.oid : the_hash_algo->empty_tree);
> +	return oid_to_hex(commit ? &commit->object.oid : r->hash_algo->empty_tree);
>  }
>  
>  int try_merge_command(struct repository *r,
> @@ -32,11 +30,11 @@ int try_merge_command(struct repository *r,
>  	for (size_t i = 0; i < xopts_nr; i++)
>  		strvec_pushf(&cmd.args, "--%s", xopts[i]);
>  	for (j = common; j; j = j->next)
> -		strvec_push(&cmd.args, merge_argument(j->item));
> +		strvec_push(&cmd.args, merge_argument(r, j->item));
>  	strvec_push(&cmd.args, "--");
>  	strvec_push(&cmd.args, head_arg);
>  	for (j = remotes; j; j = j->next)
> -		strvec_push(&cmd.args, merge_argument(j->item));
> +		strvec_push(&cmd.args, merge_argument(r, j->item));
>  
>  	cmd.git_cmd = 1;
>  	ret = run_command(&cmd);
> @@ -68,18 +66,18 @@ int checkout_fast_forward(struct repository *r,
>  	memset(&trees, 0, sizeof(trees));
>  	memset(&t, 0, sizeof(t));
>  
> -	trees[nr_trees] = repo_parse_tree_indirect(the_repository, head);
> +	trees[nr_trees] = repo_parse_tree_indirect(r, head);
>  	if (!trees[nr_trees++]) {
>  		rollback_lock_file(&lock_file);
>  		return -1;
>  	}
> -	trees[nr_trees] = repo_parse_tree_indirect(the_repository, remote);
> +	trees[nr_trees] = repo_parse_tree_indirect(r, remote);
>  	if (!trees[nr_trees++]) {
>  		rollback_lock_file(&lock_file);
>  		return -1;
>  	}
>  	for (i = 0; i < nr_trees; i++) {
> -		if (repo_parse_tree(the_repository, trees[i]) < 0) {
> +		if (repo_parse_tree(r, trees[i]) < 0) {
>  			rollback_lock_file(&lock_file);
>  			return -1;
>  		}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Outreachy PATCH] merge: stop using the_repository
  2026-10-15 19:20 ` Junio C Hamano
@ 2026-10-15 19:56   ` Okhuomon Ajayi
  0 siblings, 0 replies; 5+ messages in thread
From: Okhuomon Ajayi @ 2026-10-15 19:56 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: git, christian.couder, usmanakinyemi202, siddharthasthana31,
	kaartic.sivaraam

On Thu, Oct 15, 2026 at 8:20 PM Junio C Hamano <gitster@pobox.com> wrote:

> Please do not put me on "To:" alone unless the patch has been fully
> reviewed and reviewered acked it.  Placing reviewers on Cc: line (or
> To: line) as "area experts" asking for review is fine, and if the
> patch is in the area where I happen to be an area expert, my address
> may appear there together with other reviewers, but the default
> "To:" address on this list for a brand new patch should be the list
> address itself.


Thanks for pointing that out, i'll address new patches to the list
from now on , with reviewers on the Cc

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-10-15 19:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-15 14:25 [Outreachy PATCH] merge: stop using the_repository Okhuomon Ajayi
2026-10-15 16:59 ` Usman Akinyemi
2026-10-15 17:20   ` Okhuomon Ajayi
2026-10-15 19:20 ` Junio C Hamano
2026-10-15 19:56   ` Okhuomon Ajayi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.