Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence the detachedHead warning when ref_type is a revision #12510

Merged

Conversation

boblail
Copy link
Contributor

@boblail boblail commented Dec 2, 2021

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 and you haven't specified 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 <new-branch-name>

Or undo this operation with:

   git switch -

Turn off this advice by setting config variable advice.detachedHead to false

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

The PR that added this Homebrew#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 <new-branch-name>

Or undo this operation with:

   git switch -

Turn off this advice by setting config variable advice.detachedHead to false
```
@Bo98
Copy link
Member

Bo98 commented Dec 3, 2021

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 and you haven't specified a :branch or :tag.

Makes sense, but what scenario does that extra part in config_repo cover?

@boblail
Copy link
Contributor Author

boblail commented Dec 3, 2021

The extra part in config_repo covers the scenario where you're upgrading a formula (that uses :revision) that you'd previously installed. If you already have a repo cloned to brew --cache -s <that-formula>, then when you checkout a new revision, git would show that detached head message again unless we reclone it or just set that config in config_repo

@Bo98
Copy link
Member

Bo98 commented Dec 3, 2021

As in a repo cached before the change? Since -c advice.detachedHead=false will automatically set git config for new clones.

@MikeMcQuaid
Copy link
Member

I'm fine with this when @Bo98 is.

@boblail
Copy link
Contributor Author

boblail commented Dec 3, 2021

As in a repo cached before the change?

Yep! Exactly

@Bo98 Bo98 merged commit 371122d into Homebrew:master Dec 3, 2021
@Bo98
Copy link
Member

Bo98 commented Dec 3, 2021

Thanks!

@github-actions github-actions bot added the outdated PR was locked due to age label Jan 3, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants