Git development
 help / color / mirror / Atom feed
* [Outreachy PATCH] bundle-uri: use the passed repository for refs and tracing
@ 2026-10-28  9:34 Okhuomon Ajayi
  2026-10-28 11:05 ` Karthik Nayak
  2026-10-29 12:07 ` Patrick Steinhardt
  0 siblings, 2 replies; 8+ messages in thread
From: Okhuomon Ajayi @ 2026-10-28  9:34 UTC (permalink / raw)
  To: git
  Cc: christian.couder, usmanakinyemi202, siddharthasthana31,
	kaartic.sivaraam, Okhuomon Ajayi

unbundle_from_file() receives r and unbundles the objects into
it, but reads and writes the refs in the_repository.
fetch_bundle_uri() also has r, but uses the_repository for its
trace2 region.

Use r for both.

Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
---
unbundle_from_file() still depends on the_repository through
fetch_pack_fsck_objects(), which reads fetch.fsckObjects and
transfer.fsckObjects from the_repository's config. I left that out.

 bundle-uri.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/bundle-uri.c b/bundle-uri.c
index 2bb2eb99e4..0d612d92fe 100644
--- a/bundle-uri.c
+++ b/bundle-uri.c
@@ -448,9 +448,9 @@ static int unbundle_from_file(struct repository *r, const char *file)
 		strbuf_setlen(&bundle_ref, bundle_prefix_len);
 		strbuf_addstr(&bundle_ref, branch_name);
 
