From 68245e0f606309fe89b72201435b507de4e1ef36 Mon Sep 17 00:00:00 2001 From: Bob Lail Date: Thu, 2 Dec 2021 11:07:39 -0600 Subject: [PATCH] Silence the detachedHead warning when ref_type is a revision The PR that added this #8622 didn't actually resolve the problem because you see the warning when the `@ref_type` you've specified is a `:revision` (not a `:branch` or `:tag`). The output looks like this: ``` ==> Checking out revision 3b3527f5050270cf1acd280691b09b5abe130e73 Note: switching to '3b3527f5050270cf1acd280691b09b5abe130e73' You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by switching back to a branch. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -c with the switch command. Example: git switch -c Or undo this operation with: git switch - Turn off this advice by setting config variable advice.detachedHead to false ``` --- Library/Homebrew/download_strategy.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 237d7753df..98df56c889 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -883,9 +883,9 @@ class GitDownloadStrategy < VCSDownloadStrategy case @ref_type when :branch, :tag args << "--branch" << @ref - args << "-c" << "advice.detachedHead=false" # silences detached head warning end + args << "-c" << "advice.detachedHead=false" # silences detached head warning args << @url << cached_location end @@ -915,6 +915,9 @@ class GitDownloadStrategy < VCSDownloadStrategy command! "git", args: ["config", "remote.origin.tagOpt", "--no-tags"], chdir: cached_location + command! "git", + args: ["config", "advice.detachedHead", "false"], + chdir: cached_location end sig { params(timeout: T.nilable(Time)).void }