]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'hn/checkout-track-fetch' into seen
authorJunio C Hamano <gitster@pobox.com>
Thu, 30 Jul 2026 17:44:33 +0000 (10:44 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 30 Jul 2026 17:44:33 +0000 (10:44 -0700)
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

1  2 
Documentation/git-checkout.adoc
Documentation/git-switch.adoc
branch.c
branch.h
builtin/checkout.c
t/t7201-co.sh

Simple merge
Simple merge
diff --cc branch.c
index 22f4f46b96ed3a326fe87bf79e9643d155acebbe,46ae7f00354c9db823231ef17d870c4108ea0444..31056f7040b120667499abfc33eada3be236d6b8
+++ 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 branch.h
Simple merge
index 09b3c87e2a1280ef2d39e54c7314170697e48287,805df07707dc618a9a44fdcda0e4c79169fa46f9..f777a21a1283beabc7615a1e48652157f974f3d4
  #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"
diff --cc t/t7201-co.sh
Simple merge