git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Justin Tobler <jltobler@gmail.com>
To: git@vger.kernel.org
Cc: ps@pks.im, Justin Tobler <jltobler@gmail.com>
Subject: [PATCH 1/2] remote: allow `guess_remote_head()` to suppress advice
Date: Wed, 19 Mar 2025 20:46:45 -0500	[thread overview]
Message-ID: <20250320014646.2899791-2-jltobler@gmail.com> (raw)
In-Reply-To: <20250320014646.2899791-1-jltobler@gmail.com>

The `repo_default_branch_name()` invoked through `guess_remote_head()`
is configured to always display the default branch advice message.

Add an additional parameter to the `guess_remote_head()` function
signature to enable suppression of advice messages and update call sites
accordingly.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
---
 builtin/clone.c  | 4 ++--
 builtin/fetch.c  | 2 +-
 builtin/remote.c | 2 +-
 remote.c         | 4 ++--
 remote.h         | 2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/builtin/clone.c b/builtin/clone.c
index f14229abf4..9eb66234bc 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -450,7 +450,7 @@ static struct ref *wanted_peer_refs(struct clone_opts *opts,
 		if (head)
 			tail_link_ref(head, &tail);
 		if (option_single_branch)
-			refs = to_free = guess_remote_head(head, refs, 0);
+			refs = to_free = guess_remote_head(head, refs, 0, 0);
 	} else if (option_single_branch) {
 		local_refs = NULL;
 		tail = &local_refs;
@@ -1523,7 +1523,7 @@ int cmd_clone(int argc,
 	}
 
 	remote_head = find_ref_by_name(refs, "HEAD");
-	remote_head_points_at = guess_remote_head(remote_head, mapped_refs, 0);
+	remote_head_points_at = guess_remote_head(remote_head, mapped_refs, 0, 0);
 
 	if (option_branch) {
 		our_head_points_at = find_remote_branch(mapped_refs, option_branch);
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 95fd0018b9..a4f5b3e683 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1638,7 +1638,7 @@ static int set_head(const struct ref *remote_refs, struct remote *remote)
 
 	get_fetch_map(remote_refs, &refspec, &fetch_map_tail, 0);
 	matches = guess_remote_head(find_ref_by_name(remote_refs, "HEAD"),
-				    fetch_map, 1);
+				    fetch_map, 1, 0);
 	for (ref = matches; ref; ref = ref->next) {
 		string_list_append(&heads, strip_refshead(ref->name));
 	}
diff --git a/builtin/remote.c b/builtin/remote.c
index 1b7aad8838..ebd1a796d2 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -511,7 +511,7 @@ static int get_head_names(const struct ref *remote_refs, struct ref_states *stat
 
 	get_fetch_map(remote_refs, &refspec, &fetch_map_tail, 0);
 	matches = guess_remote_head(find_ref_by_name(remote_refs, "HEAD"),
-				    fetch_map, 1);
+				    fetch_map, 1, 0);
 	for (ref = matches; ref; ref = ref->next)
 		string_list_append(&states->heads, abbrev_branch(ref->name));
 
diff --git a/remote.c b/remote.c
index e609cf5c56..e9e55ecdbf 100644
--- a/remote.c
+++ b/remote.c
@@ -2297,7 +2297,7 @@ struct ref *get_local_heads(void)
 
 struct ref *guess_remote_head(const struct ref *head,
 			      const struct ref *refs,
-			      int all)
+			      int all, int quiet)
 {
 	const struct ref *r;
 	struct ref *list = NULL;
@@ -2316,7 +2316,7 @@ struct ref *guess_remote_head(const struct ref *head,
 
 	/* If a remote branch exists with the default branch name, let's use it. */
 	if (!all) {
-		char *default_branch = repo_default_branch_name(the_repository, 0);
+		char *default_branch = repo_default_branch_name(the_repository, quiet);
 		char *ref = xstrfmt("refs/heads/%s", default_branch);
 
 		r = find_ref_by_name(refs, ref);
diff --git a/remote.h b/remote.h
index 6be5031f64..49c7b644bb 100644
--- a/remote.h
+++ b/remote.h
@@ -395,7 +395,7 @@ struct ref *get_local_heads(void);
  */
 struct ref *guess_remote_head(const struct ref *head,
 			      const struct ref *refs,
-			      int all);
+			      int all, int quiet);
 
 /* Return refs which no longer exist on remote */
 struct ref *get_stale_heads(struct refspec *rs, struct ref *fetch_map);
-- 
2.49.0


  reply	other threads:[~2025-03-20  2:21 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-19  9:53 bug: git shows hints that should be suppressed alan
2025-03-19  9:58 ` alan
2025-03-19 14:45 ` Elijah Newren
2025-03-20  1:36   ` Justin Tobler
2025-03-20  1:46     ` [PATCH 0/2] clone: suppress unexpected advice message during clone Justin Tobler
2025-03-20  1:46       ` Justin Tobler [this message]
2025-03-20  5:13         ` [PATCH 1/2] remote: allow `guess_remote_head()` to suppress advice Patrick Steinhardt
2025-03-20 23:30           ` Justin Tobler
2025-03-21  8:52           ` Junio C Hamano
2025-03-20  1:46       ` [PATCH 2/2] clone: suppress unexpected default branch advice Justin Tobler
2025-03-20  5:13         ` Patrick Steinhardt
2025-03-20 23:36           ` Justin Tobler
2025-03-20 11:10       ` [PATCH 0/2] clone: suppress unexpected advice message during clone Phillip Wood
2025-03-20 23:48         ` Justin Tobler
2025-03-21 16:42           ` Phillip Wood
2025-03-21 23:16       ` [PATCH v2 0/3] " Justin Tobler
2025-03-21 23:16         ` [PATCH v2 1/3] remote: allow `guess_remote_head()` to suppress advice Justin Tobler
2025-03-24  9:31           ` Phillip Wood
2025-03-24 15:21             ` Justin Tobler
2025-03-24 19:29               ` phillip.wood123
2025-03-21 23:16         ` [PATCH v2 2/3] builtin/clone: suppress unexpected default branch advice Justin Tobler
2025-03-24  9:32           ` Phillip Wood
2025-03-24 15:35             ` Justin Tobler
2025-03-21 23:16         ` [PATCH v2 3/3] advice: allow disabling default branch name advice Justin Tobler
2025-03-24  9:32           ` Phillip Wood
2025-03-23 19:38         ` [PATCH v2 0/3] clone: suppress unexpected advice message during clone Junio C Hamano
2025-03-25  0:51         ` [PATCH v3 " Justin Tobler
2025-03-25  0:51           ` [PATCH v3 1/3] remote: allow `guess_remote_head()` to suppress advice Justin Tobler
2025-03-25  0:51           ` [PATCH v3 2/3] builtin/clone: suppress unexpected default branch advice Justin Tobler
2025-03-25  0:51           ` [PATCH v3 3/3] advice: allow disabling default branch name advice Justin Tobler
2025-03-25 14:35           ` [PATCH v3 0/3] clone: suppress unexpected advice message during clone Phillip Wood
2025-03-20  4:05     ` bug: git shows hints that should be suppressed alan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250320014646.2899791-2-jltobler@gmail.com \
    --to=jltobler@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=ps@pks.im \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).