Thread View: linux.kernel.git
8 messages
8 total messages
Started by Okhuomon Ajayi
Tue, 27 Oct 2026 15:34
[Outreachy PATCH] negotiator/default: stop using the_repository
Author: Okhuomon Ajayi
Date: Tue, 27 Oct 2026 15:34
Date: Tue, 27 Oct 2026 15:34
142 lines
15003 bytes
15003 bytes
The default negotiator uses the_repository to parse commits,
clear marks, and walk refs. fetch_negotiator_init() already
has the repository but does not pass it down.
Give default_negotiator_init() a repository parameter, store
it on the negotiation state, and use it for those calls.
clear_marks() receives the repository through its callback
data. Drop USE_THE_REPOSITORY_VARIABLE.
Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
---
fetch-negotiator.c | 2 +-
negotiator/default.c | 26 +++++++++++++++-----------
negotiator/default.h | 4 +++-
3 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/fetch-negotiator.c b/fetch-negotiator.c
index be383367f5..1a2cf3f384 100644
--- a/fetch-negotiator.c
+++ b/fetch-negotiator.c
@@ -19,7 +19,7 @@ void fetch_negotiator_init(struct repository *r,
return;
case FETCH_NEGOTIATION_CONSECUTIVE:
- default_negotiator_init(negotiator);
+ default_negotiator_init(negotiator, r);
return;
}
}
diff --git a/negotiator/default.c b/negotiator/default.c
index 19cdf3808c..4684bed796 100644
--- a/negotiator/default.c
+++ b/negotiator/default.c
@@ -1,5 +1,3 @@
-#define USE_THE_REPOSITORY_VARIABLE
-
#include "git-compat-util.h"
#include "default.h"
#include "../commit.h"
@@ -18,6 +16,7 @@
static int marked;
struct negotiation_state {
+ struct repository *repo;
struct prio_queue rev_list;
int non_common_revs;
};
@@ -28,7 +27,7 @@ static void rev_list_push(struct negotiation_state *ns,
if (!(commit->object.flags & mark)) {
commit->object.flags |= mark;
- if (repo_parse_commit(the_repository, commit))
+ if (repo_parse_commit(ns->repo, commit))
return;
prio_queue_put(&ns->rev_list, commit);
@@ -38,9 +37,10 @@ static void rev_list_push(struct negotiation_state *ns,
}
}
-static int clear_marks(const struct reference *ref, void *cb_data UNUSED)
+static int clear_marks(const struct reference *ref, void *cb_data)
{
- struct object *o = deref_tag(the_repository, parse_object(the_repository, ref->oid),
+ struct repository *r = cb_data;
+ struct object *o = deref_tag(r, parse_object(r, ref->oid),
ref->name, 0);
if (o && o->type == OBJ_COMMIT)
@@ -78,7 +78,7 @@ static void mark_common(struct negotiation_state *ns, struct commit *commit,
struct commit_list *parents;
if (!o->parsed && !dont_parse)
- if (repo_parse_commit(the_repository, commit))
+ if (repo_parse_commit(ns->repo, commit))
continue;
for (parents = commit->parents;
@@ -119,7 +119,7 @@ static const struct object_id *get_rev(struct negotiation_state *ns)
commit = prio_queue_get(&ns->rev_list);
if (!commit)
return NULL;
- repo_parse_commit(the_repository, commit);
+ repo_parse_commit(ns->repo, commit);
parents = commit->parents;
commit->object.flags |= POPPED;
@@ -179,7 +179,9 @@ static int ack(struct fetch_negotiator *n, struct commit *c)
static void have_sent(struct fetch_negotiator *n, struct commit *c)
{
- if (repo_parse_commit(the_repository, c))
+ struct negotiation_state *ns = n->data;
+
+ if (repo_parse_commit(ns->repo, c))
return;
mark_common(n->data, c, 0, 0);
}
@@ -190,7 +192,8 @@ static void release(struct fetch_negotiator *n)
FREE_AND_NULL(n->data);
}
-void default_negotiator_init(struct fetch_negotiator *negotiator)
+void default_negotiator_init(struct fetch_negotiator *negotiator,
+ struct repository *r)
{
struct negotiation_state *ns;
negotiator->known_common = known_common;
@@ -200,10 +203,11 @@ void default_negotiator_init(struct fetch_negotiator *negotiator)
negotiator->have_sent = have_sent;
negotiator->release = release;
negotiator->data = CALLOC_ARRAY(ns, 1);
+ ns->repo = r;
ns->rev_list.compare = compare_commits_by_commit_date;
if (marked)
- refs_for_each_ref(get_main_ref_store(the_repository),
- clear_marks, NULL);
+ refs_for_each_ref(get_main_ref_store(r),
+ clear_marks, r);
marked = 1;
}
diff --git a/negotiator/default.h b/negotiator/default.h
index d23a8f2fb8..bd998eb32e 100644
--- a/negotiator/default.h
+++ b/negotiator/default.h
@@ -2,7 +2,9 @@
#define NEGOTIATOR_DEFAULT_H
struct fetch_negotiator;
+struct repository;
-void default_negotiator_init(struct fetch_negotiator *negotiator);
+void default_negotiator_init(struct fetch_negotiator *negotiator,
+ struct repository *r);
#endif
base-commit: 7e34d8174dcda3435d1404c9a30bef46afe6c13e
--
2.56.0
Re: [Outreachy PATCH] negotiator/default: stop using the_repository
Author: Christian Couder
Date: Tue, 03 Nov 2026 11:50
Date: Tue, 03 Nov 2026 11:50
29 lines
12659 bytes
12659 bytes
On Tue, Oct 27, 2026 at 4:37 PM Okhuomon Ajayi
<okhuomonajayi54@gmail.com> wrote:
> static void have_sent(struct fetch_negotiator *n, struct commit *c)
> {
> - if (repo_parse_commit(the_repository, c))
> + struct negotiation_state *ns = n->data;
> +
> + if (repo_parse_commit(ns->repo, c))
> return;
> mark_common(n->data, c, 0, 0);
As you introduced `ns`, you might use it to simplify the above line using:
mark_common(ns, c, 0, 0);
> }
[...]
> -void default_negotiator_init(struct fetch_negotiator *negotiator);
> +void default_negotiator_init(struct fetch_negotiator *negotiator,
> + struct repository *r);
Many functions have their `struct repository *r` argument as their
first argument. Is there a reason why you prefered to have it as the
second argument?
Thanks.
Re: [Outreachy PATCH] negotiator/default: stop using the_repository
Author: Okhuomon Ajayi
Date: Tue, 03 Nov 2026 12:12
Date: Tue, 03 Nov 2026 12:12
20 lines
12412 bytes
12412 bytes
On Tue, Nov 3, 2026 at 12:50 PM Christian Couder <christian.couder@gmail.com> wrote: > As you introduced `ns`, you might use it to simplify the above line using: > > mark_common(ns, c, 0, 0); Good point. I'll make that change in the next version. > Many functions have their `struct repository *r` argument as their > first argument. Is there a reason why you prefered to have it as the > second argument? No particular reason. I'll put the repository argument first in the next version. Thanks!
[Outreachy PATCH v2] negotiator/default: stop using the_repository
Author: Okhuomon Ajayi
Date: Tue, 03 Nov 2026 15:50
Date: Tue, 03 Nov 2026 15:50
152 lines
15565 bytes
15565 bytes
The default negotiator uses the_repository to parse commits,
clear marks, and walk refs. fetch_negotiator_init() already
has the repository but does not pass it down.
Give default_negotiator_init() a repository parameter, store
it on the negotiation state, and use it for those calls.
clear_marks() receives the repository through its callback
data. Drop USE_THE_REPOSITORY_VARIABLE.
Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
---
Changes since v1:
- Put the repository first in default_negotiator_init(), as
Christian suggested.
- Pass ns to mark_common() in have_sent().
Thanks, Christian, for the review.
fetch-negotiator.c | 2 +-
negotiator/default.c | 28 ++++++++++++++++------------
negotiator/default.h | 4 +++-
3 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/fetch-negotiator.c b/fetch-negotiator.c
index be383367f5..a5183bb3bc 100644
--- a/fetch-negotiator.c
+++ b/fetch-negotiator.c
@@ -19,7 +19,7 @@ void fetch_negotiator_init(struct repository *r,
return;
case FETCH_NEGOTIATION_CONSECUTIVE:
- default_negotiator_init(negotiator);
+ default_negotiator_init(r, negotiator);
return;
}
}
diff --git a/negotiator/default.c b/negotiator/default.c
index 19cdf3808c..f7cb52f10c 100644
--- a/negotiator/default.c
+++ b/negotiator/default.c
@@ -1,5 +1,3 @@
-#define USE_THE_REPOSITORY_VARIABLE
-
#include "git-compat-util.h"
#include "default.h"
#include "../commit.h"
@@ -18,6 +16,7 @@
static int marked;
struct negotiation_state {
+ struct repository *repo;
struct prio_queue rev_list;
int non_common_revs;
};
@@ -28,7 +27,7 @@ static void rev_list_push(struct negotiation_state *ns,
if (!(commit->object.flags & mark)) {
commit->object.flags |= mark;
- if (repo_parse_commit(the_repository, commit))
+ if (repo_parse_commit(ns->repo, commit))
return;
prio_queue_put(&ns->rev_list, commit);
@@ -38,9 +37,10 @@ static void rev_list_push(struct negotiation_state *ns,
}
}
-static int clear_marks(const struct reference *ref, void *cb_data UNUSED)
+static int clear_marks(const struct reference *ref, void *cb_data)
{
- struct object *o = deref_tag(the_repository, parse_object(the_repository, ref->oid),
+ struct repository *r = cb_data;
+ struct object *o = deref_tag(r, parse_object(r, ref->oid),
ref->name, 0);
if (o && o->type == OBJ_COMMIT)
@@ -78,7 +78,7 @@ static void mark_common(struct negotiation_state *ns, struct commit *commit,
struct commit_list *parents;
if (!o->parsed && !dont_parse)
- if (repo_parse_commit(the_repository, commit))
+ if (repo_parse_commit(ns->repo, commit))
continue;
for (parents = commit->parents;
@@ -119,7 +119,7 @@ static const struct object_id *get_rev(struct negotiation_state *ns)
commit = prio_queue_get(&ns->rev_list);
if (!commit)
return NULL;
- repo_parse_commit(the_repository, commit);
+ repo_parse_commit(ns->repo, commit);
parents = commit->parents;
commit->object.flags |= POPPED;
@@ -179,9 +179,11 @@ static int ack(struct fetch_negotiator *n, struct commit *c)
static void have_sent(struct fetch_negotiator *n, struct commit *c)
{
- if (repo_parse_commit(the_repository, c))
+ struct negotiation_state *ns = n->data;
+
+ if (repo_parse_commit(ns->repo, c))
return;
- mark_common(n->data, c, 0, 0);
+ mark_common(ns, c, 0, 0);
}
static void release(struct fetch_negotiator *n)
@@ -190,7 +192,8 @@ static void release(struct fetch_negotiator *n)
FREE_AND_NULL(n->data);
}
-void default_negotiator_init(struct fetch_negotiator *negotiator)
+void default_negotiator_init(struct repository *r,
+ struct fetch_negotiator *negotiator)
{
struct negotiation_state *ns;
negotiator->known_common = known_common;
@@ -200,10 +203,11 @@ void default_negotiator_init(struct fetch_negotiator *negotiator)
negotiator->have_sent = have_sent;
negotiator->release = release;
negotiator->data = CALLOC_ARRAY(ns, 1);
+ ns->repo = r;
ns->rev_list.compare = compare_commits_by_commit_date;
if (marked)
- refs_for_each_ref(get_main_ref_store(the_repository),
- clear_marks, NULL);
+ refs_for_each_ref(get_main_ref_store(r),
+ clear_marks, r);
marked = 1;
}
diff --git a/negotiator/default.h b/negotiator/default.h
index d23a8f2fb8..98bc989cff 100644
--- a/negotiator/default.h
+++ b/negotiator/default.h
@@ -2,7 +2,9 @@
#define NEGOTIATOR_DEFAULT_H
struct fetch_negotiator;
+struct repository;
-void default_negotiator_init(struct fetch_negotiator *negotiator);
+void default_negotiator_init(struct repository *r,
+ struct fetch_negotiator *negotiator);
#endif
base-commit: 7e34d8174dcda3435d1404c9a30bef46afe6c13e
--
2.56.0
Re: [Outreachy PATCH v2] negotiator/default: stop using the_repository
Author: Okhuomon Ajayi
Date: Mon, 23 Nov 2026 09:29
Date: Mon, 23 Nov 2026 09:29
173 lines
17933 bytes
17933 bytes
Hi Christian,
Gentle ping on this v2. It's in 'seen' marked "Needs review". Is there
anything you'd like me to change?
Thanks,
Okhuomon
On Tue, Nov 3, 2026 at 4:50 PM Okhuomon Ajayi <okhuomonajayi54@gmail.com> wrote:
>
> The default negotiator uses the_repository to parse commits,
> clear marks, and walk refs. fetch_negotiator_init() already
> has the repository but does not pass it down.
>
> Give default_negotiator_init() a repository parameter, store
> it on the negotiation state, and use it for those calls.
> clear_marks() receives the repository through its callback
> data. Drop USE_THE_REPOSITORY_VARIABLE.
>
> Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
> ---
> Changes since v1:
> - Put the repository first in default_negotiator_init(), as
> Christian suggested.
> - Pass ns to mark_common() in have_sent().
>
> Thanks, Christian, for the review.
>
> fetch-negotiator.c | 2 +-
> negotiator/default.c | 28 ++++++++++++++++------------
> negotiator/default.h | 4 +++-
> 3 files changed, 20 insertions(+), 14 deletions(-)
>
> diff --git a/fetch-negotiator.c b/fetch-negotiator.c
> index be383367f5..a5183bb3bc 100644
> --- a/fetch-negotiator.c
> +++ b/fetch-negotiator.c
> @@ -19,7 +19,7 @@ void fetch_negotiator_init(struct repository *r,
> return;
>
> case FETCH_NEGOTIATION_CONSECUTIVE:
> - default_negotiator_init(negotiator);
> + default_negotiator_init(r, negotiator);
> return;
> }
> }
> diff --git a/negotiator/default.c b/negotiator/default.c
> index 19cdf3808c..f7cb52f10c 100644
> --- a/negotiator/default.c
> +++ b/negotiator/default.c
> @@ -1,5 +1,3 @@
> -#define USE_THE_REPOSITORY_VARIABLE
> -
> #include "git-compat-util.h"
> #include "default.h"
> #include "../commit.h"
> @@ -18,6 +16,7 @@
> static int marked;
>
> struct negotiation_state {
> + struct repository *repo;
> struct prio_queue rev_list;
> int non_common_revs;
> };
> @@ -28,7 +27,7 @@ static void rev_list_push(struct negotiation_state *ns,
> if (!(commit->object.flags & mark)) {
> commit->object.flags |= mark;
>
> - if (repo_parse_commit(the_repository, commit))
> + if (repo_parse_commit(ns->repo, commit))
> return;
>
> prio_queue_put(&ns->rev_list, commit);
> @@ -38,9 +37,10 @@ static void rev_list_push(struct negotiation_state *ns,
> }
> }
>
> -static int clear_marks(const struct reference *ref, void *cb_data UNUSED)
> +static int clear_marks(const struct reference *ref, void *cb_data)
> {
> - struct object *o = deref_tag(the_repository, parse_object(the_repository, ref->oid),
> + struct repository *r = cb_data;
> + struct object *o = deref_tag(r, parse_object(r, ref->oid),
> ref->name, 0);
>
> if (o && o->type == OBJ_COMMIT)
> @@ -78,7 +78,7 @@ static void mark_common(struct negotiation_state *ns, struct commit *commit,
> struct commit_list *parents;
>
> if (!o->parsed && !dont_parse)
> - if (repo_parse_commit(the_repository, commit))
> + if (repo_parse_commit(ns->repo, commit))
> continue;
>
> for (parents = commit->parents;
> @@ -119,7 +119,7 @@ static const struct object_id *get_rev(struct negotiation_state *ns)
> commit = prio_queue_get(&ns->rev_list);
> if (!commit)
> return NULL;
> - repo_parse_commit(the_repository, commit);
> + repo_parse_commit(ns->repo, commit);
> parents = commit->parents;
>
> commit->object.flags |= POPPED;
> @@ -179,9 +179,11 @@ static int ack(struct fetch_negotiator *n, struct commit *c)
>
> static void have_sent(struct fetch_negotiator *n, struct commit *c)
> {
> - if (repo_parse_commit(the_repository, c))
> + struct negotiation_state *ns = n->data;
> +
> + if (repo_parse_commit(ns->repo, c))
> return;
> - mark_common(n->data, c, 0, 0);
> + mark_common(ns, c, 0, 0);
> }
>
> static void release(struct fetch_negotiator *n)
> @@ -190,7 +192,8 @@ static void release(struct fetch_negotiator *n)
> FREE_AND_NULL(n->data);
> }
>
> -void default_negotiator_init(struct fetch_negotiator *negotiator)
> +void default_negotiator_init(struct repository *r,
> + struct fetch_negotiator *negotiator)
> {
> struct negotiation_state *ns;
> negotiator->known_common = known_common;
> @@ -200,10 +203,11 @@ void default_negotiator_init(struct fetch_negotiator *negotiator)
> negotiator->have_sent = have_sent;
> negotiator->release = release;
> negotiator->data = CALLOC_ARRAY(ns, 1);
> + ns->repo = r;
> ns->rev_list.compare = compare_commits_by_commit_date;
>
> if (marked)
> - refs_for_each_ref(get_main_ref_store(the_repository),
> - clear_marks, NULL);
> + refs_for_each_ref(get_main_ref_store(r),
> + clear_marks, r);
> marked = 1;
> }
> diff --git a/negotiator/default.h b/negotiator/default.h
> index d23a8f2fb8..98bc989cff 100644
> --- a/negotiator/default.h
> +++ b/negotiator/default.h
> @@ -2,7 +2,9 @@
> #define NEGOTIATOR_DEFAULT_H
>
> struct fetch_negotiator;
> +struct repository;
>
> -void default_negotiator_init(struct fetch_negotiator *negotiator);
> +void default_negotiator_init(struct repository *r,
> + struct fetch_negotiator *negotiator);
>
> #endif
>
> base-commit: 7e34d8174dcda3435d1404c9a30bef46afe6c13e
> --
> 2.56.0
>
Re: [Outreachy PATCH v2] negotiator/default: stop using the_repository
Author: Christian Couder
Date: Tue, 24 Nov 2026 08:41
Date: Tue, 24 Nov 2026 08:41
25 lines
12613 bytes
12613 bytes
On Tue, Nov 3, 2026 at 4:50 PM Okhuomon Ajayi <okhuomonajayi54@gmail.com> wrote: > > The default negotiator uses the_repository to parse commits, > clear marks, and walk refs. fetch_negotiator_init() already > has the repository but does not pass it down. > > Give default_negotiator_init() a repository parameter, store > it on the negotiation state, and use it for those calls. > clear_marks() receives the repository through its callback > data. Drop USE_THE_REPOSITORY_VARIABLE. > > Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com> > --- > Changes since v1: > - Put the repository first in default_negotiator_init(), as > Christian suggested. > - Pass ns to mark_common() in have_sent(). Sorry for the delay in the review. This version 2 looks good to me. Thanks!
Re: [Outreachy PATCH v2] negotiator/default: stop using the_repository
Author: Okhuomon Ajayi
Date: Tue, 24 Nov 2026 08:47
Date: Tue, 24 Nov 2026 08:47
9 lines
12083 bytes
12083 bytes
On Tue, Nov 24, 2026 at 9:41 AM Christian Couder <christian.couder@gmail.com> wrote: > This version 2 looks good to me. Thanks for the review, Christian. Okhuomon
Re: [Outreachy PATCH v2] negotiator/default: stop using the_repository
Author: Junio C Hamano
Date: Tue, 24 Nov 2026 15:23
Date: Tue, 24 Nov 2026 15:23
27 lines
13871 bytes
13871 bytes
Christian Couder <christian.couder@gmail.com> writes: > On Tue, Nov 3, 2026 at 4:50 PM Okhuomon Ajayi <okhuomonajayi54@gmail.com> wrote: >> >> The default negotiator uses the_repository to parse commits, >> clear marks, and walk refs. fetch_negotiator_init() already >> has the repository but does not pass it down. >> >> Give default_negotiator_init() a repository parameter, store >> it on the negotiation state, and use it for those calls. >> clear_marks() receives the repository through its callback >> data. Drop USE_THE_REPOSITORY_VARIABLE. >> >> Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com> >> --- >> Changes since v1: >> - Put the repository first in default_negotiator_init(), as >> Christian suggested. >> - Pass ns to mark_common() in have_sent(). > > Sorry for the delay in the review. > > This version 2 looks good to me. Thanks for writing and reviewing. Will mark the topic as ready for 'next', then.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads