From: Junio C Hamano Date: Thu, 30 Jul 2026 17:44:33 +0000 (-0700) Subject: Merge branch 'hn/checkout-track-fetch' into seen X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9ec7dbfd677ca7e19e22953e51605f42cd302efe;p=thirdparty%2Fgit.git Merge branch 'hn/checkout-track-fetch' into seen The 'git checkout --track=...' command has been taught to optionally fetch the branch from the remote that the new branch will work with. * hn/checkout-track-fetch: checkout: extend --track with a "fetch" mode to refresh start-point branch: expose helpers for finding the remote owning a tracking ref --- 9ec7dbfd677ca7e19e22953e51605f42cd302efe diff --cc branch.c index 22f4f46b96,46ae7f0035..31056f7040 --- a/branch.c +++ b/branch.c @@@ -59,9 -52,54 +52,54 @@@ static int find_tracked_branch(struct r return 0; } + void find_tracking_remote_for_ref(struct tracking *tracking, + struct string_list *ambiguous_remotes) + { + struct find_tracked_branch_cb ftb_cb = { + .tracking = tracking, + .ambiguous_remotes = ambiguous_remotes, + }; + + for_each_remote(find_tracked_branch, &ftb_cb); + } + + void advise_ambiguous_fetch_refspec(const char *dst, + const struct string_list *ambiguous_remotes) + { + struct strbuf remotes_advice = STRBUF_INIT; + struct string_list_item *item; + + if (!advice_enabled(ADVICE_AMBIGUOUS_FETCH_REFSPEC)) + return; + + for_each_string_list_item(item, ambiguous_remotes) + /* + * TRANSLATORS: This is a line listing a remote with duplicate + * refspecs in the advice message below. For RTL languages you'll + * probably want to swap the "%s" and leading " " space around. + */ + strbuf_addf(&remotes_advice, _(" %s\n"), item->string); + + /* + * TRANSLATORS: The second argument is a \n-delimited list of + * duplicate refspecs, composed above. + */ + advise(_("There are multiple remotes whose fetch refspecs map to the remote\n" + "tracking ref '%s':\n" + "%s" + "\n" + "This is typically a configuration error.\n" + "\n" + "To support setting up tracking branches, ensure that\n" + "different remotes' fetch refspecs map into different\n" + "tracking namespaces."), dst, + remotes_advice.buf); + strbuf_release(&remotes_advice); + } + static int should_setup_rebase(const char *origin) { - switch (autorebase) { + switch (repo_config_values(the_repository)->autorebase) { case AUTOREBASE_NEVER: return 0; case AUTOREBASE_LOCAL: diff --cc builtin/checkout.c index 09b3c87e2a,805df07707..f777a21a12 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@@ -29,10 -31,8 +30,11 @@@ #include "repo-settings.h" #include "resolve-undo.h" #include "revision.h" + #include "run-command.h" +#include "sequencer.h" #include "setup.h" +#include "sparse-index.h" +#include "strvec.h" #include "submodule.h" #include "symlinks.h" #include "trace2.h"