{"thread":{"id":"66570","subject":"[Outreachy PATCH] checkout: use repository parameter in unique_tracking_name","startedAt":"2026-10-17T22:53:26Z","lastAt":"2026-11-04T09:05:34Z","messageCount":14,"participants":["Okhuomon Ajayi","Usman Akinyemi","Junio C Hamano","Christian Couder"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"555338","messageId":"20261017225326.7827-1-okhuomonajayi54@gmail.com","threadId":"66570","inReplyTo":null,"subject":"[Outreachy PATCH] checkout: use repository parameter in unique_tracking_name","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-10-17T22:53:26Z","receivedAt":"2026-10-17T22:53:26Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"The function uses the_repository to read configuration and look up\nthe object ID of a tracking reference.\n\nPass the repository to unique_tracking_name() and through\ntracking_name_data. Callers pass the_repository for now.\n\nThis removes the need for USE_THE_REPOSITORY_VARIABLE in checkout.c.\n\nSigned-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>\n---\n builtin/checkout.c |  3 ++-\n builtin/worktree.c |  6 ++++--\n checkout.c         | 11 ++++++-----\n checkout.h         |  4 +++-\n 4 files changed, 15 insertions(+), 9 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 2d575a4f57..bad49368b9 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -1389,7 +1389,8 @@ static char *parse_remote_branch(const char *arg,\n \tint num_matches = 0;\n \tstruct string_list matched_remote_names = STRING_LIST_INIT_DUP;\n \n-\tchar *remote = unique_tracking_name(arg, rev, &num_matches,\n+\tchar *remote = unique_tracking_name(the_repository, arg, rev,\n+\t\t\t\t\t    &num_matches,\n \t\t\t\t\t    &matched_remote_names);\n \n \tif (remote && could_be_checkout_paths) {\ndiff --git a/builtin/worktree.c b/builtin/worktree.c\nindex 77ecd0f71f..203456bd23 100644\n--- a/builtin/worktree.c\n+++ b/builtin/worktree.c\n@@ -802,7 +802,8 @@ static char *dwim_branch(const struct add_opts *opts, const char *path, char **n\n \t\tint num_matches = 0;\n \t\tstruct string_list matched_remote_names = STRING_LIST_INIT_DUP;\n \n-\t\tremote = unique_tracking_name(*new_branch, &oid, &num_matches,\n+\t\tremote = unique_tracking_name(the_repository, *new_branch,\n+\t\t\t\t\t      &oid, &num_matches,\n \t\t\t\t\t      &matched_remote_names);\n \t\tif (!remote && num_matches > 1) {\n \t\t\tif (!opts->quiet &&\n@@ -938,7 +939,8 @@ static int add(int ac, const char **av, const char *prefix,\n \t\t\tint num_matches = 0;\n \t\t\tstruct string_list matched_remote_names = STRING_LIST_INIT_DUP;\n \n-\t\t\tremote = unique_tracking_name(branch, &oid, &num_matches,\n+\t\t\tremote = unique_tracking_name(the_repository, branch,\n+\t\t\t\t\t\t      &oid, &num_matches,\n \t\t\t\t\t\t      &matched_remote_names);\n \t\t\tif (remote) {\n \t\t\t\tnew_branch = branch;\ndiff --git a/checkout.c b/checkout.c\nindex a0d0229435..f0fb40d48e 100644\n--- a/checkout.c\n+++ b/checkout.c\n@@ -1,5 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n-\n #include \"git-compat-util.h\"\n #include \"object-name.h\"\n #include \"remote.h\"\n@@ -11,6 +9,7 @@\n #include \"string-list.h\"\n \n struct tracking_name_data {\n+\tstruct repository *repo;\n \t/* const */ char *src_ref;\n \tchar *dst_ref;\n \tstruct object_id *dst_oid;\n@@ -30,7 +29,7 @@ static int check_tracking_name(struct remote *remote, void *cb_data)\n \tmemset(&query, 0, sizeof(struct refspec_item));\n \tquery.src = cb->src_ref;\n \tif (remote_find_tracking(remote, &query) ||\n-\t    repo_get_oid(the_repository, query.dst, cb->dst_oid)) {\n+\t    repo_get_oid(cb->repo, query.dst, cb->dst_oid)) {\n \t\tfree(query.dst);\n \t\treturn 0;\n \t}\n@@ -51,17 +50,19 @@ static int check_tracking_name(struct remote *remote, void *cb_data)\n \treturn 0;\n }\n \n-char *unique_tracking_name(const char *name, struct object_id *oid,\n+char *unique_tracking_name(struct repository *repo,\n+\t\t\t   const char *name, struct object_id *oid,\n \t\t\t   int *dwim_remotes_matched,\n \t\t\t   struct string_list *dwim_remote_names)\n {\n \tstruct tracking_name_data cb_data = TRACKING_NAME_DATA_INIT;\n \tconst char *default_remote = NULL;\n \n-\tif (!repo_config_get_string_tmp(the_repository,\n+\tif (!repo_config_get_string_tmp(repo,\n \t\t\t\t\t\"checkout.defaultremote\",\n \t\t\t\t\t&default_remote))\n \t\tcb_data.default_remote = default_remote;\n+\tcb_data.repo = repo;\n \tcb_data.src_ref = xstrfmt(\"refs/heads/%s\", name);\n \tcb_data.dst_oid = oid;\n \tcb_data.remote_names = dwim_remote_names;\ndiff --git a/checkout.h b/checkout.h\nindex 0b185a0fc9..25fe7dfb7c 100644\n--- a/checkout.h\n+++ b/checkout.h\n@@ -3,6 +3,7 @@\n \n #include \"hash.h\"\n \n+struct repository;\n struct string_list;\n \n /*\n@@ -10,7 +11,8 @@ struct string_list;\n  * tracking branch.  Return the name of the remote if such a branch\n  * exists, NULL otherwise.\n  */\n-char *unique_tracking_name(const char *name,\n+char *unique_tracking_name(struct repository *repo,\n+\t\t\t   const char *name,\n \t\t\t   struct object_id *oid,\n \t\t\t   int *dwim_remotes_matched,\n \t\t\t   struct string_list *dwim_remote_names);\n-- \n2.54.0\n\n\n"},{"id":"555836","messageId":"CAPSxiM9fCTEoQDv09fX_NZCcLRXYaaCdWXPxDT7JZ+LCwT1YQA@mail.gmail.com","threadId":"66570","inReplyTo":"20261017225326.7827-1-okhuomonajayi54@gmail.com","subject":"Re: [Outreachy PATCH] checkout: use repository parameter in unique_tracking_name","fromName":"Usman Akinyemi","fromEmail":"usmanakinyemi202@gmail.com","sentAt":"2026-10-22T09:41:04Z","receivedAt":"2026-10-22T09:41:04Z","isPatch":true,"sender":{"key":"usmanakinyemi202@gmail.com","avatar":"https://avatars.githubusercontent.com/u/86585626?v=4"},"body":">\n> The function uses the_repository to read configuration and look up\nWhich function ? You have left the reader of the commit message to wonder\nwhat function ?\n> the object ID of a tracking reference.\n>\n> Pass the repository to unique_tracking_name() and through\n> tracking_name_data. Callers pass the_repository for now.\nYou could be more descriptive more about the patches, someone should be able to\ngo through the commit and sort get the whole idea of the patch, what\nwas present,\nWhat changes and why ?\n\nOtherwise, the changes look good to me.\n\n>\n> This removes the need for USE_THE_REPOSITORY_VARIABLE in checkout.c.\n>\n\nThanks.\n\n"},{"id":"555845","messageId":"CAFpMFfDhbadSn9gzQmfL02Qk_GKDzCCZKsmt_p6YPoGGHhrjjw@mail.gmail.com","threadId":"66570","inReplyTo":"CAPSxiM9fCTEoQDv09fX_NZCcLRXYaaCdWXPxDT7JZ+LCwT1YQA@mail.gmail.com","subject":"Re: [Outreachy PATCH] checkout: use repository parameter in unique_tracking_name","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-10-22T10:26:51Z","receivedAt":"2026-10-22T10:26:51Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"On Thu, Oct 22, 2026 at 10:41 AM Usman Akinyemi\n<usmanakinyemi202@gmail.com> wrote:\n> > Pass the repository to unique_tracking_name() and through\n> > tracking_name_data. Callers pass the_repository for now.\n> You could be more descriptive more about the patches, someone should be able to\n> go through the commit and sort get the whole idea of the patch, what\n> was present,\n> What changes and why ?\n\nThanks for the review. I will name unique_tracking_name() in the\nmessage and explain what it used before, what changed, and why, so\nthe commit can be understood on its own. I will send v2 with the\nupdated message.\n\n"},{"id":"555849","messageId":"20261022105641.68963-1-okhuomonajayi54@gmail.com","threadId":"66570","inReplyTo":"20261017225326.7827-1-okhuomonajayi54@gmail.com","subject":"[Outreachy PATCH v2] checkout: pass the repository to unique_tracking_name()","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-10-22T10:56:41Z","receivedAt":"2026-10-22T10:56:41Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"unique_tracking_name() uses the_repository to read the\n\"checkout.defaultRemote\" configuration and look up the object\nID of a remote-tracking branch.\n\nPass the repository to unique_tracking_name() and through\ntracking_name_data so check_tracking_name() can use it for\nthe object lookup. Update the three callers to pass\nthe_repository.\n\nThis removes the need for USE_THE_REPOSITORY_VARIABLE in\ncheckout.c. for_each_remote() still uses the global repository;\nleave that for a separate change.\n\nSigned-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>\n---\nChanges since v1:\n- Rewrote the commit message to name the function and say what was\n  there, what changed and why, as suggested by Usman. No code changes.\n\n builtin/checkout.c |  3 ++-\n builtin/worktree.c |  6 ++++--\n checkout.c         | 11 ++++++-----\n checkout.h         |  4 +++-\n 4 files changed, 15 insertions(+), 9 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 2d575a4f57..bad49368b9 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -1389,7 +1389,8 @@ static char *parse_remote_branch(const char *arg,\n \tint num_matches = 0;\n \tstruct string_list matched_remote_names = STRING_LIST_INIT_DUP;\n \n-\tchar *remote = unique_tracking_name(arg, rev, &num_matches,\n+\tchar *remote = unique_tracking_name(the_repository, arg, rev,\n+\t\t\t\t\t    &num_matches,\n \t\t\t\t\t    &matched_remote_names);\n \n \tif (remote && could_be_checkout_paths) {\ndiff --git a/builtin/worktree.c b/builtin/worktree.c\nindex 77ecd0f71f..203456bd23 100644\n--- a/builtin/worktree.c\n+++ b/builtin/worktree.c\n@@ -802,7 +802,8 @@ static char *dwim_branch(const struct add_opts *opts, const char *path, char **n\n \t\tint num_matches = 0;\n \t\tstruct string_list matched_remote_names = STRING_LIST_INIT_DUP;\n \n-\t\tremote = unique_tracking_name(*new_branch, &oid, &num_matches,\n+\t\tremote = unique_tracking_name(the_repository, *new_branch,\n+\t\t\t\t\t      &oid, &num_matches,\n \t\t\t\t\t      &matched_remote_names);\n \t\tif (!remote && num_matches > 1) {\n \t\t\tif (!opts->quiet &&\n@@ -938,7 +939,8 @@ static int add(int ac, const char **av, const char *prefix,\n \t\t\tint num_matches = 0;\n \t\t\tstruct string_list matched_remote_names = STRING_LIST_INIT_DUP;\n \n-\t\t\tremote = unique_tracking_name(branch, &oid, &num_matches,\n+\t\t\tremote = unique_tracking_name(the_repository, branch,\n+\t\t\t\t\t\t      &oid, &num_matches,\n \t\t\t\t\t\t      &matched_remote_names);\n \t\t\tif (remote) {\n \t\t\t\tnew_branch = branch;\ndiff --git a/checkout.c b/checkout.c\nindex a0d0229435..f0fb40d48e 100644\n--- a/checkout.c\n+++ b/checkout.c\n@@ -1,5 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n-\n #include \"git-compat-util.h\"\n #include \"object-name.h\"\n #include \"remote.h\"\n@@ -11,6 +9,7 @@\n #include \"string-list.h\"\n \n struct tracking_name_data {\n+\tstruct repository *repo;\n \t/* const */ char *src_ref;\n \tchar *dst_ref;\n \tstruct object_id *dst_oid;\n@@ -30,7 +29,7 @@ static int check_tracking_name(struct remote *remote, void *cb_data)\n \tmemset(&query, 0, sizeof(struct refspec_item));\n \tquery.src = cb->src_ref;\n \tif (remote_find_tracking(remote, &query) ||\n-\t    repo_get_oid(the_repository, query.dst, cb->dst_oid)) {\n+\t    repo_get_oid(cb->repo, query.dst, cb->dst_oid)) {\n \t\tfree(query.dst);\n \t\treturn 0;\n \t}\n@@ -51,17 +50,19 @@ static int check_tracking_name(struct remote *remote, void *cb_data)\n \treturn 0;\n }\n \n-char *unique_tracking_name(const char *name, struct object_id *oid,\n+char *unique_tracking_name(struct repository *repo,\n+\t\t\t   const char *name, struct object_id *oid,\n \t\t\t   int *dwim_remotes_matched,\n \t\t\t   struct string_list *dwim_remote_names)\n {\n \tstruct tracking_name_data cb_data = TRACKING_NAME_DATA_INIT;\n \tconst char *default_remote = NULL;\n \n-\tif (!repo_config_get_string_tmp(the_repository,\n+\tif (!repo_config_get_string_tmp(repo,\n \t\t\t\t\t\"checkout.defaultremote\",\n \t\t\t\t\t&default_remote))\n \t\tcb_data.default_remote = default_remote;\n+\tcb_data.repo = repo;\n \tcb_data.src_ref = xstrfmt(\"refs/heads/%s\", name);\n \tcb_data.dst_oid = oid;\n \tcb_data.remote_names = dwim_remote_names;\ndiff --git a/checkout.h b/checkout.h\nindex 0b185a0fc9..25fe7dfb7c 100644\n--- a/checkout.h\n+++ b/checkout.h\n@@ -3,6 +3,7 @@\n \n #include \"hash.h\"\n \n+struct repository;\n struct string_list;\n \n /*\n@@ -10,7 +11,8 @@ struct string_list;\n  * tracking branch.  Return the name of the remote if such a branch\n  * exists, NULL otherwise.\n  */\n-char *unique_tracking_name(const char *name,\n+char *unique_tracking_name(struct repository *repo,\n+\t\t\t   const char *name,\n \t\t\t   struct object_id *oid,\n \t\t\t   int *dwim_remotes_matched,\n \t\t\t   struct string_list *dwim_remote_names);\n\nbase-commit: c51408889c3b372814bc20b9431c3b74d0d268eb\n-- \n2.56.0\n\n\n"},{"id":"555899","messageId":"xmqqo6clfu19.fsf@gitster.g","threadId":"66570","inReplyTo":"20261022105641.68963-1-okhuomonajayi54@gmail.com","subject":"Re: [Outreachy PATCH v2] checkout: pass the repository to unique_tracking_name()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-10-22T18:51:30Z","receivedAt":"2026-10-22T18:51:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Okhuomon Ajayi <okhuomonajayi54@gmail.com> writes:\n\n> unique_tracking_name() uses the_repository to read the\n> \"checkout.defaultRemote\" configuration and look up the object\n> ID of a remote-tracking branch.\n>\n> Pass the repository to unique_tracking_name() and through\n> tracking_name_data so check_tracking_name() can use it for\n> the object lookup. Update the three callers to pass\n> the_repository.\n>\n> This removes the need for USE_THE_REPOSITORY_VARIABLE in\n> checkout.c. for_each_remote() still uses the global repository;\n> leave that for a separate change.\n\nThe mention of for_each_remote() feels weirdly abrupt.  Many other\nthings still rely on the the_repository global variable, but\nthere must be a reason why for_each_remote() is singled out in the\ncontext of this patch.  What is it?\n\nReplace the last sentence with something like:\n\n    The callers still cannot call unique_tracking_name() with an\n    arbitrary repository parameter other than the_repository, until\n    the call in unique_tracking_name() to for_each_remote(), which\n    only works with the_repository, is updated to take an arbitrary\n    repository instance.\n\nperhaps?\n\nAnd explained that way, it becomes dubious if we chose a good place\nto stop.  The updated unique_tracking_name() gives an illusion that\ncallers now can pass an arbitrary repository to it and expect it to\nwork correctly with the given repository, but it does not.\n\nSo, I dunno.\n\n\n> Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>\n> ---\n> Changes since v1:\n> - Rewrote the commit message to name the function and say what was\n>   there, what changed and why, as suggested by Usman. No code changes.\n>\n>  builtin/checkout.c |  3 ++-\n>  builtin/worktree.c |  6 ++++--\n>  checkout.c         | 11 ++++++-----\n>  checkout.h         |  4 +++-\n>  4 files changed, 15 insertions(+), 9 deletions(-)\n>\n> diff --git a/builtin/checkout.c b/builtin/checkout.c\n> index 2d575a4f57..bad49368b9 100644\n> --- a/builtin/checkout.c\n> +++ b/builtin/checkout.c\n> @@ -1389,7 +1389,8 @@ static char *parse_remote_branch(const char *arg,\n>  \tint num_matches = 0;\n>  \tstruct string_list matched_remote_names = STRING_LIST_INIT_DUP;\n>  \n> -\tchar *remote = unique_tracking_name(arg, rev, &num_matches,\n> +\tchar *remote = unique_tracking_name(the_repository, arg, rev,\n> +\t\t\t\t\t    &num_matches,\n>  \t\t\t\t\t    &matched_remote_names);\n>  \n>  \tif (remote && could_be_checkout_paths) {\n> diff --git a/builtin/worktree.c b/builtin/worktree.c\n> index 77ecd0f71f..203456bd23 100644\n> --- a/builtin/worktree.c\n> +++ b/builtin/worktree.c\n> @@ -802,7 +802,8 @@ static char *dwim_branch(const struct add_opts *opts, const char *path, char **n\n>  \t\tint num_matches = 0;\n>  \t\tstruct string_list matched_remote_names = STRING_LIST_INIT_DUP;\n>  \n> -\t\tremote = unique_tracking_name(*new_branch, &oid, &num_matches,\n> +\t\tremote = unique_tracking_name(the_repository, *new_branch,\n> +\t\t\t\t\t      &oid, &num_matches,\n>  \t\t\t\t\t      &matched_remote_names);\n>  \t\tif (!remote && num_matches > 1) {\n>  \t\t\tif (!opts->quiet &&\n> @@ -938,7 +939,8 @@ static int add(int ac, const char **av, const char *prefix,\n>  \t\t\tint num_matches = 0;\n>  \t\t\tstruct string_list matched_remote_names = STRING_LIST_INIT_DUP;\n>  \n> -\t\t\tremote = unique_tracking_name(branch, &oid, &num_matches,\n> +\t\t\tremote = unique_tracking_name(the_repository, branch,\n> +\t\t\t\t\t\t      &oid, &num_matches,\n>  \t\t\t\t\t\t      &matched_remote_names);\n>  \t\t\tif (remote) {\n>  \t\t\t\tnew_branch = branch;\n> diff --git a/checkout.c b/checkout.c\n> index a0d0229435..f0fb40d48e 100644\n> --- a/checkout.c\n> +++ b/checkout.c\n> @@ -1,5 +1,3 @@\n> -#define USE_THE_REPOSITORY_VARIABLE\n> -\n>  #include \"git-compat-util.h\"\n>  #include \"object-name.h\"\n>  #include \"remote.h\"\n> @@ -11,6 +9,7 @@\n>  #include \"string-list.h\"\n>  \n>  struct tracking_name_data {\n> +\tstruct repository *repo;\n>  \t/* const */ char *src_ref;\n>  \tchar *dst_ref;\n>  \tstruct object_id *dst_oid;\n> @@ -30,7 +29,7 @@ static int check_tracking_name(struct remote *remote, void *cb_data)\n>  \tmemset(&query, 0, sizeof(struct refspec_item));\n>  \tquery.src = cb->src_ref;\n>  \tif (remote_find_tracking(remote, &query) ||\n> -\t    repo_get_oid(the_repository, query.dst, cb->dst_oid)) {\n> +\t    repo_get_oid(cb->repo, query.dst, cb->dst_oid)) {\n>  \t\tfree(query.dst);\n>  \t\treturn 0;\n>  \t}\n> @@ -51,17 +50,19 @@ static int check_tracking_name(struct remote *remote, void *cb_data)\n>  \treturn 0;\n>  }\n>  \n> -char *unique_tracking_name(const char *name, struct object_id *oid,\n> +char *unique_tracking_name(struct repository *repo,\n> +\t\t\t   const char *name, struct object_id *oid,\n>  \t\t\t   int *dwim_remotes_matched,\n>  \t\t\t   struct string_list *dwim_remote_names)\n>  {\n>  \tstruct tracking_name_data cb_data = TRACKING_NAME_DATA_INIT;\n>  \tconst char *default_remote = NULL;\n>  \n> -\tif (!repo_config_get_string_tmp(the_repository,\n> +\tif (!repo_config_get_string_tmp(repo,\n>  \t\t\t\t\t\"checkout.defaultremote\",\n>  \t\t\t\t\t&default_remote))\n>  \t\tcb_data.default_remote = default_remote;\n> +\tcb_data.repo = repo;\n>  \tcb_data.src_ref = xstrfmt(\"refs/heads/%s\", name);\n>  \tcb_data.dst_oid = oid;\n>  \tcb_data.remote_names = dwim_remote_names;\n> diff --git a/checkout.h b/checkout.h\n> index 0b185a0fc9..25fe7dfb7c 100644\n> --- a/checkout.h\n> +++ b/checkout.h\n> @@ -3,6 +3,7 @@\n>  \n>  #include \"hash.h\"\n>  \n> +struct repository;\n>  struct string_list;\n>  \n>  /*\n> @@ -10,7 +11,8 @@ struct string_list;\n>   * tracking branch.  Return the name of the remote if such a branch\n>   * exists, NULL otherwise.\n>   */\n> -char *unique_tracking_name(const char *name,\n> +char *unique_tracking_name(struct repository *repo,\n> +\t\t\t   const char *name,\n>  \t\t\t   struct object_id *oid,\n>  \t\t\t   int *dwim_remotes_matched,\n>  \t\t\t   struct string_list *dwim_remote_names);\n>\n> base-commit: c51408889c3b372814bc20b9431c3b74d0d268eb\n\n"},{"id":"555901","messageId":"xmqq33txfs8n.fsf@gitster.g","threadId":"66570","inReplyTo":"xmqqo6clfu19.fsf@gitster.g","subject":"Re: [Outreachy PATCH v2] checkout: pass the repository to unique_tracking_name()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-10-22T19:30:16Z","receivedAt":"2026-10-22T19:30:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Replace the last sentence with something like:\n>\n>     The callers still cannot call unique_tracking_name() with an\n>     arbitrary repository parameter other than the_repository, until\n>     the call in unique_tracking_name() to for_each_remote(), which\n>     only works with the_repository, is updated to take an arbitrary\n>     repository instance.\n>\n> perhaps?\n>\n> And explained that way, it becomes dubious if we chose a good place\n> to stop.  The updated unique_tracking_name() gives an illusion that\n> callers now can pass an arbitrary repository to it and expect it to\n> work correctly with the given repository, but it does not.\n>\n> So, I dunno.\n\nI think we need to improve the situation by doing something like the\nattached patch.  We already have similar provisions in environment.h\n(to clarify that have_git_dir() and friends only work with\n'the_repository'), hash.h ('the_hash_algo'), hex.h (get_hash_hex(),\nget_oid_hex(), etc.), path.h (GIT_PATH_FUNC() macro) and\nrepository.h ('the_repository' itself).\n\nAs we pass a 'struct repository' pointer to more functions, making\nsure they do not call functions that still work only with\n'the_repository' will become more important.\n\nI suspect that in remote.h, there may be more symbols that need to\nbe hidden when 'USE_THE_REPOSITORY_VARIABLE' is not defined, to\nensure functions written without the macro can truly work with\nan arbitrary repository instance.  The attached patch is just to\nillustrate the direction.\n\nThis is totally outside your topic and meant for more senior\ndevelopers who help polish the foundation of the codebase.\n\nThanks.\n\n\n remote.h | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git i/remote.h w/remote.h\nindex bfa5218c6e..eb7d4481eb 100644\n--- i/remote.h\n+++ w/remote.h\n@@ -145,8 +145,10 @@ int remote_is_configured(struct remote *remote, int in_repo);\n \n typedef int each_remote_fn(struct remote *remote, void *priv);\n \n+#ifdef USE_THE_REPOSITORY_VARIABLE\n /* iterate through struct remotes */\n int for_each_remote(each_remote_fn fn, void *priv);\n+#endif\n \n int remote_has_url(struct remote *remote, const char *url);\n struct strvec *push_url_of_remote(struct remote *remote);\n\n"},{"id":"555919","messageId":"CAFpMFfAhONvaXUVHhkXr9KV-G5hKT2kLi4pa4qZMpVZQUWgBxg@mail.gmail.com","threadId":"66570","inReplyTo":"xmqqo6clfu19.fsf@gitster.g","subject":"Re: [Outreachy PATCH v2] checkout: pass the repository to unique_tracking_name()","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-10-22T21:23:27Z","receivedAt":"2026-10-22T21:23:27Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"On Thu, Oct 22, 2026 at 7:51 PM Junio C Hamano <gitster@pobox.com> wrote:\n> The mention of for_each_remote() feels weirdly abrupt.  Many other\n> things still rely on the the_repository global variable, but\n> there must be a reason why for_each_remote() is singled out in the\n> context of this patch.  What is it?\n\n\nThanks for the review.\n\nYou are right. I mentioned for_each_remote() because\nunique_tracking_name() calls it to go through the remotes, and it\nstill reads them from the_repository. So the new repository\nparameter is not used everywhere yet, and a caller passing a\ndifferent repository would not get the right result.\n\nI will look into this more closely before sending anything else.\n\nThanks,\nOkhuomon\n\n"},{"id":"556108","messageId":"20261023211533.73433-1-okhuomonajayi54@gmail.com","threadId":"66570","inReplyTo":"20261022105641.68963-1-okhuomonajayi54@gmail.com","subject":"[Outreachy PATCH v3 0/2] checkout: make unique_tracking_name() use the given repository","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-10-23T21:15:31Z","receivedAt":"2026-10-23T21:15:31Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"unique_tracking_name() takes a repository since v2, but it still\nwent through the remotes with for_each_remote(), which only works\nwith the_repository. As Junio pointed out, that gave the illusion\nthat callers could pass any repository.\n\nPatch 1 adds repo_for_each_remote(), which takes a repository, and\nkeeps for_each_remote() as a wrapper that passes the_repository.\nPatch 2 is v2 with unique_tracking_name() using\nrepo_for_each_remote(), so everything it reads comes from the given\nrepository.\n\nChanges since v2:\n- New patch 1 adding repo_for_each_remote().\n- unique_tracking_name() now uses it instead of for_each_remote().\n- Dropped the sentence about for_each_remote() from the commit\n  message of patch 2.\n\n\nOkhuomon Ajayi (2):\n  remote: add repo_for_each_remote()\n  checkout: pass the repository to unique_tracking_name()\n\n builtin/checkout.c |  3 ++-\n builtin/worktree.c |  6 ++++--\n checkout.c         | 13 +++++++------\n checkout.h         |  4 +++-\n remote.c           | 14 ++++++++++----\n remote.h           |  2 ++\n 6 files changed, 28 insertions(+), 14 deletions(-)\n\n\nbase-commit: c51408889c3b372814bc20b9431c3b74d0d268eb\n-- \n2.56.0\n\n\n"},{"id":"556109","messageId":"20261023211533.73433-2-okhuomonajayi54@gmail.com","threadId":"66570","inReplyTo":"20261023211533.73433-1-okhuomonajayi54@gmail.com","subject":"[Outreachy PATCH v3 1/2] remote: add repo_for_each_remote()","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-10-23T21:15:32Z","receivedAt":"2026-10-23T21:15:32Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"for_each_remote() always reads the remotes of the_repository.\n\nAdd repo_for_each_remote(), which takes a repository, and turn\nfor_each_remote() into a wrapper that passes the_repository.\nCallers that are given a repository, such as\nunique_tracking_name() in the next patch, can then use the\nremotes of that repository.\n\nSigned-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>\n---\n remote.c | 14 ++++++++++----\n remote.h |  2 ++\n 2 files changed, 12 insertions(+), 4 deletions(-)\n\ndiff --git a/remote.c b/remote.c\nindex 71170f36a9..d18f39d19a 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -869,14 +869,15 @@ int remote_is_configured(struct remote *remote, int in_repo)\n \treturn !!remote->origin;\n }\n \n-int for_each_remote(each_remote_fn fn, void *priv)\n+int repo_for_each_remote(struct repository *repo,\n+\t\t\t each_remote_fn fn, void *priv)\n {\n \tint i, result = 0;\n-\tread_config(the_repository, 0);\n-\tfor (i = 0; i < the_repository->remote_state->remotes_nr && !result;\n+\tread_config(repo, 0);\n+\tfor (i = 0; i < repo->remote_state->remotes_nr && !result;\n \t     i++) {\n \t\tstruct remote *remote =\n-\t\t\tthe_repository->remote_state->remotes[i];\n+\t\t\trepo->remote_state->remotes[i];\n \t\tif (!remote)\n \t\t\tcontinue;\n \t\tresult = fn(remote, priv);\n@@ -884,6 +885,11 @@ int for_each_remote(each_remote_fn fn, void *priv)\n \treturn result;\n }\n \n+int for_each_remote(each_remote_fn fn, void *priv)\n+{\n+\treturn repo_for_each_remote(the_repository, fn, priv);\n+}\n+\n static void handle_duplicate(struct ref *ref1, struct ref *ref2)\n {\n \tif (strcmp(ref1->name, ref2->name)) {\ndiff --git a/remote.h b/remote.h\nindex cca02033b9..2a0bf416d9 100644\n--- a/remote.h\n+++ b/remote.h\n@@ -140,6 +140,8 @@ int remote_is_configured(struct remote *remote, int in_repo);\n typedef int each_remote_fn(struct remote *remote, void *priv);\n \n /* iterate through struct remotes */\n+int repo_for_each_remote(struct repository *repo,\n+\t\t\t each_remote_fn fn, void *priv);\n int for_each_remote(each_remote_fn fn, void *priv);\n \n int remote_has_url(struct remote *remote, const char *url);\n-- \n2.56.0\n\n\n"},{"id":"556110","messageId":"20261023211533.73433-3-okhuomonajayi54@gmail.com","threadId":"66570","inReplyTo":"20261023211533.73433-1-okhuomonajayi54@gmail.com","subject":"[Outreachy PATCH v3 2/2] checkout: pass the repository to unique_tracking_name()","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-10-23T21:15:33Z","receivedAt":"2026-10-23T21:15:33Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"unique_tracking_name() uses the_repository to read the\n\"checkout.defaultRemote\" configuration and look up the object\nID of a remote-tracking branch.\n\nPass the repository to unique_tracking_name() and through\ntracking_name_data so check_tracking_name() can use it for\nthe object lookup, and use repo_for_each_remote() so the\nremotes are also read from that repository. Update the three\ncallers to pass the_repository.\n\nThis removes the need for USE_THE_REPOSITORY_VARIABLE in\ncheckout.c.\n\nSigned-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>\n---\n builtin/checkout.c |  3 ++-\n builtin/worktree.c |  6 ++++--\n checkout.c         | 13 +++++++------\n checkout.h         |  4 +++-\n 4 files changed, 16 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 2d575a4f57..bad49368b9 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -1389,7 +1389,8 @@ static char *parse_remote_branch(const char *arg,\n \tint num_matches = 0;\n \tstruct string_list matched_remote_names = STRING_LIST_INIT_DUP;\n \n-\tchar *remote = unique_tracking_name(arg, rev, &num_matches,\n+\tchar *remote = unique_tracking_name(the_repository, arg, rev,\n+\t\t\t\t\t    &num_matches,\n \t\t\t\t\t    &matched_remote_names);\n \n \tif (remote && could_be_checkout_paths) {\ndiff --git a/builtin/worktree.c b/builtin/worktree.c\nindex 77ecd0f71f..203456bd23 100644\n--- a/builtin/worktree.c\n+++ b/builtin/worktree.c\n@@ -802,7 +802,8 @@ static char *dwim_branch(const struct add_opts *opts, const char *path, char **n\n \t\tint num_matches = 0;\n \t\tstruct string_list matched_remote_names = STRING_LIST_INIT_DUP;\n \n-\t\tremote = unique_tracking_name(*new_branch, &oid, &num_matches,\n+\t\tremote = unique_tracking_name(the_repository, *new_branch,\n+\t\t\t\t\t      &oid, &num_matches,\n \t\t\t\t\t      &matched_remote_names);\n \t\tif (!remote && num_matches > 1) {\n \t\t\tif (!opts->quiet &&\n@@ -938,7 +939,8 @@ static int add(int ac, const char **av, const char *prefix,\n \t\t\tint num_matches = 0;\n \t\t\tstruct string_list matched_remote_names = STRING_LIST_INIT_DUP;\n \n-\t\t\tremote = unique_tracking_name(branch, &oid, &num_matches,\n+\t\t\tremote = unique_tracking_name(the_repository, branch,\n+\t\t\t\t\t\t      &oid, &num_matches,\n \t\t\t\t\t\t      &matched_remote_names);\n \t\t\tif (remote) {\n \t\t\t\tnew_branch = branch;\ndiff --git a/checkout.c b/checkout.c\nindex a0d0229435..8a4812df8d 100644\n--- a/checkout.c\n+++ b/checkout.c\n@@ -1,5 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n-\n #include \"git-compat-util.h\"\n #include \"object-name.h\"\n #include \"remote.h\"\n@@ -11,6 +9,7 @@\n #include \"string-list.h\"\n \n struct tracking_name_data {\n+\tstruct repository *repo;\n \t/* const */ char *src_ref;\n \tchar *dst_ref;\n \tstruct object_id *dst_oid;\n@@ -30,7 +29,7 @@ static int check_tracking_name(struct remote *remote, void *cb_data)\n \tmemset(&query, 0, sizeof(struct refspec_item));\n \tquery.src = cb->src_ref;\n \tif (remote_find_tracking(remote, &query) ||\n-\t    repo_get_oid(the_repository, query.dst, cb->dst_oid)) {\n+\t    repo_get_oid(cb->repo, query.dst, cb->dst_oid)) {\n \t\tfree(query.dst);\n \t\treturn 0;\n \t}\n@@ -51,21 +50,23 @@ static int check_tracking_name(struct remote *remote, void *cb_data)\n \treturn 0;\n }\n \n-char *unique_tracking_name(const char *name, struct object_id *oid,\n+char *unique_tracking_name(struct repository *repo,\n+\t\t\t   const char *name, struct object_id *oid,\n \t\t\t   int *dwim_remotes_matched,\n \t\t\t   struct string_list *dwim_remote_names)\n {\n \tstruct tracking_name_data cb_data = TRACKING_NAME_DATA_INIT;\n \tconst char *default_remote = NULL;\n \n-\tif (!repo_config_get_string_tmp(the_repository,\n+\tif (!repo_config_get_string_tmp(repo,\n \t\t\t\t\t\"checkout.defaultremote\",\n \t\t\t\t\t&default_remote))\n \t\tcb_data.default_remote = default_remote;\n+\tcb_data.repo = repo;\n \tcb_data.src_ref = xstrfmt(\"refs/heads/%s\", name);\n \tcb_data.dst_oid = oid;\n \tcb_data.remote_names = dwim_remote_names;\n-\tfor_each_remote(check_tracking_name, &cb_data);\n+\trepo_for_each_remote(repo, check_tracking_name, &cb_data);\n \tif (dwim_remotes_matched)\n \t\t*dwim_remotes_matched = cb_data.num_matches;\n \tfree(cb_data.src_ref);\ndiff --git a/checkout.h b/checkout.h\nindex 0b185a0fc9..25fe7dfb7c 100644\n--- a/checkout.h\n+++ b/checkout.h\n@@ -3,6 +3,7 @@\n \n #include \"hash.h\"\n \n+struct repository;\n struct string_list;\n \n /*\n@@ -10,7 +11,8 @@ struct string_list;\n  * tracking branch.  Return the name of the remote if such a branch\n  * exists, NULL otherwise.\n  */\n-char *unique_tracking_name(const char *name,\n+char *unique_tracking_name(struct repository *repo,\n+\t\t\t   const char *name,\n \t\t\t   struct object_id *oid,\n \t\t\t   int *dwim_remotes_matched,\n \t\t\t   struct string_list *dwim_remote_names);\n-- \n2.56.0\n\n\n"},{"id":"557306","messageId":"CAP8UFD2_msUwNf1Opvt95jFWBoPi5H8jNCpQcH0ohYh26F4fLg@mail.gmail.com","threadId":"66570","inReplyTo":"20261023211533.73433-2-okhuomonajayi54@gmail.com","subject":"Re: [Outreachy PATCH v3 1/2] remote: add repo_for_each_remote()","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2026-11-03T12:41:18Z","receivedAt":"2026-11-03T12:41:18Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Fri, Oct 23, 2026 at 11:15 PM Okhuomon Ajayi\n<okhuomonajayi54@gmail.com> wrote:\n\n> -int for_each_remote(each_remote_fn fn, void *priv)\n> +int repo_for_each_remote(struct repository *repo,\n> +                        each_remote_fn fn, void *priv)\n>  {\n>         int i, result = 0;\n> -       read_config(the_repository, 0);\n> -       for (i = 0; i < the_repository->remote_state->remotes_nr && !result;\n> +       read_config(repo, 0);\n> +       for (i = 0; i < repo->remote_state->remotes_nr && !result;\n>              i++) {\n>                 struct remote *remote =\n> -                       the_repository->remote_state->remotes[i];\n> +                       repo->remote_state->remotes[i];\n\nIt looks like moving from `the_repository` to `repo` could be a good\nopportunity to unwrap some lines. For example something like:\n\n        int result = 0;\n        read_config(repo, 0);\n        for (int i = 0; i < repo->remote_state->remotes_nr && !result; i++) {\n                struct remote *remote = repo->remote_state->remotes[i];\n\nkeeps lines under our 80 characters limit and is a bit nicer to read.\n\nThanks.\n\n>                 if (!remote)\n>                         continue;\n>                 result = fn(remote, priv);\n\n"},{"id":"557413","messageId":"20261104090534.21838-1-okhuomonajayi54@gmail.com","threadId":"66570","inReplyTo":"20261023211533.73433-1-okhuomonajayi54@gmail.com","subject":"[Outreachy PATCH v4 0/2] checkout: make unique_tracking_name() use the given repository","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-11-04T09:05:32Z","receivedAt":"2026-11-04T09:05:32Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"Changes since v3:\n- In patch 1, unwrap the lines in repo_for_each_remote() that are\n  now short enough after the switch from the_repository to repo, as\n  Christian suggested. Patch 2 is unchanged.\n\nThanks, Christian, for the review.\n\nOkhuomon Ajayi (2):\n  remote: add repo_for_each_remote()\n  checkout: pass the repository to unique_tracking_name()\n\n builtin/checkout.c |  3 ++-\n builtin/worktree.c |  6 ++++--\n checkout.c         | 13 +++++++------\n checkout.h         |  4 +++-\n remote.c           | 18 +++++++++++-------\n remote.h           |  2 ++\n 6 files changed, 29 insertions(+), 17 deletions(-)\n\n\nbase-commit: c51408889c3b372814bc20b9431c3b74d0d268eb\n-- \n2.56.0\n\n\n"},{"id":"557414","messageId":"20261104090534.21838-2-okhuomonajayi54@gmail.com","threadId":"66570","inReplyTo":"20261104090534.21838-1-okhuomonajayi54@gmail.com","subject":"[Outreachy PATCH v4 1/2] remote: add repo_for_each_remote()","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-11-04T09:05:33Z","receivedAt":"2026-11-04T09:05:33Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"for_each_remote() always reads the remotes of the_repository.\n\nAdd repo_for_each_remote(), which takes a repository, and turn\nfor_each_remote() into a wrapper that passes the_repository.\nCallers that are given a repository, such as\nunique_tracking_name() in the next patch, can then use the\nremotes of that repository.\n\nSigned-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>\n---\n remote.c | 18 +++++++++++-------\n remote.h |  2 ++\n 2 files changed, 13 insertions(+), 7 deletions(-)\n\ndiff --git a/remote.c b/remote.c\nindex 71170f36a9..f070ad5a01 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -869,14 +869,13 @@ int remote_is_configured(struct remote *remote, int in_repo)\n \treturn !!remote->origin;\n }\n \n-int for_each_remote(each_remote_fn fn, void *priv)\n+int repo_for_each_remote(struct repository *repo,\n+\t\t\t each_remote_fn fn, void *priv)\n {\n-\tint i, result = 0;\n-\tread_config(the_repository, 0);\n-\tfor (i = 0; i < the_repository->remote_state->remotes_nr && !result;\n-\t     i++) {\n-\t\tstruct remote *remote =\n-\t\t\tthe_repository->remote_state->remotes[i];\n+\tint result = 0;\n+\tread_config(repo, 0);\n+\tfor (int i = 0; i < repo->remote_state->remotes_nr && !result; i++) {\n+\t\tstruct remote *remote = repo->remote_state->remotes[i];\n \t\tif (!remote)\n \t\t\tcontinue;\n \t\tresult = fn(remote, priv);\n@@ -884,6 +883,11 @@ int for_each_remote(each_remote_fn fn, void *priv)\n \treturn result;\n }\n \n+int for_each_remote(each_remote_fn fn, void *priv)\n+{\n+\treturn repo_for_each_remote(the_repository, fn, priv);\n+}\n+\n static void handle_duplicate(struct ref *ref1, struct ref *ref2)\n {\n \tif (strcmp(ref1->name, ref2->name)) {\ndiff --git a/remote.h b/remote.h\nindex cca02033b9..2a0bf416d9 100644\n--- a/remote.h\n+++ b/remote.h\n@@ -140,6 +140,8 @@ int remote_is_configured(struct remote *remote, int in_repo);\n typedef int each_remote_fn(struct remote *remote, void *priv);\n \n /* iterate through struct remotes */\n+int repo_for_each_remote(struct repository *repo,\n+\t\t\t each_remote_fn fn, void *priv);\n int for_each_remote(each_remote_fn fn, void *priv);\n \n int remote_has_url(struct remote *remote, const char *url);\n-- \n2.56.0\n\n\n"},{"id":"557415","messageId":"20261104090534.21838-3-okhuomonajayi54@gmail.com","threadId":"66570","inReplyTo":"20261104090534.21838-1-okhuomonajayi54@gmail.com","subject":"[Outreachy PATCH v4 2/2] checkout: pass the repository to unique_tracking_name()","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-11-04T09:05:34Z","receivedAt":"2026-11-04T09:05:34Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"unique_tracking_name() uses the_repository to read the\n\"checkout.defaultRemote\" configuration and look up the object\nID of a remote-tracking branch.\n\nPass the repository to unique_tracking_name() and through\ntracking_name_data so check_tracking_name() can use it for\nthe object lookup, and use repo_for_each_remote() so the\nremotes are also read from that repository. Update the three\ncallers to pass the_repository.\n\nThis removes the need for USE_THE_REPOSITORY_VARIABLE in\ncheckout.c.\n\nSigned-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>\n---\n builtin/checkout.c |  3 ++-\n builtin/worktree.c |  6 ++++--\n checkout.c         | 13 +++++++------\n checkout.h         |  4 +++-\n 4 files changed, 16 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 2d575a4f57..bad49368b9 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -1389,7 +1389,8 @@ static char *parse_remote_branch(const char *arg,\n \tint num_matches = 0;\n \tstruct string_list matched_remote_names = STRING_LIST_INIT_DUP;\n \n-\tchar *remote = unique_tracking_name(arg, rev, &num_matches,\n+\tchar *remote = unique_tracking_name(the_repository, arg, rev,\n+\t\t\t\t\t    &num_matches,\n \t\t\t\t\t    &matched_remote_names);\n \n \tif (remote && could_be_checkout_paths) {\ndiff --git a/builtin/worktree.c b/builtin/worktree.c\nindex 77ecd0f71f..203456bd23 100644\n--- a/builtin/worktree.c\n+++ b/builtin/worktree.c\n@@ -802,7 +802,8 @@ static char *dwim_branch(const struct add_opts *opts, const char *path, char **n\n \t\tint num_matches = 0;\n \t\tstruct string_list matched_remote_names = STRING_LIST_INIT_DUP;\n \n-\t\tremote = unique_tracking_name(*new_branch, &oid, &num_matches,\n+\t\tremote = unique_tracking_name(the_repository, *new_branch,\n+\t\t\t\t\t      &oid, &num_matches,\n \t\t\t\t\t      &matched_remote_names);\n \t\tif (!remote && num_matches > 1) {\n \t\t\tif (!opts->quiet &&\n@@ -938,7 +939,8 @@ static int add(int ac, const char **av, const char *prefix,\n \t\t\tint num_matches = 0;\n \t\t\tstruct string_list matched_remote_names = STRING_LIST_INIT_DUP;\n \n-\t\t\tremote = unique_tracking_name(branch, &oid, &num_matches,\n+\t\t\tremote = unique_tracking_name(the_repository, branch,\n+\t\t\t\t\t\t      &oid, &num_matches,\n \t\t\t\t\t\t      &matched_remote_names);\n \t\t\tif (remote) {\n \t\t\t\tnew_branch = branch;\ndiff --git a/checkout.c b/checkout.c\nindex a0d0229435..8a4812df8d 100644\n--- a/checkout.c\n+++ b/checkout.c\n@@ -1,5 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n-\n #include \"git-compat-util.h\"\n #include \"object-name.h\"\n #include \"remote.h\"\n@@ -11,6 +9,7 @@\n #include \"string-list.h\"\n \n struct tracking_name_data {\n+\tstruct repository *repo;\n \t/* const */ char *src_ref;\n \tchar *dst_ref;\n \tstruct object_id *dst_oid;\n@@ -30,7 +29,7 @@ static int check_tracking_name(struct remote *remote, void *cb_data)\n \tmemset(&query, 0, sizeof(struct refspec_item));\n \tquery.src = cb->src_ref;\n \tif (remote_find_tracking(remote, &query) ||\n-\t    repo_get_oid(the_repository, query.dst, cb->dst_oid)) {\n+\t    repo_get_oid(cb->repo, query.dst, cb->dst_oid)) {\n \t\tfree(query.dst);\n \t\treturn 0;\n \t}\n@@ -51,21 +50,23 @@ static int check_tracking_name(struct remote *remote, void *cb_data)\n \treturn 0;\n }\n \n-char *unique_tracking_name(const char *name, struct object_id *oid,\n+char *unique_tracking_name(struct repository *repo,\n+\t\t\t   const char *name, struct object_id *oid,\n \t\t\t   int *dwim_remotes_matched,\n \t\t\t   struct string_list *dwim_remote_names)\n {\n \tstruct tracking_name_data cb_data = TRACKING_NAME_DATA_INIT;\n \tconst char *default_remote = NULL;\n \n-\tif (!repo_config_get_string_tmp(the_repository,\n+\tif (!repo_config_get_string_tmp(repo,\n \t\t\t\t\t\"checkout.defaultremote\",\n \t\t\t\t\t&default_remote))\n \t\tcb_data.default_remote = default_remote;\n+\tcb_data.repo = repo;\n \tcb_data.src_ref = xstrfmt(\"refs/heads/%s\", name);\n \tcb_data.dst_oid = oid;\n \tcb_data.remote_names = dwim_remote_names;\n-\tfor_each_remote(check_tracking_name, &cb_data);\n+\trepo_for_each_remote(repo, check_tracking_name, &cb_data);\n \tif (dwim_remotes_matched)\n \t\t*dwim_remotes_matched = cb_data.num_matches;\n \tfree(cb_data.src_ref);\ndiff --git a/checkout.h b/checkout.h\nindex 0b185a0fc9..25fe7dfb7c 100644\n--- a/checkout.h\n+++ b/checkout.h\n@@ -3,6 +3,7 @@\n \n #include \"hash.h\"\n \n+struct repository;\n struct string_list;\n \n /*\n@@ -10,7 +11,8 @@ struct string_list;\n  * tracking branch.  Return the name of the remote if such a branch\n  * exists, NULL otherwise.\n  */\n-char *unique_tracking_name(const char *name,\n+char *unique_tracking_name(struct repository *repo,\n+\t\t\t   const char *name,\n \t\t\t   struct object_id *oid,\n \t\t\t   int *dwim_remotes_matched,\n \t\t\t   struct string_list *dwim_remote_names);\n-- \n2.56.0\n\n\n"}]}