-		has_old = !refs_read_ref(get_main_ref_store(the_repository),
+		has_old = !refs_read_ref(get_main_ref_store(r),
 					 bundle_ref.buf, &old_oid);
-		refs_update_ref(get_main_ref_store(the_repository),
+		refs_update_ref(get_main_ref_store(r),
 				"fetched bundle", bundle_ref.buf, oid,
 				has_old ? &old_oid : NULL,
 				0, UPDATE_REFS_MSG_ON_ERR);
@@ -859,7 +859,7 @@ int fetch_bundle_uri(struct repository *r, const char *uri,
 		.id = xstrdup(""),
 	};
 
-	trace2_region_enter("fetch", "fetch-bundle-uri", the_repository);
+	trace2_region_enter("fetch", "fetch-bundle-uri", r);
 
 	init_bundle_list(&list);
 
@@ -886,7 +886,7 @@ int fetch_bundle_uri(struct repository *r, const char *uri,
 	for_all_bundles_in_list(&list, unlink_bundle, NULL);
 	clear_bundle_list(&list);
 	clear_remote_bundle_info(&bundle, NULL);
-	trace2_region_leave("fetch", "fetch-bundle-uri", the_repository);
+	trace2_region_leave("fetch", "fetch-bundle-uri", r);
 	return result;
 }
 

base-commit: 37b3475fb530c14109211faca33716a173db61ed
-- 
2.56.0


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

* Re: [Outreachy PATCH] bundle-uri: use the passed repository for refs and tracing
  2026-10-28  9:34 [Outreachy PATCH] bundle-uri: use the passed repository for refs and tracing Okhuomon Ajayi
@ 2026-10-28 11:05 ` Karthik Nayak
  2026-10-28 11:18   ` Okhuomon Ajayi
  2026-10-28 16:36   ` Junio C Hamano
  2026-10-29 12:07 ` Patrick Steinhardt
  1 sibling, 2 replies; 8+ messages in thread
From: Karthik Nayak @ 2026-10-28 11:05 UTC (permalink / raw)
  To: Okhuomon Ajayi, git
  Cc: christian.couder, usmanakinyemi202, siddharthasthana31,
	kaartic.sivaraam

[-- Attachment #1: Type: text/plain, Size: 463 bytes --]

Okhuomon Ajayi <okhuomonajayi54@gmail.com> writes:

> unbundle_from_file() receives r and unbundles the objects into
> it, but reads and writes the refs in the_repository.
> fetch_bundle_uri() also has r, but uses the_repository for its
> trace2 region.
>

Looking at the callers of `unbundle_from_file()` I don't see there is a
reason for divergence. i.e. both `r` and `the_repository` should point
to the same repository. So this does make sense to me.

Thanks

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 690 bytes --]

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

* Re: [Outreachy PATCH] bundle-uri: use the passed repository for refs and tracing
  2026-10-28 11:05 ` Karthik Nayak
@ 2026-10-28 11:18   ` Okhuomon Ajayi
  2026-10-28 16:36   ` Junio C Hamano
  1 sibling, 0 replies; 8+ messages in thread
From: Okhuomon Ajayi @ 2026-10-28 11:18 UTC (permalink / raw)
  To: Karthik Nayak
  Cc: git, christian.couder, usmanakinyemi202, siddharthasthana31,
	kaartic.sivaraam

On Wed, Oct 28, 2026 at 12:05 PM Karthik Nayak <karthik.188@gmail.com> wrote:
> Looking at the callers of `unbundle_from_file()` I don't see there is a
> reason for divergence. i.e. both `r` and `the_repository` should point
> to the same repository. So this does make sense to me.


Thanks for checking, Karthik!

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

* Re: [Outreachy PATCH] bundle-uri: use the passed repository for refs and tracing
  2026-10-28 11:05 ` Karthik Nayak
  2026-10-28 11:18   ` Okhuomon Ajayi
@ 2026-10-28 16:36   ` Junio C Hamano
  1 sibling, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2026-10-28 16:36 UTC (permalink / raw)
  To: Karthik Nayak
  Cc: Okhuomon Ajayi, git, christian.couder, usmanakinyemi202,
	siddharthasthana31, kaartic.sivaraam

Karthik Nayak <karthik.188@gmail.com> writes:

> Okhuomon Ajayi <okhuomonajayi54@gmail.com> writes:
>
>> unbundle_from_file() receives r and unbundles the objects into
>> it, but reads and writes the refs in the_repository.
>> fetch_bundle_uri() also has r, but uses the_repository for its
>> trace2 region.
>>
>
> Looking at the callers of `unbundle_from_file()` I don't see there is a
> reason for divergence. i.e. both `r` and `the_repository` should point
> to the same repository. So this does make sense to me.
>
> Thanks

Thanks.  Will queue and mark it ready for 'next'.

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

* Re: [Outreachy PATCH] bundle-uri: use the passed repository for refs and tracing
  2026-10-28  9:34 [Outreachy PATCH] bundle-uri: use the passed repository for refs and tracing Okhuomon Ajayi
  2026-10-28 11:05 ` Karthik Nayak
@ 2026-10-29 12:07 ` Patrick Steinhardt
  2026-10-29 12:47   ` Okhuomon Ajayi
  2026-10-29 13:13   ` [Outreachy PATCH v2] bundle-uri: stop using the_repository Okhuomon Ajayi
  1 sibling, 2 replies; 8+ messages in thread
From: Patrick Steinhardt @ 2026-10-29 12:07 UTC (permalink / raw)
  To: Okhuomon Ajayi
  Cc: git, christian.couder, usmanakinyemi202, siddharthasthana31,
	kaartic.sivaraam

On Wed, Oct 28, 2026 at 10:34:55AM +0100, Okhuomon Ajayi wrote:
> unbundle_from_file() receives r and unbundles the objects into
> it, but reads and writes the refs in the_repository.
> fetch_bundle_uri() also has r, but uses the_repository for its
> trace2 region.
> 
> Use r for both.

Okay.

> Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
> ---
> unbundle_from_file() still depends on the_repository through
> fetch_pack_fsck_objects(), which reads fetch.fsckObjects and
> transfer.fsckObjects from the_repository's config. I left that out.

That's fine, we know that subsystems may still implicitly depend on
it even though they don't declare `USE_THE_REPOSITORY_VARIABLE` anymore.

What I find curious though is why you didn't go the last mile so that we
could drop that define from this subsystem altogether. There's only two
sites left that use `the_repository`, and both of them are trivial to
convert (see below patch).

So shouldn't we maybe also fix those cases while already at it and then
drop the define?

Patrick

diff --git a/bundle-uri.c b/bundle-uri.c
index 1f1683b52e9..abdb99f4375 100644
--- a/bundle-uri.c
+++ b/bundle-uri.c
@@ -285,7 +285,7 @@ int bundle_uri_parse_config_format(const char *uri,
 	return result;
 }
 
-static char *find_temp_filename(void)
+static char *find_temp_filename(struct repository *r)
 {
 	int fd;
 	struct strbuf name = STRBUF_INIT;
@@ -293,7 +293,7 @@ static char *find_temp_filename(void)
 	 * Find a temporary filename that is available. This is briefly
 	 * racy, but unlikely to collide.
 	 */
-	fd = odb_mkstemp(the_repository->objects, &name,
+	fd = odb_mkstemp(r->objects, &name,
 			 "bundles/tmp_uri_XXXXXX");
 	if (fd < 0) {
 		warning(_("failed to create temporary file"));
@@ -383,7 +383,7 @@ static int download_https_uri_to_file(const char *file, const char *uri)
 	return result;
 }
 
-static int copy_uri_to_file(const char *filename, const char *uri)
+static int copy_uri_to_file(struct repository *r, const char *filename, const char *uri)
 {
 	const char *out;
 
@@ -395,7 +395,7 @@ static int copy_uri_to_file(const char *filename, const char *uri)
 		uri = out;
 
 	/* Copy as a file */
-	return copy_file(the_repository, filename, uri, 0);
+	return copy_file(r, filename, uri, 0);
 }
 
 static int unbundle_from_file(struct repository *r, const char *file)
@@ -773,12 +773,12 @@ static int fetch_bundle_uri_internal(struct repository *r,
 	}
 
 	if (!bundle->file &&
-	    !(bundle->file = find_temp_filename())) {
+	    !(bundle->file = find_temp_filename(r))) {
 		result = -1;
 		goto cleanup;
 	}
 
-	if ((result = copy_uri_to_file(bundle->file, bundle->uri))) {
+	if ((result = copy_uri_to_file(r, bundle->file, bundle->uri))) {
 		warning(_("failed to download bundle from URI '%s'"), bundle->uri);
 		goto cleanup;
 	}

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

* Re: [Outreachy PATCH] bundle-uri: use the passed repository for refs and tracing
  2026-10-29 12:07 ` Patrick Steinhardt
@ 2026-10-29 12:47   ` Okhuomon Ajayi
  2026-10-29 13:13   ` [Outreachy PATCH v2] bundle-uri: stop using the_repository Okhuomon Ajayi
  1 sibling, 0 replies; 8+ messages in thread
From: Okhuomon Ajayi @ 2026-10-29 12:47 UTC (permalink / raw)
  To: Patrick Steinhardt
  Cc: git, christian.couder, usmanakinyemi202, siddharthasthana31,
	kaartic.sivaraam

On Thu, Oct 29, 2026 at 1:07 PM Patrick Steinhardt <ps@pks.im> wrote:
> So shouldn't we maybe also fix those cases while already at it and then
> drop the define?


Thanks, Patrick. Yes, that makes sense. I applied your diff and
bundle-uri.c builds
without USE_THE_REPOSITORY_VARIABLE. I'll send a v2 that converts
find_temp_filename() and copy_uri_to_file() too and drops the define.

Junio, please hold v1 from 'next'; v2 will replace it.

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

* [Outreachy PATCH v2] bundle-uri: stop using the_repository
  2026-10-29 12:07 ` Patrick Steinhardt
  2026-10-29 12:47   ` Okhuomon Ajayi
@ 2026-10-29 13:13   ` Okhuomon Ajayi
  2026-10-29 13:37     ` Patrick Steinhardt
  1 sibling, 1 reply; 8+ messages in thread
From: Okhuomon Ajayi @ 2026-10-29 13:13 UTC (permalink / raw)
  To: git
  Cc: christian.couder, usmanakinyemi202, siddharthasthana31,
	kaartic.sivaraam, ps, karthik.188, Okhuomon Ajayi

unbundle_from_file() receives r and unbundles the objects into
it, but reads and writes the refs in the_repository.
fetch_bundle_uri() also has r, but uses the_repository for its
trace2 region. find_temp_filename() and copy_uri_to_file() also
use the_repository, even though their only caller,
fetch_bundle_uri_internal(), has r.

Use r in all of these places, passing it to find_temp_filename()
and copy_uri_to_file(). With that, bundle-uri.c no longer uses
the_repository, so drop USE_THE_REPOSITORY_VARIABLE.

Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
---
Changes since v1:
- Also pass the repository to find_temp_filename() and
  copy_uri_to_file(), and drop USE_THE_REPOSITORY_VARIABLE,
  as suggested by Patrick.

Thanks, Patrick, for the suggestion and the diff, and Karthik
for the review.

unbundle_from_file() still depends on the_repository through
fetch_pack_fsck_objects(), which reads fetch.fsckObjects and
transfer.fsckObjects from the_repository's config.

 bundle-uri.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/bundle-uri.c b/bundle-uri.c
index 2bb2eb99e4..9797eaed9a 100644
--- a/bundle-uri.c
+++ b/bundle-uri.c
@@ -1,4 +1,3 @@
-#define USE_THE_REPOSITORY_VARIABLE
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
@@ -286,7 +285,7 @@ int bundle_uri_parse_config_format(const char *uri,
 	return result;
 }
 
-static char *find_temp_filename(void)
+static char *find_temp_filename(struct repository *r)
 {
 	int fd;
 	struct strbuf name = STRBUF_INIT;
@@ -294,7 +293,7 @@ static char *find_temp_filename(void)
 	 * Find a temporary filename that is available. This is briefly
 	 * racy, but unlikely to collide.
 	 */
-	fd = odb_mkstemp(the_repository->objects, &name,
+	fd = odb_mkstemp(r->objects, &name,
 			 "bundles/tmp_uri_XXXXXX");
 	if (fd < 0) {
 		warning(_("failed to create temporary file"));
@@ -384,7 +383,8 @@ static int download_https_uri_to_file(const char *file, const char *uri)
 	return result;
 }
 
-static int copy_uri_to_file(const char *filename, const char *uri)
+static int copy_uri_to_file(struct repository *r,
+			    const char *filename, const char *uri)
 {
 	const char *out;
 
@@ -396,7 +396,7 @@ static int copy_uri_to_file(const char *filename, const char *uri)
 		uri = out;
 
 	/* Copy as a file */
-	return copy_file(the_repository, filename, uri, 0);
+	return copy_file(r, filename, uri, 0);
 }
 
 static int unbundle_from_file(struct repository *r, const char *file)
@@ -448,9 +448,9 @@ static int unbundle_from_file(struct repository *r, const char *file)
 		strbuf_setlen(&bundle_ref, bundle_prefix_len);
 		strbuf_addstr(&bundle_ref, branch_name);
 
-		has_old = !refs_read_ref(get_main_ref_store(the_repository),
+		has_old = !refs_read_ref(get_main_ref_store(r),
 					 bundle_ref.buf, &old_oid);
-		refs_update_ref(get_main_ref_store(the_repository),
+		refs_update_ref(get_main_ref_store(r),
 				"fetched bundle", bundle_ref.buf, oid,
 				has_old ? &old_oid : NULL,
 				0, UPDATE_REFS_MSG_ON_ERR);
@@ -774,12 +774,12 @@ static int fetch_bundle_uri_internal(struct repository *r,
 	}
 
 	if (!bundle->file &&
-	    !(bundle->file = find_temp_filename())) {
+	    !(bundle->file = find_temp_filename(r))) {
 		result = -1;
 		goto cleanup;
 	}
 
-	if ((result = copy_uri_to_file(bundle->file, bundle->uri))) {
+	if ((result = copy_uri_to_file(r, bundle->file, bundle->uri))) {
 		warning(_("failed to download bundle from URI '%s'"), bundle->uri);
 		goto cleanup;
 	}
@@ -859,7 +859,7 @@ int fetch_bundle_uri(struct repository *r, const char *uri,
 		.id = xstrdup(""),
 	};
 
-	trace2_region_enter("fetch", "fetch-bundle-uri", the_repository);
+	trace2_region_enter("fetch", "fetch-bundle-uri", r);
 
 	init_bundle_list(&list);
 
@@ -886,7 +886,7 @@ int fetch_bundle_uri(struct repository *r, const char *uri,
 	for_all_bundles_in_list(&list, unlink_bundle, NULL);
 	clear_bundle_list(&list);
 	clear_remote_bundle_info(&bundle, NULL);
-	trace2_region_leave("fetch", "fetch-bundle-uri", the_repository);
+	trace2_region_leave("fetch", "fetch-bundle-uri", r);
 	return result;
 }
 

base-commit: 37b3475fb530c14109211faca33716a173db61ed
-- 
2.56.0


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

* Re: [Outreachy PATCH v2] bundle-uri: stop using the_repository
  2026-10-29 13:13   ` [Outreachy PATCH v2] bundle-uri: stop using the_repository Okhuomon Ajayi
@ 2026-10-29 13:37     ` Patrick Steinhardt
  0 siblings, 0 replies; 8+ messages in thread
From: Patrick Steinhardt @ 2026-10-29 13:37 UTC (permalink / raw)
  To: Okhuomon Ajayi
  Cc: git, christian.couder, usmanakinyemi202, siddharthasthana31,
	kaartic.sivaraam, karthik.188

On Thu, Oct 29, 2026 at 02:13:25PM +0100, Okhuomon Ajayi wrote:
> Changes since v1:
> - Also pass the repository to find_temp_filename() and
>   copy_uri_to_file(), and drop USE_THE_REPOSITORY_VARIABLE,
>   as suggested by Patrick.
> 
> Thanks, Patrick, for the suggestion and the diff, and Karthik
> for the review.

Thanks, the diff looks as expected.

Patrick

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

end of thread, other threads:[~2026-10-29 13:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-28  9:34 [Outreachy PATCH] bundle-uri: use the passed repository for refs and tracing Okhuomon Ajayi
2026-10-28 11:05 ` Karthik Nayak
2026-10-28 11:18   ` Okhuomon Ajayi
2026-10-28 16:36   ` Junio C Hamano
2026-10-29 12:07 ` Patrick Steinhardt
2026-10-29 12:47   ` Okhuomon Ajayi
2026-10-29 13:13   ` [Outreachy PATCH v2] bundle-uri: stop using the_repository Okhuomon Ajayi
2026-10-29 13:37     ` Patrick Steinhardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox